-/****************************************************************************
- * *
- * FUNCTION : lwrite(int fh, VOID FAR *pv, DWORD ul) *
- * *
- * PURPOSE : Writes data in steps of 32k till all the data is written. *
- * *
- * RETURNS : 0 - If write did not proceed correctly. *
- * number of bytes written otherwise. *
- * *
- ****************************************************************************/
-
-DWORD PASCAL lwrite(int fh, VOID FAR *pv, DWORD ul)
-{
- DWORD ulT = ul;
-#if defined(WINNT) || defined(__WIN32__) || defined(__WIN32__)
- BYTE *hp = (BYTE *) pv;
-#else
- BYTE huge *hp = (BYTE huge *) pv;
-#endif
- while (ul > MAXREAD) {
- if (_lwrite(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
- return 0;
- ul -= MAXREAD;
- hp += MAXREAD;
- }
- if (_lwrite(fh, (LPSTR) hp, (WORD) ul) != (WORD) ul)
- return 0;
- return ulT;
-}
-
-/****************************************************************************
- *
- * FUNCTION : ReadDIB(hWnd)
- *
- * PURPOSE : Reads a DIB from a file, obtains a handle to its
- * BITMAPINFO struct. and loads the DIB. Once the DIB
- * is loaded, the function also creates a bitmap and
- * palette out of the DIB for a device-dependent form.
- *
- * RETURNS : TRUE - DIB loaded and bitmap/palette created
- * The DIBINIT structure pointed to by pInfo is
- * filled with the appropriate handles.
- * FALSE - otherwise
- *
- ****************************************************************************/
-BOOL ReadDIB(LPSTR lpFileName, HBITMAP *bitmap, HPALETTE *palette)
-{
- int fh;
- LPBITMAPINFOHEADER lpbi;
- OFSTRUCT of;
- BITMAPFILEHEADER bf;
- WORD nNumColors;
- BOOL result = FALSE;
- char str[128];
- WORD offBits;
- HDC hDC;
- BOOL bCoreHead = FALSE;
- HANDLE hDIB = 0;
-
- /* Open the file and get a handle to it's BITMAPINFO */
-
- fh = OpenFile (lpFileName, &of, OF_READ);
- if (fh == -1) {
- wsprintf(str,"Can't open file '%ls'", (LPSTR)lpFileName);
- MessageBox(NULL, str, "Error", MB_ICONSTOP | MB_OK);
- return (0);
- }
-
- hDIB = GlobalAlloc(GHND, (DWORD)(sizeof(BITMAPINFOHEADER) +
- 256 * sizeof(RGBQUAD)));
- if (!hDIB)
- return(0);
-
-#ifdef __WINDOWS_386__
- lpbi = (LPBITMAPINFOHEADER)MK_FP32(GlobalLock(hDIB));
-#else
- lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIB);
-#endif
+ // we use positive height here which corresponds to a DIB with normal, i.e.
+ // bottom to top, order -- normally using negative height (which means
+ // reversed for MS and hence natural for all the normal people top to
+ // bottom line scan order) could be used to avoid the need for the image
+ // reversal in Create(image) but this doesn't work under NT, only Win9x!
+ info->bmiHeader.biHeight = height;