#include "poppack.h"
-/*forward declerations... actualy in user32\windows\icon.c but usful here****/
-HICON ICON_CreateCursorFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot);
-HICON ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot);
+/* forward declarations... actually in user32\windows\icon.c but useful here */
+HICON CreateCursorIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot, BOOL fIcon);
CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width, int height, int colors);
CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir, int width, int height, int colors);
/*
* @implemented
*/
-HANDLE STDCALL
+HANDLE WINAPI
LoadImageA(HINSTANCE hinst,
LPCSTR lpszName,
UINT uType,
hIcon = CreateIconFromResourceEx((PBYTE)ResIcon,
SizeofResource(hinst, hResInfo),
Icon, 0x00030000, width, height,
- fuLoad & (LR_DEFAULTCOLOR | LR_MONOCHROME));
+ (fuLoad & (LR_DEFAULTSIZE | LR_SHARED)) | LR_DEFAULTCOLOR);
if (hIcon && 0 != (fuLoad & LR_SHARED))
{
if (fuLoad & LR_SHARED)
{
- DbgPrint("FIXME: need LR_SHARED support for loading icon images from files\n");
+ FIXME("Need LR_SHARED support for loading icon images from files\n");
}
hFile = CreateFileW(lpszName, GENERIC_READ, FILE_SHARE_READ, NULL,
else
{
ColorBits = GetDeviceCaps(hScreenDc, BITSPIXEL);
- /*
- * FIXME:
- * Remove this after proper support for alpha icons will be finished.
- */
- if (ColorBits > 8)
- ColorBits = 8;
}
/* Pick the best size. */
/* Make data point to the start of the XOR image data. */
Data = (PBYTE)SafeIconImage + HeaderSize;
- hIcon = ICON_CreateIconFromData(hScreenDc, Data, SafeIconImage, width, height, width/2, height/2);
+ hIcon = CreateCursorIconFromData(hScreenDc, Data, SafeIconImage, width, height, width/2, height/2, Icon);
RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
DeleteDC(hScreenDc);
ULONG HeaderSize;
ULONG ColorCount;
PVOID Data;
+ BOOL Hit = FALSE;
if (!(fuLoad & LR_LOADFROMFILE))
{
BitmapInfo = (LPBITMAPINFO)((ULONG_PTR)BitmapInfo + sizeof(BITMAPFILEHEADER));
}
- if (BitmapInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
+ HeaderSize = BitmapInfo->bmiHeader.biSize;
+ if (HeaderSize == sizeof(BITMAPCOREHEADER))
{
BITMAPCOREHEADER* Core = (BITMAPCOREHEADER*)BitmapInfo;
ColorCount = (Core->bcBitCount <= 8) ? (1 << Core->bcBitCount) : 0;
- HeaderSize = sizeof(BITMAPCOREHEADER) + ColorCount * sizeof(RGBTRIPLE);
+ HeaderSize += ColorCount * sizeof(RGBTRIPLE);
}
else
{
- ColorCount = BitmapInfo->bmiHeader.biClrUsed;
- if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8)
- ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount;
- HeaderSize = sizeof(BITMAPINFOHEADER) + ColorCount * sizeof(RGBQUAD);
+ if (BitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ HeaderSize += 3 * sizeof(RGBQUAD);
+ }
+ else
+ {
+ ColorCount = BitmapInfo->bmiHeader.biClrUsed;
+ if (ColorCount == 0 && BitmapInfo->bmiHeader.biBitCount <= 8)
+ ColorCount = 1 << BitmapInfo->bmiHeader.biBitCount;
+ HeaderSize += ColorCount * sizeof(RGBQUAD);
+ }
}
Data = (PVOID)((ULONG_PTR)BitmapInfo + HeaderSize);
UnmapViewOfFile(BitmapInfo);
return NULL;
}
+
+ _SEH2_TRY
+ {
memcpy(PrivateInfo, BitmapInfo, HeaderSize);
+ }
+ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Hit = TRUE;
+ }
+ _SEH2_END;
+ if (Hit)
+ {
+ ERR("We have a thread overrun, these are already freed! pi -> %d, bi -> %d\n", PrivateInfo, BitmapInfo);
+ RtlFreeHeap(GetProcessHeap(), 0, PrivateInfo);
+ if (fuLoad & LR_LOADFROMFILE)
+ UnmapViewOfFile(BitmapInfo);
+ return NULL;
+ }
+
/* FIXME: Handle color conversion and transparency. */
hScreenDc = CreateCompatibleDC(NULL);
return hBitmap;
}
-HANDLE STDCALL
+HANDLE WINAPI
LoadImageW(
IN HINSTANCE hinst,
IN LPCWSTR lpszName,
/*
* @implemented
*/
-HBITMAP STDCALL
+HBITMAP WINAPI
LoadBitmapA(HINSTANCE hInstance, LPCSTR lpBitmapName)
{
return LoadImageA(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0, 0);
/*
* @implemented
*/
-HBITMAP STDCALL
+HBITMAP WINAPI
LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName)
{
return LoadImageW(hInstance, lpBitmapName, IMAGE_BITMAP, 0, 0, 0);