forked from Dwayne-Phillips/CIPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbmp2tif.c
executable file
·91 lines (77 loc) · 2.19 KB
/
bmp2tif.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/************************************************
*
* file bmp2tif.c
*
* Functions: This file contains
* main
*
* Purpose:
* This program creates a tiff file
* that is just like the input bmp file.
*
* External Calls:
* imageio.c
* does_not_exist
* get_image_size
* read_image_array
* write_image_array
* free_image_array
* create_allocate_tif_file
*
* Modifications:
* 27 September 1998 - created
*
*************************************************/
int does_not_exist();
int get_image_size();
int create_allocate_tiff_file();
int read_image_array();
int write_image_array();
int free_image_array();
#include "cips.h"
int main(argc, argv)
int argc;
char *argv[];
{
char *cc;
long l, w;
int ok = 0;
short **the_image;
struct tiff_header_struct image_header;
struct bmpfileheader bmp_file_header;
struct bitmapheader bmheader;
if(argc < 3 || argc > 3){
printf(
"\nusage: bmp2tif bmp-file-name tif-file-name\n");
exit(-1);
}
if(does_not_exist(argv[1])){
printf("\nERROR input file %s does not exist",
argv[1]);
exit(0);
}
cc = strstr(argv[1], ".bmp");
if(cc == NULL){
printf("\nERROR %s must be a bmp file",
argv[1]);
exit(0);
} /* ends tif */
cc = strstr(argv[2], ".tif");
if(cc == NULL){ /* create a tif */
printf("\nERROR %s must be a tiff file name",
argv[2]);
exit(0);
}
get_image_size(argv[1], &l, &w);
the_image = allocate_image_array(l, w);
image_header.lsb = 1;
image_header.bits_per_pixel = 8;
image_header.image_length = l;
image_header.image_width = w;;
image_header.strip_offset = 1000;
create_allocate_tiff_file(argv[2],
&image_header);
read_image_array(argv[1], the_image);
write_image_array(argv[2], the_image);
free_image_array(the_image, l);
} /* ends main */