-#endif // wxUSE_IMAGE
-
-// ============================================================================
-// old DIB code, to be integrated in wxDIB class
-// ============================================================================
-
-/*
- * Routines for dealing with Device Independent Bitmaps.
- *
- * wxReadDIB() - Reads a DIB
- * wxWriteDIB() - Writes a global handle in CF_DIB format
- * to a file.
- * wxPaletteSize() - Calculates the palette size in bytes
- * of given DIB
- * wxDibNumColors() - Determines the number of colors in DIB
- * wxDibFromBitmap() - Creates a DIB repr. the DDB passed in.
- * lread() - Private routine to read more than 64k
- * lwrite() - Private routine to write more than 64k
- */
-
-#ifndef SEEK_CUR
-/* flags for _lseek */
-#define SEEK_CUR 1
-#define SEEK_END 2
-#define SEEK_SET 0
-#endif
-
-#define MAXREAD 32768 /* Number of bytes to be read during */
- /* each read operation. */
-
-/* Header signatutes for various resources */
-#define BFT_ICON 0x4349 /* 'IC' */
-#define BFT_BITMAP 0x4d42 /* 'BM' */
-#define BFT_CURSOR 0x5450 /* 'PT(' */
-
-/* macro to determine if resource is a DIB */
-#define ISDIB(bft) ((bft) == BFT_BITMAP)
-
-/* Macro to align given value to the closest DWORD (unsigned long ) */
-#define ALIGNULONG(i) ((i+3)/4*4)
-
-/* Macro to determine to round off the given value to the closest byte */
-#define WIDTHBYTES(i) ((i+31)/32*4)
-
-#define PALVERSION 0x300
-#define MAXPALETTE 256 /* max. # supported palette entries */
-
-static DWORD lread(int fh, VOID FAR *pv, DWORD ul);
-static DWORD lwrite(int fh, VOID FAR *pv, DWORD ul);
-
-static bool wxWriteDIB (LPTSTR szFile,HANDLE hdib);
-WORD wxPaletteSize (VOID FAR * pv); // This is non-static as some apps use it externally
-static WORD wxDibNumColors (VOID FAR * pv);
-static bool wxMakeBitmapAndPalette(HDC,HANDLE,HPALETTE *,HBITMAP *);
-
-/*
- * FUNCTION : wxWriteDIB(LPSTR szFile,HANDLE hdib)
- * PURPOSE : Write a global handle in CF_DIB format to a file.
- * RETURNS : TRUE - if successful.
- * FALSE - otherwise
- */
-
-static bool wxWriteDIB(LPTSTR szFile, HANDLE hdib)
-{
- BITMAPFILEHEADER hdr;
- LPBITMAPINFOHEADER lpbi;
- int fh;
- OFSTRUCT of;
-
- if (!hdib)
- return FALSE;
-
- fh = OpenFile(wxConvertWX2MB(szFile), &of, OF_CREATE | OF_READWRITE);
- if (fh == -1)
- return FALSE;
-
- lpbi = (LPBITMAPINFOHEADER) GlobalLock(hdib);
-
- /* Fill in the fields of the file header */
- hdr.bfType = BFT_BITMAP;
- hdr.bfSize = GlobalSize(hdib) + sizeof(BITMAPFILEHEADER);
- hdr.bfReserved1 = 0;
- hdr.bfReserved2 = 0;
- hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + lpbi->biSize +
- wxPaletteSize(lpbi);
-
- /* Write the file header */
- _lwrite(fh, (LPSTR) &hdr, sizeof(BITMAPFILEHEADER));
-
- /* Write the DIB header and the bits */
- lwrite(fh, (LPSTR) lpbi, GlobalSize(hdib));
-
- GlobalUnlock(hdib);
- _lclose(fh);
- return TRUE;
-}
-
-/*
- * FUNCTION : wxPaletteSize(VOID FAR * pv)
- * PURPOSE : Calculates the palette size in bytes. If the info. block
- * is of the BITMAPCOREHEADER type, the number of colors is
- * multiplied by 3 to give the palette size, otherwise the
- * number of colors is multiplied by 4.
- * RETURNS : Palette size in number of bytes.
- */
-
-WORD wxPaletteSize(VOID FAR * pv)
-{
- LPBITMAPINFOHEADER lpbi;
- WORD NumColors;
-
- lpbi = (LPBITMAPINFOHEADER) pv;
- NumColors = wxDibNumColors(lpbi);
-
- if (lpbi->biSize == sizeof(BITMAPCOREHEADER))
- return (WORD)(NumColors * sizeof(RGBTRIPLE));
- else
- return (WORD)(NumColors * sizeof(RGBQUAD));
-}
-
-/*
- * FUNCTION : wxDibNumColors(VOID FAR * pv)
- * PURPOSE : Determines the number of colors in the DIB by looking at
- * the BitCount filed in the info block.
- * RETURNS : The number of colors in the DIB. *
- */
-
-static WORD wxDibNumColors(VOID FAR *pv)
-{
- int bits;
- BITMAPINFOHEADER *lpbi;
- BITMAPCOREHEADER *lpbc;
-
- lpbi = ((BITMAPINFOHEADER*) pv);
- lpbc = ((BITMAPCOREHEADER*) pv);
-
- /* With the BITMAPINFO format headers, the size of the palette
- * is in biClrUsed, whereas in the BITMAPCORE - style headers, it
- * is dependent on the bits per pixel ( = 2 raised to the power of
- * bits/pixel).
- */
- if (lpbi->biSize != sizeof(BITMAPCOREHEADER)) {
- if (lpbi->biClrUsed != 0)
- return (WORD) lpbi->biClrUsed;
- bits = lpbi->biBitCount;
- }
- else
- bits = lpbc->bcBitCount;
-
- switch (bits) {
- case 1:
- return 2;
- case 4:
- return 16;
- case 8:
- return 256;
- default:
- /* A 24 bitcount DIB has no color table */
- return 0;
- }
-}
-
-/*
- * FUNCTION : lread(int fh, VOID FAR *pv, DWORD ul)
- * PURPOSE : Reads data in steps of 32k till all the data has been read.
- * RETURNS : 0 - If read did not proceed correctly.
- * number of bytes read otherwise.
- */
-
-static DWORD lread(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 > (DWORD) MAXREAD) {
- if (_lread(fh, (LPSTR) hp, (WORD) MAXREAD) != MAXREAD)
- return 0;
- ul -= MAXREAD;
- hp += MAXREAD;
- }
- if (_lread(fh, (LPSTR) hp, (WXUINT) ul) != (WXUINT) ul)
- return 0;
- return ulT;
-}
-
-/*
- * 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.
- */
-
-static DWORD lwrite(int fh, VOID FAR *pv, DWORD ul)