X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8cb172b4f12fae80b06d5936108a1bc7f2521674..316189733a8b7f28aa7f9f555884bb45da30da33:/src/msw/microwin.c diff --git a/src/msw/microwin.c b/src/msw/microwin.c index a399e32749..fbb20d0cd4 100644 --- a/src/msw/microwin.c +++ b/src/msw/microwin.c @@ -6,15 +6,11 @@ // Created: 2001-05-31 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// */ -#ifdef __GNUG__ - #pragma implementation "microwin.h" -#endif - #include "mwtypes.h" #include "windows.h" #include "wintern.h" @@ -283,3 +279,87 @@ int GetObject(HGDIOBJ hObj, int sz, LPVOID logObj) return 0; } } + +/* Not in wingdi.c in earlier versions of MicroWindows */ +#if 0 +HBITMAP WINAPI +CreateCompatibleBitmap(HDC hdc, int nWidth, int nHeight) +{ + MWBITMAPOBJ * hbitmap; + int size; + int linelen; + + if(!hdc) + return NULL; + + nWidth = MWMAX(nWidth, 1); + nHeight = MWMAX(nHeight, 1); + + /* calc memory allocation size and linelen from width and height*/ + if(!GdCalcMemGCAlloc(hdc->psd, nWidth, nHeight, 0, 0, &size, &linelen)) + return NULL; + + /* allocate gdi object*/ + hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size); + if(!hbitmap) + return NULL; + hbitmap->hdr.type = OBJ_BITMAP; + hbitmap->hdr.stockobj = FALSE; + hbitmap->width = nWidth; + hbitmap->height = nHeight; + + /* create compatible with hdc*/ + hbitmap->planes = hdc->psd->planes; + hbitmap->bpp = hdc->psd->bpp; + hbitmap->linelen = linelen; + hbitmap->size = size; + + return (HBRUSH)hbitmap; +} +#endif + +/* Attempt by JACS to create arbitrary bitmap + * TODO: make use of lpData + */ + +HBITMAP WINAPI +CreateBitmap( int nWidth, int nHeight, int nPlanes, int bPP, LPCVOID lpData) +{ + MWBITMAPOBJ * hbitmap; + int size; + int linelen; + + HDC hScreenDC; + + hScreenDC = GetDC(NULL); + + nWidth = MWMAX(nWidth, 1); + nHeight = MWMAX(nHeight, 1); + + /* calc memory allocation size and linelen from width and height*/ + if(!GdCalcMemGCAlloc(hScreenDC->psd, nWidth, nHeight, nPlanes, bPP, &size, &linelen)) + { + ReleaseDC(NULL, hScreenDC); + return NULL; + } + ReleaseDC(NULL, hScreenDC); + + /* allocate gdi object*/ + hbitmap = (MWBITMAPOBJ *)GdItemAlloc(sizeof(MWBITMAPOBJ)-1+size); + if(!hbitmap) + return NULL; + hbitmap->hdr.type = OBJ_BITMAP; + hbitmap->hdr.stockobj = FALSE; + hbitmap->width = nWidth; + hbitmap->height = nHeight; + + /* create with specified parameters */ + hbitmap->planes = nPlanes; + hbitmap->bpp = bPP; + hbitmap->linelen = linelen; + hbitmap->size = size; + + /* TODO: copy data */ + + return (HBRUSH)hbitmap; +}