-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiff2bmp.c
48 lines (32 loc) · 1013 Bytes
/
tiff2bmp.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
/*****************************************************************************
A simple client for the tiff decoder. The same concept as for png:
1. Info() returns information about the image
2. Decode()
3. Convert()
*********************************************************************/
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <malloc.h>
#include "bmp.h"
#include "lzw.h"
#include "tiff.h"
extern void WriteBmp(struct BMP *bmp, char *path);
static struct TIFFINFO T;
extern void tiff2bmp(char *path)
{
enum BITPERPIXELENUM FORMAT= BITPERPIXEL32;
if ( TIFFInfo(&T) )
{
int bmpSize= BmpSize(FORMAT, T.ImageWidth, T.ImageHeight);
struct BMP *bmp= malloc(bmpSize);
if ( bmp )
{
BmpPrep(bmp, FORMAT, T.ImageWidth, T.ImageHeight);
TIFFDecode(&T);
TIFFConvert(&T, FORMAT, (PBYTE)bmp + bmp->bmfh.bfOffBits, bmp->biPitch);
WriteBmp(bmp, path);
free(bmp);
}
}
if (T.tiff_mem) free(T.tiff_mem);
}