- Restructure and simplify CreateCursorFromData
- Call CreateIconFromResourceEx properly allowing it to create colored icons (although it doesn't care about that yet)
- Fix some comment typos
win32k:
- Don't just copy the pointer to an XLATEOBJ, copy instead. The caller will free it, EngSetPointerShape will do so too (causing either double-frees or memory write errors)

svn path=/trunk/; revision=42291
This commit is contained in:
Gregor Schneider 2009-07-29 18:28:11 +00:00
parent 76ec995125
commit 2f0c6dbb98
3 changed files with 21 additions and 24 deletions

View file

@ -56,7 +56,7 @@ typedef struct
#include "poppack.h"
/* forward declerations... actually in user32\windows\icon.c but usful here */
/* forward declarations... actually in user32\windows\icon.c but useful here */
HICON ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot);
CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width, int height, int colors);
CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir, int width, int height, int colors);
@ -265,7 +265,7 @@ LoadCursorIconImage(
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))
{

View file

@ -98,13 +98,25 @@ ICON_CreateCursorFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cx
BITMAPINFO *bwBIH = (BITMAPINFO *)BitmapInfoBuffer;
BITMAPINFO *orgBIH = (BITMAPINFO *)IconImage;
ICONINFO IconInfo;
PVOID XORImageData = ImageData;
IconInfo.fIcon = FALSE;
IconInfo.xHotspot = xHotspot;
IconInfo.yHotspot = yHotspot;
/* Create a BITMAPINFO header for the monochrome part of the icon */
/* Handle the color part of the cursor */
if (IconImage->icHeader.biBitCount == 1)
{
IconInfo.hbmColor = (HBITMAP)0;
}
else
{
FIXME("loading %d bpp color cursor\n", IconImage->icHeader.biBitCount);
IconInfo.hbmColor = CreateDIBitmap(hDC, &IconImage->icHeader, CBM_INIT,
ImageData, (BITMAPINFO*)IconImage,
DIB_RGB_COLORS);
}
/* Create a BITMAPINFO header for the monochrome part of the cursor */
bwBIH->bmiHeader.biBitCount = 1;
bwBIH->bmiHeader.biWidth = IconImage->icHeader.biWidth;
bwBIH->bmiHeader.biHeight = IconImage->icHeader.biHeight;
@ -127,29 +139,13 @@ ICON_CreateCursorFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cx
bwBIH->bmiColors[1].rgbRed = 0xff;
bwBIH->bmiColors[1].rgbReserved = 0;
/* Load the AND bitmap */
/* Load the monochrome bitmap */
IconInfo.hbmMask = CreateDIBitmap(hDC, &bwBIH->bmiHeader, 0,
XORImageData, bwBIH, DIB_RGB_COLORS);
ImageData, bwBIH, DIB_RGB_COLORS);
if (IconInfo.hbmMask)
{
SetDIBits(hDC, IconInfo.hbmMask, 0, IconImage->icHeader.biHeight,
XORImageData, orgBIH, DIB_RGB_COLORS);
}
if (IconImage->icHeader.biBitCount == 1)
{
IconInfo.hbmColor = (HBITMAP)0;
}
else
{
/* Create the color part of the icon */
IconInfo.hbmColor = CreateDIBitmap(hDC, &IconImage->icHeader, 0,
XORImageData, orgBIH, DIB_RGB_COLORS);
if (IconInfo.hbmColor)
{
SetDIBits(hDC, IconInfo.hbmColor, 0, IconImage->icHeader.biHeight,
XORImageData, orgBIH, DIB_RGB_COLORS);
}
ImageData, orgBIH, DIB_RGB_COLORS);
}
/* Create the icon based on everything we have so far */

View file

@ -426,7 +426,8 @@ EngSetPointerShape(
}
else
{
pgp->XlateObject = pxlo;
pgp->XlateObject = EngAllocMem(0, sizeof(XLATEOBJ), TAG_XLATEOBJ);
memcpy(pgp->XlateObject, pxlo, sizeof(XLATEOBJ));
}
/* Create surface for saving the pixels under the cursor. */