Mercurial > dwindows
changeset 242:36013ddd3f5b
Fixes for Windows code.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 19 Feb 2003 06:23:59 +0000 |
parents | 00d2b1bcf036 |
children | 3c1e39905f2f |
files | win/dw.c |
diffstat | 1 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/win/dw.c Wed Feb 19 06:00:54 2003 +0000 +++ b/win/dw.c Wed Feb 19 06:23:59 2003 +0000 @@ -6698,10 +6698,15 @@ HPIXMAP pixmap; BITMAP bm; HDC hdc; - char *file = alloca(strlen(filename) + 5); + SIZE sz; + char *file = malloc(strlen(filename) + 5); if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap)))) + { + if(file) + free(file); return NULL; + } strcpy(file, filename); @@ -6713,22 +6718,36 @@ if(access(file, 04) != 0) { free(pixmap); + free(file); return NULL; } } - dc = GetDC(handle); - - pixmap->width = width; pixmap->height = height; + hdc = GetDC(handle); pixmap->handle = handle; pixmap->hbm = (HBITMAP)LoadImage(NULL, file, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + + if(!pixmap->hbm) + { + free(file); + free(pixmap); + ReleaseDC(handle, hdc); + return NULL; + } + pixmap->hdc = CreateCompatibleDC(hdc); + GetBitmapDimensionEx(pixmap->hbm, &sz); + + pixmap->width = sz.cx; pixmap->height = sz.cy; + SelectObject(pixmap->hdc, pixmap->hbm); ReleaseDC(handle, hdc); + free(file); + return pixmap; }