2002.04.08 22:49 "Trouble displaying TIFF image", by Randall Emery
I have an existing program that loads and displays a bit map image, and I'm working in MS C++ to modify the program to use a TIFF image instead.
My basic approach has been to load in a TIFF image, translate it to a bit map format, and then let the program continue along as before. I'm doing this translation using the LoadTIFFinDIB function, which is defined in \contrib\win95\tiff2dib.c of the libtiff 3.5.7 download for windows.
The original program reads in a bit map file with the following function call: ghBkgrndBitMap = LoadResource(ghInst, FindResource(ghInst, MAKEINTRESOURCE(IDB_BITMAP2), RT_BITMAP) );
I've included tiff2dib.c in my project file, defined a variable to hold the bit map with "HANDLE hDIB = NULL;", and replaced the call above with the following code:
hDIB = LoadTIFFinDIB("C:\\qtlogo.tif"); //original .bmp file saved as a
ghBkgrndBitMap = hDIB;
However, despite what appears to me to be a successful call to LoadTIFFinDIB (I get messages that tags 317 and "Thresholding" will be ignored, but hDIB points to a new area of memory), I get a black screen when the program displays the image.
If you have any insights into this problem, I'd really appreciate the help. I'm brand new to the libtiff library.
P.S. Definitions of the variables in the original function call follow:
HANDLE ghBkgrndBitMap = NULL; /* bitmap we paint on the background of our client windows */
typedef CHAR *LPSTR, *PSTR;
typedef unsigned long DWORD;
typedef unsigned short WORD;
/* UNICODE */
#define MAKEINTRESOURCEA(i) (LPSTR)((DWORD)((WORD)(i)))
#define MAKEINTRESOURCEW(i) (LPWSTR)((DWORD)((WORD)(i)))
#define MAKEINTRESOURCE MAKEINTRESOURCEW
#define MAKEINTRESOURCE MAKEINTRESOURCEA
#endif // !UNICODE
#define IDB_BITMAP2 113
#define RT_BITMAP MAKEINTRESOURCE(2)