-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtif2bmp.c
executable file
·95 lines (82 loc) · 2.3 KB
/
tif2bmp.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
92
93
94
95
/************************************************
*
* file tif2bmp.c
*
* Functions: This file contains
* main
*
* Purpose:
* This program creates a bmp file
* that is just like the input tiff file.
*
* External Calls:
* imageio.c
* does_not_exist
* get_image_size
* read_image_array
* write_image_array
* free_image_array
* create_allocate_bmp_file
*
* Modifications:
* 27 September 1998 - created
*
*************************************************/
#include "cips.h"
int does_not_exist();
int create_image_file();
int get_image_size();
int read_image_array();
int free_image_array();
int write_image_array();
int create_allocate_bmp_file();
int main(argc, argv)
int argc;
char *argv[];
{
char *cc;
char reply[80];
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: tif2bmp tif-file-name bmp-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], ".tif");
if(cc == NULL){
printf("\nERROR %s must be a tiff file",
argv[1]);
exit(0);
} /* ends tif */
cc = strstr(argv[2], ".bmp");
if(cc == NULL){ /* create a bmp */
printf("\nERROR %s must be a bmp file name",
argv[2]);
exit(0);
}
get_image_size(argv[1], &l, &w);
/********* DEBUG
printf("\nDEBUG input %s l=%d w=%d", argv[1], l, w);
printf("\nDEBUG Hit enter to continue");
**********/
the_image = allocate_image_array(l, w);
gets(reply);
bmheader.height = l;
bmheader.width = w;
create_allocate_bmp_file(argv[2],
&bmp_file_header,
&bmheader);
read_image_array(argv[1], the_image);
write_image_array(argv[2], the_image);
free_image_array(the_image, l);
} /* ends main */