- Add a very bare bones implementation of IMAGE_ICON for CopyImage.

- Move the IMAGE_BITMAP stuff to a seperate function which will eventually be rewritten.

svn path=/trunk/; revision=31302
This commit is contained in:
Ged Murphy 2007-12-18 13:49:38 +00:00
parent 4bce737574
commit eeb93976b2

View file

@ -268,8 +268,15 @@ LoadCursorIconImage(
if (hIcon && 0 != (fuLoad & LR_SHARED))
{
#if 0
NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, hResInfo,
(HRSRC)NULL);
#else
ICONINFO iconInfo;
if(NtUserGetIconInfo(ResIcon, &iconInfo, NULL, NULL, NULL, FALSE))
NtUserSetCursorIconData((HICON)hIcon, hinst, NULL, &iconInfo);
#endif
}
return hIcon;
@ -561,34 +568,12 @@ LoadBitmapW(HINSTANCE hInstance, LPCWSTR lpBitmapName)
}
/*
* @unimplemented
*/
HANDLE WINAPI
CopyImage(
IN HANDLE hnd,
IN UINT type,
IN INT desiredx,
IN INT desiredy,
IN UINT flags)
{
/*
* BUGS
* Only Windows NT 4.0 supports the LR_COPYRETURNORG flag for bitmaps,
* all other versions (95/2000/XP have been tested) ignore it.
*
* NOTES
* If LR_CREATEDIBSECTION is absent, the copy will be monochrome for
* a monochrome source bitmap or if LR_MONOCHROME is present, otherwise
* the copy will have the same depth as the screen.
* The content of the image will only be copied if the bit depth of the
* original image is compatible with the bit depth of the screen, or
* if the source is a DIB section.
* The LR_MONOCHROME flag is ignored if LR_CREATEDIBSECTION is present.
*/
switch (type)
{
case IMAGE_BITMAP:
static HANDLE
CopyBmp(HANDLE hnd,
UINT type,
INT desiredx,
INT desiredy,
UINT flags)
{
HBITMAP res = NULL;
DIBSECTION ds;
@ -766,18 +751,125 @@ CopyImage(
HeapFree(GetProcessHeap(), 0, bi);
return res;
}
INT
GetIconCurBpp(PICONINFO pIconInfo)
{
PBITMAPINFO pbi;
pbi = (PBITMAPINFO)pIconInfo->hbmColor;
return pbi->bmiHeader.biBitCount;
}
static BOOL
SetCursorIconData(
HANDLE Handle,
HINSTANCE hMod,
LPWSTR lpResName,
PICONINFO pIconInfo)
{
UNICODE_STRING Res;
if (!Handle || !pIconInfo)
return FALSE;
RtlInitUnicodeString(&Res, lpResName);
return NtUserSetCursorIconData(Handle, hMod, &Res, pIconInfo);
}
/* bare bones icon copy implementation */
static HANDLE
CopyIcoCur(HANDLE hIconCur,
UINT type,
INT desiredx,
INT desiredy,
UINT flags)
{
HANDLE hNewIcon = NULL;
ICONINFO origIconInfo, newIconInfo;
SIZE origSize;
DWORD origBpp;
if (!hIconCur)
return NULL;
if (flags & LR_COPYFROMRESOURCE || flags & LR_CREATEDIBSECTION)
{
FIXME("FIXME: LR_COPYFROMRESOURCE and LR_CREATEDIBSECTION are yet not implemented for icons\n");
}
if (NtUserGetIconSize(hIconCur, 0, &origSize.cx, &origSize.cy))
{
if (desiredx == 0) desiredx = origSize.cx;
if (desiredx == 0) desiredy = origSize.cy;
if (NtUserGetIconInfo(hIconCur, &origIconInfo, NULL, NULL, &origBpp, TRUE))
{
hNewIcon = (HANDLE)NtUserCallOneParam(0, ONEPARAM_ROUTINE_CREATECURICONHANDLE);
if (hNewIcon)
{
/* the bitmaps returned from the NtUserGetIconInfo are copies of the original,
* so we can use these directly to build up our icon/cursor copy */
RtlCopyMemory(&newIconInfo, &origIconInfo, sizeof(ICONINFO));
if (!SetCursorIconData(hNewIcon, NULL, NULL, &newIconInfo))
{
if (newIconInfo.fIcon)
DestroyIcon(hNewIcon);
else
DestroyCursor(hNewIcon);
hNewIcon = NULL;
}
}
DeleteObject(origIconInfo.hbmMask);
DeleteObject(origIconInfo.hbmColor);
}
}
return hNewIcon;
}
/*
* @unimplemented
*/
HANDLE WINAPI
CopyImage(
IN HANDLE hnd,
IN UINT type,
IN INT desiredx,
IN INT desiredy,
IN UINT flags)
{
/*
* BUGS
* Only Windows NT 4.0 supports the LR_COPYRETURNORG flag for bitmaps,
* all other versions (95/2000/XP have been tested) ignore it.
*
* NOTES
* If LR_CREATEDIBSECTION is absent, the copy will be monochrome for
* a monochrome source bitmap or if LR_MONOCHROME is present, otherwise
* the copy will have the same depth as the screen.
* The content of the image will only be copied if the bit depth of the
* original image is compatible with the bit depth of the screen, or
* if the source is a DIB section.
* The LR_MONOCHROME flag is ignored if LR_CREATEDIBSECTION is present.
*/
switch (type)
{
case IMAGE_BITMAP:
return CopyBmp(hnd, type, desiredx, desiredy, flags);
case IMAGE_ICON:
{
static BOOL IconMsgDisplayed = FALSE;
/* FIXME: support loading the image as shared from an instance */
if (!IconMsgDisplayed)
{
FIXME("FIXME: CopyImage doesn't support IMAGE_ICON correctly!\n");
IconMsgDisplayed = TRUE;
}
return CopyIcon(hnd);
// return CURSORICON_ExtCopy(hnd,type, desiredx, desiredy, flags);
}
return CopyIcoCur(hnd, type, desiredx, desiredy, flags);
case IMAGE_CURSOR:
{
@ -795,6 +887,6 @@ CopyImage(
return CopyCursor(hnd);
}
}
return NULL;
}