Fix icon handling

svn path=/trunk/; revision=6251
This commit is contained in:
Gé van Geldorp 2003-10-06 16:25:53 +00:00
parent 307c3b1526
commit 0c98050bdc
12 changed files with 461 additions and 371 deletions

View file

@ -40,7 +40,6 @@ NtGdiCreateFontIndirect 1
NtGdiCreateHalftonePalette 1
NtGdiCreateHatchBrush 2
NtGdiCreateIC 4
NtGdiCreateIcon 9
NtGdiCreateMetaFile 1
NtGdiCreatePalette 1
NtGdiCreatePatternBrush 1

View file

@ -1098,7 +1098,7 @@ extern "C" {
#define RT_CURSORA (MAKEINTRESOURCEA(1))
#define RT_GROUP_CURSORA (MAKEINTRESOURCEA(12))
#define RT_ICONA (MAKEINTRESOURCEA(3))
#define RT_GROUP_ICONA (MAKEINTRESOURCEA(13))
#define RT_GROUP_ICONA (MAKEINTRESOURCEA(14))
#define RT_VERSIONA (MAKEINTRESOURCEA(16))
#define RT_ACCELERATORW (MAKEINTRESOURCEW(9))
@ -1113,7 +1113,7 @@ extern "C" {
#define RT_CURSORW (MAKEINTRESOURCEW(1))
#define RT_GROUP_CURSORW (MAKEINTRESOURCEW(12))
#define RT_ICONW (MAKEINTRESOURCEW(3))
#define RT_GROUP_ICONW (MAKEINTRESOURCEW(13))
#define RT_GROUP_ICONW (MAKEINTRESOURCEW(14))
#define RT_VERSIONW (MAKEINTRESOURCEW(16))
#ifndef _DISABLE_TIDENT

View file

@ -30,7 +30,6 @@
#define GDI_OBJECT_TYPE_ENHMETAFILE 0x00730000
#define GDI_OBJECT_TYPE_ENHMETADC 0x00740000
#define GDI_OBJECT_TYPE_MEMDC 0x00750000
#define GDI_OBJECT_TYPE_ICONCURSOR 0x00760000
#define GDI_OBJECT_TYPE_DCE 0x00770000
#define GDI_OBJECT_TYPE_DONTCARE 0x007f0000
/*@}*/

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: icon.c,v 1.11 2003/08/29 00:24:42 weiden Exp $
/* $Id: icon.c,v 1.12 2003/10/06 16:25:53 gvg Exp $
*
* PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/icon.c
@ -36,25 +36,194 @@
/* FUNCTIONS *****************************************************************/
STATIC WINBOOL FASTCALL
ICON_CopyBitmaps(HBITMAP *MaskTo, HBITMAP MaskFrom,
HBITMAP *ColorTo, HBITMAP *ColorFrom,
DWORD Width, DWORD Height)
{
HDC DCFrom, DCTo;
HBITMAP InitialFrom, InitialTo;
DCFrom = CreateCompatibleDC(NULL);
if (NULL == DCFrom)
{
return FALSE;
}
DCTo = CreateCompatibleDC(DCFrom);
if (NULL == DCTo)
{
DeleteDC(DCFrom);
return FALSE;
}
*MaskTo = CreateCompatibleBitmap(DCTo, Width, Height);
if (NULL == *MaskTo)
{
DeleteDC(DCTo);
DeleteDC(DCFrom);
return FALSE;
}
InitialFrom = SelectObject(DCFrom, MaskFrom);
if (NULL == InitialFrom)
{
DeleteObject(*MaskTo);
*MaskTo = NULL;
DeleteDC(DCTo);
DeleteDC(DCFrom);
return FALSE;
}
InitialTo = SelectObject(DCTo, *MaskTo);
if (NULL == InitialTo)
{
DeleteObject(*MaskTo);
*MaskTo = NULL;
DeleteDC(DCTo);
SelectObject(DCFrom, InitialFrom);
DeleteDC(DCFrom);
return FALSE;
}
if (! BitBlt(DCTo, 0, 0, Width, Height, DCFrom, 0, 0, SRCCOPY))
{
SelectObject(DCTo, InitialTo);
DeleteObject(*MaskTo);
*MaskTo = NULL;
DeleteDC(DCTo);
SelectObject(DCFrom, InitialFrom);
DeleteDC(DCFrom);
return FALSE;
}
*ColorTo = CreateCompatibleBitmap(DCTo, Width, Height);
if (NULL == *ColorTo)
{
SelectObject(DCTo, InitialTo);
DeleteObject(*MaskTo);
*MaskTo = NULL;
DeleteDC(DCTo);
SelectObject(DCFrom, InitialFrom);
DeleteDC(DCFrom);
return FALSE;
}
if (NULL == SelectObject(DCFrom, ColorFrom))
{
DeleteObject(*ColorTo);
*ColorTo = NULL;
SelectObject(DCTo, InitialTo);
DeleteObject(*MaskTo);
*MaskTo = NULL;
DeleteDC(DCTo);
SelectObject(DCFrom, InitialFrom);
DeleteDC(DCFrom);
return FALSE;
}
if (NULL == SelectObject(DCTo, *ColorTo))
{
DeleteObject(*ColorTo);
*ColorTo = NULL;
SelectObject(DCTo, InitialTo);
DeleteObject(*MaskTo);
*MaskTo = NULL;
DeleteDC(DCTo);
SelectObject(DCFrom, InitialFrom);
DeleteDC(DCFrom);
return FALSE;
}
if (! BitBlt(DCTo, 0, 0, Width, Height, DCFrom, 0, 0, SRCCOPY))
{
SelectObject(DCTo, InitialTo);
DeleteObject(*ColorTo);
*ColorTo = NULL;
DeleteObject(*MaskTo);
*MaskTo = NULL;
DeleteDC(DCTo);
SelectObject(DCFrom, InitialFrom);
DeleteDC(DCFrom);
return FALSE;
}
SelectObject(DCTo, InitialTo);
DeleteDC(DCTo);
SelectObject(DCFrom, InitialFrom);
DeleteDC(DCFrom);
return TRUE;
}
STATIC
HICON
FASTCALL
ICON_CreateIconIndirect(PICONINFO IconInfo, WINBOOL CopyBitmaps,
DWORD Width, DWORD Height)
{
PICONINFO NewIcon;
if (NULL == IconInfo)
{
DPRINT("Invalid parameter passed\n");
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
NewIcon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ICONINFO));
if (NULL == NewIcon)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
/* Set up the basic icon stuff */
NewIcon->fIcon = IconInfo->fIcon;
NewIcon->xHotspot = IconInfo->xHotspot;
NewIcon->yHotspot = IconInfo->yHotspot;
if (CopyBitmaps)
{
/* Store a copy the bitmaps */
if (! ICON_CopyBitmaps(&(NewIcon->hbmMask), IconInfo->hbmMask,
&(NewIcon->hbmColor), IconInfo->hbmColor,
Width, Height))
{
HeapFree(GetProcessHeap(), 0, NewIcon);
return NULL;
}
}
else
{
/* We take ownership of the bitmaps */
NewIcon->hbmMask = IconInfo->hbmMask;
NewIcon->hbmColor = IconInfo->hbmColor;
}
return (HICON) NewIcon;
}
HICON
ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot)
{
HANDLE hXORBitmap;
HANDLE hANDBitmap;
BITMAPINFO* bwBIH;
ICONINFO IconInfo;
HICON hIcon;
//load the XOR bitmap
hXORBitmap = CreateDIBitmap(hDC, &IconImage->icHeader, CBM_INIT,
IconInfo.fIcon = TRUE;
IconInfo.xHotspot = xHotspot;
IconInfo.yHotspot = yHotspot;
/* Load the XOR bitmap */
IconInfo.hbmColor = CreateDIBitmap(hDC, &IconImage->icHeader, CBM_INIT,
ImageData, (BITMAPINFO*)IconImage, DIB_RGB_COLORS);
//make ImageData point to the start of the AND image data
/* make ImageData point to the start of the AND image data */
ImageData = ((PBYTE)ImageData) + (((IconImage->icHeader.biWidth *
IconImage->icHeader.biBitCount + 31) & ~31) >> 3) *
(IconImage->icHeader.biHeight );
//create a BITMAPINFO header for the monocrome part of the icon
/* create a BITMAPINFO header for the monocrome part of the icon */
bwBIH = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof (BITMAPINFOHEADER)+2*sizeof(RGBQUAD));
bwBIH->bmiHeader.biBitCount = 1;
@ -80,26 +249,15 @@ ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDe
bwBIH->bmiColors[1].rgbRed = 0xff;
bwBIH->bmiColors[1].rgbReserved = 0;
//load the AND bitmap
hANDBitmap = CreateDIBitmap(hDC, &bwBIH->bmiHeader, CBM_INIT,
/* load the AND bitmap */
IconInfo.hbmMask = CreateDIBitmap(hDC, &bwBIH->bmiHeader, CBM_INIT,
ImageData, bwBIH, DIB_RGB_COLORS);
RtlFreeHeap(RtlGetProcessHeap(), 0, bwBIH);
IconInfo.fIcon = TRUE;
IconInfo.xHotspot = xHotspot;
IconInfo.yHotspot = yHotspot;
IconInfo.hbmColor = hXORBitmap;
IconInfo.hbmMask = hANDBitmap;
//Create the icon based on everything we have so far
hIcon = CreateIconIndirect(&IconInfo);
//clean up
DeleteObject(hXORBitmap);
DeleteObject(hANDBitmap);
return hIcon;
/* Create the icon based on everything we have so far */
return ICON_CreateIconIndirect(&IconInfo, FALSE, IconImage->icHeader.biWidth,
IconImage->icHeader.biHeight);
}
@ -111,13 +269,21 @@ STDCALL
CopyIcon(
HICON hIcon)
{
ICONINFO IconInfo;
NtUserGetIconInfo(hIcon, &IconInfo.fIcon,
&IconInfo.xHotspot,
&IconInfo.yHotspot,
&IconInfo.hbmMask,
&IconInfo.hbmColor);
return CreateIconIndirect(&IconInfo);
PICONINFO IconInfo = (PICONINFO) hIcon;
BITMAP BitmapInfo;
if (NULL == IconInfo)
{
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
if (0 == GetObjectW(IconInfo->hbmColor, sizeof(BITMAP), &BitmapInfo))
{
return NULL;
}
return ICON_CreateIconIndirect(IconInfo, TRUE, BitmapInfo.bmWidth, BitmapInfo.bmHeight);
}
@ -132,19 +298,27 @@ CreateIcon(
int nHeight,
BYTE cPlanes,
BYTE cBitsPixel,
CONST BYTE *lpbANDbits,
CONST BYTE *lpbXORbits)
CONST BYTE *ANDbits,
CONST BYTE *XORbits)
{
DPRINT("hInstance not used in this implementation\n");
return NtGdiCreateIcon(TRUE,
nWidth,
nHeight,
cPlanes,
cBitsPixel,
nWidth/2,
nHeight/2,
lpbANDbits,
lpbXORbits);
ICONINFO IconInfo;
IconInfo.fIcon = TRUE;
IconInfo.xHotspot = nWidth / 2;
IconInfo.yHotspot = nHeight / 2;
IconInfo.hbmMask = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPixel, ANDbits);
if (NULL == IconInfo.hbmMask)
{
return NULL;
}
IconInfo.hbmColor = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPixel, XORbits);
if (NULL == IconInfo.hbmColor)
{
DeleteObject(IconInfo.hbmMask);
return NULL;
}
return ICON_CreateIconIndirect(&IconInfo, FALSE, nWidth, nHeight);
}
@ -188,7 +362,7 @@ CreateIconFromResourceEx(
DPRINT("dwVersion, cxDesired, cyDesired are all ignored in this implementation!\n");
if (!fIcon)
if (! fIcon)
{
wXHotspot = (WORD)*pbIconBits;
pbIconBits+=2;
@ -202,11 +376,11 @@ CreateIconFromResourceEx(
wYHotspot = cyDesired / 2;
}
//get an safe copy of the icon data
/* get an safe copy of the icon data */
SafeIconImage = RtlAllocateHeap(RtlGetProcessHeap(), 0, cbIconBits);
memcpy(SafeIconImage, pbIconBits, cbIconBits);
//take into acount the origonal hight was for both the AND and XOR images
/* take into acount the origonal hight was for both the AND and XOR images */
SafeIconImage->icHeader.biHeight /= 2;
if (SafeIconImage->icHeader.biSize == sizeof(BITMAPCOREHEADER))
@ -222,11 +396,11 @@ CreateIconFromResourceEx(
HeaderSize = sizeof(BITMAPINFOHEADER) + ColourCount * sizeof(RGBQUAD);
}
//make data point to the start of the XOR image data
/* make data point to the start of the XOR image data */
Data = (PBYTE)SafeIconImage + HeaderSize;
//get a handle to the screen dc, the icon we create is going to be compatable with this
hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL);
/* get a handle to the screen dc, the icon we create is going to be compatable with this */
hScreenDc = CreateCompatibleDC(NULL);
if (hScreenDc == NULL)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage);
@ -235,6 +409,7 @@ CreateIconFromResourceEx(
hIcon = ICON_CreateIconFromData(hScreenDc, Data, SafeIconImage, cxDesired, cyDesired, wXHotspot, wYHotspot);
RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage);
return hIcon;
}
@ -244,24 +419,33 @@ CreateIconFromResourceEx(
*/
HICON
STDCALL
CreateIconIndirect(
PICONINFO piconinfo)
CreateIconIndirect(PICONINFO IconInfo)
{
BITMAP bmMask;
BITMAP bmColor;
BITMAP ColorBitmap;
BITMAP MaskBitmap;
NtGdiGetObject( piconinfo->hbmMask, sizeof(BITMAP), &bmMask );
NtGdiGetObject( piconinfo->hbmColor, sizeof(BITMAP), &bmColor );
if (NULL == IconInfo)
{
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
return NtGdiCreateIcon(piconinfo->fIcon,
bmColor.bmWidth,
bmColor.bmHeight,
bmColor.bmPlanes,
bmColor.bmBitsPixel,
piconinfo->xHotspot,
piconinfo->yHotspot,
bmMask.bmBits,
bmColor.bmBits);
if (0 == GetObjectW(IconInfo->hbmColor, sizeof(BITMAP), &ColorBitmap))
{
return NULL;
}
if (0 == GetObjectW(IconInfo->hbmMask, sizeof(BITMAP), &MaskBitmap))
{
return NULL;
}
if (ColorBitmap.bmWidth != MaskBitmap.bmWidth ||
ColorBitmap.bmHeight != MaskBitmap.bmWidth)
{
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
return ICON_CreateIconIndirect(IconInfo, TRUE, ColorBitmap.bmWidth, ColorBitmap.bmHeight);
}
@ -273,7 +457,26 @@ STDCALL
DestroyIcon(
HICON hIcon)
{
return NtGdiDeleteObject(hIcon);
PICONINFO IconInfo = (PICONINFO) hIcon;
if (NULL == IconInfo)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (NULL != IconInfo->hbmMask)
{
DeleteObject(IconInfo->hbmMask);
}
if (NULL != IconInfo->hbmColor)
{
DeleteObject(IconInfo->hbmColor);
}
HeapFree(GetProcessHeap(), 0, IconInfo);
return TRUE;
}
@ -288,7 +491,7 @@ DrawIcon(
int Y,
HICON hIcon)
{
return DrawIconEx (hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE);
return DrawIconEx(hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE);
}
/* Ported from WINE20030408 */
@ -308,50 +511,48 @@ DrawIconEx(
HBRUSH hbrFlickerFreeDraw,
UINT diFlags)
{
ICONINFO IconInfo;
BITMAP XORBitmap;
PICONINFO IconInfo = (PICONINFO) hIcon;
BITMAP Bitmap;
HDC hDC_off = 0, hMemDC;
BOOL result = FALSE, DoOffscreen;
HBITMAP hB_off = 0, hOld = 0;
if (!NtUserGetIconInfo(hIcon, &IconInfo.fIcon,
&IconInfo.xHotspot,
&IconInfo.yHotspot,
&IconInfo.hbmMask,
&IconInfo.hbmColor))
if (NULL == IconInfo)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
NtGdiGetObject(IconInfo.hbmColor, sizeof(BITMAP), &XORBitmap);
GetObjectW(IconInfo->hbmColor, sizeof(BITMAP), &Bitmap);
DPRINT("(hdc=%p,pos=%d.%d,hicon=%p,extend=%d.%d,istep=%d,br=%p,flags=0x%08x)\n",
hdc,xLeft,yTop,hIcon,cxWidth,cyWidth,istepIfAniCur,hbrFlickerFreeDraw,diFlags );
hMemDC = CreateCompatibleDC (hdc);
hMemDC = CreateCompatibleDC(hdc);
if (diFlags & DI_COMPAT)
{
DPRINT("Ignoring flag DI_COMPAT\n");
}
if (!diFlags)
{
diFlags = DI_NORMAL;
}
// Calculate the size of the destination image.
/* Calculate the size of the destination image. */
if (cxWidth == 0)
{
if (diFlags & DI_DEFAULTSIZE)
cxWidth = GetSystemMetrics (SM_CXICON);
else
cxWidth = XORBitmap.bmWidth;
cxWidth = (diFlags & DI_DEFAULTSIZE ? GetSystemMetrics (SM_CXICON)
: Bitmap.bmWidth);
}
if (cyWidth == 0)
{
if (diFlags & DI_DEFAULTSIZE)
cyWidth = GetSystemMetrics (SM_CYICON);
else
cyWidth = XORBitmap.bmHeight;
cyWidth = (diFlags & DI_DEFAULTSIZE ? GetSystemMetrics (SM_CYICON)
: Bitmap.bmHeight);
}
DoOffscreen = (GetObjectType( hbrFlickerFreeDraw ) == OBJ_BRUSH);
DoOffscreen = (NULL != hbrFlickerFreeDraw
&& OBJ_BRUSH == GetObjectType(hbrFlickerFreeDraw));
if (DoOffscreen)
{
@ -362,66 +563,70 @@ DrawIconEx(
r.right = cxWidth;
r.bottom = cxWidth;
DbgPrint("in DrawIconEx calling: CreateCompatibleDC\n");
DPRINT("in DrawIconEx calling: CreateCompatibleDC\n");
hDC_off = CreateCompatibleDC(hdc);
DbgPrint("in DrawIconEx calling: CreateCompatibleBitmap\n");
DPRINT("in DrawIconEx calling: CreateCompatibleBitmap\n");
hB_off = CreateCompatibleBitmap(hdc, cxWidth, cyWidth);
if (hDC_off && hB_off)
{
DbgPrint("in DrawIconEx calling: SelectObject\n");
DPRINT("in DrawIconEx calling: SelectObject\n");
hOld = SelectObject(hDC_off, hB_off);
DbgPrint("in DrawIconEx calling: FillRect\n");
DPRINT("in DrawIconEx calling: FillRect\n");
FillRect(hDC_off, &r, hbrFlickerFreeDraw);
}
}
if (hMemDC && (!DoOffscreen || (hDC_off && hB_off)))
if (hMemDC && (! DoOffscreen || (hDC_off && hB_off)))
{
COLORREF oldFg, oldBg;
INT nStretchMode;
nStretchMode = SetStretchBltMode (hdc, STRETCH_DELETESCANS);
nStretchMode = SetStretchBltMode(hdc, STRETCH_DELETESCANS);
oldFg = SetTextColor(hdc, RGB(0, 0, 0));
oldBg = SetBkColor(hdc, RGB(255, 255, 255));
oldFg = SetTextColor( hdc, RGB(0,0,0) );
oldBg = SetBkColor( hdc, RGB(255,255,255) );
if (IconInfo.hbmColor && IconInfo.hbmMask)
if (IconInfo->hbmColor && IconInfo->hbmMask)
{
HBITMAP hBitTemp = SelectObject( hMemDC, IconInfo.hbmMask );
HBITMAP hBitTemp = SelectObject(hMemDC, IconInfo->hbmMask);
if (diFlags & DI_MASK)
{
if (DoOffscreen)
{
StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCAND);
else
StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCAND);
hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight,
SRCAND);
}
SelectObject( hMemDC, IconInfo.hbmColor );
else
{
StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth,
hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight,
SRCAND);
}
}
SelectObject(hMemDC, IconInfo->hbmColor);
if (diFlags & DI_IMAGE)
{
if (DoOffscreen)
{
StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCPAINT);
else
StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth,
hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCPAINT);
hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight,
SRCINVERT);
}
SelectObject( hMemDC, hBitTemp );
else
{
StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth,
hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight,
SRCINVERT);
}
}
SelectObject(hMemDC, hBitTemp);
result = TRUE;
}
SetTextColor( hdc, oldFg );
SetBkColor( hdc, oldBg );
if (IconInfo.hbmColor)
DeleteObject( IconInfo.hbmColor );
if (IconInfo.hbmMask)
DeleteObject( IconInfo.hbmMask );
SetStretchBltMode (hdc, nStretchMode);
if (DoOffscreen)
@ -432,11 +637,18 @@ DrawIconEx(
}
if (hMemDC)
{
DeleteDC( hMemDC );
}
if (hDC_off)
{
DeleteDC(hDC_off);
}
if (hB_off)
{
DeleteObject(hB_off);
}
return result;
}
@ -448,26 +660,40 @@ WINBOOL
STDCALL
GetIconInfo(
HICON hIcon,
PICONINFO piconinfo)
PICONINFO IconInfo)
{
ICONINFO IconInfo;
WINBOOL res;
PICONINFO IconData = (PICONINFO) hIcon;
BITMAP BitmapInfo;
if(!piconinfo)
if (NULL == IconData)
{
SetLastError(ERROR_NOACCESS);
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if (NULL == IconInfo)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
res = NtUserGetIconInfo(hIcon,
&piconinfo->fIcon,
&piconinfo->xHotspot,
&piconinfo->yHotspot,
&piconinfo->hbmMask,
&piconinfo->hbmColor);
if(res)
RtlCopyMemory(piconinfo, &IconInfo, sizeof(ICONINFO));
return res;
/* Copy basic info */
IconInfo->fIcon = IconData->fIcon;
IconInfo->xHotspot = IconData->xHotspot;
IconInfo->yHotspot = IconData->yHotspot;
/* Copy the bitmaps */
if (0 == GetObjectW(IconData->hbmColor, sizeof(BITMAP), &BitmapInfo))
{
return FALSE;
}
if (! ICON_CopyBitmaps(&(IconInfo->hbmMask), IconData->hbmMask,
&(IconInfo->hbmColor), IconData->hbmColor,
BitmapInfo.bmWidth, BitmapInfo.bmHeight))
{
return FALSE;
}
return TRUE;
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dib16bpp.c,v 1.8 2003/08/31 07:56:24 gvg Exp $ */
/* $Id: dib16bpp.c,v 1.9 2003/10/06 16:25:53 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
@ -305,7 +305,7 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Source = 0;
for (k = 0; k < 2; k++)
{
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 16));
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 16));
}
}
if (UsesPattern)
@ -323,7 +323,7 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
{
if (UsesSource)
{
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
}
if (UsesPattern)
{
@ -335,6 +335,7 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Dest >>= 16;
}
}
sy++;
}
}
return TRUE;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dib1bpp.c,v 1.10 2003/08/22 08:03:51 gvg Exp $ */
/* $Id: dib1bpp.c,v 1.11 2003/10/06 16:25:53 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -295,7 +295,7 @@ DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Source = 0;
for (k = 0; k < 32; k++)
{
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << k);
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << k);
}
}
if (UsesPattern)
@ -312,7 +312,7 @@ DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
{
if (UsesSource)
{
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
}
if (UsesPattern)
{
@ -323,6 +323,7 @@ DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Dest >>= 1;
}
}
sy++;
}
}
return TRUE;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dib24bpp.c,v 1.13 2003/08/12 21:55:47 gvg Exp $ */
/* $Id: dib24bpp.c,v 1.14 2003/10/06 16:25:53 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
@ -253,7 +253,7 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4)
{
LONG i, j, k, sx, sy;
LONG i, j, sx, sy;
ULONG Dest, Source, Pattern;
PULONG DestBits;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
@ -276,7 +276,7 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Dest = *DestBits & 0x00ffffff;
if (UsesSource)
{
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) & 0x00ffffff;
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation) & 0x00ffffff;
}
if (UsesPattern)
{
@ -287,6 +287,7 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
*(PBYTE)DestBits = Dest & 0xff;
*(PWORD)(DestBits + 1) = Dest >> 8;
}
sy++;
}
}
return TRUE;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dib32bpp.c,v 1.5 2003/08/13 20:24:04 chorns Exp $ */
/* $Id: dib32bpp.c,v 1.6 2003/10/06 16:25:53 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
@ -247,7 +247,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
PBRUSHOBJ Brush, PPOINTL BrushOrigin,
XLATEOBJ *ColorTranslation, ULONG Rop4)
{
LONG i, j, k, sx, sy;
LONG i, j, sx, sy;
ULONG Dest, Source, Pattern;
PULONG DestBits;
BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000);
@ -270,7 +270,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Dest = *DestBits;
if (UsesSource)
{
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation);
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
}
if (UsesPattern)
{
@ -279,6 +279,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
}
*DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern);
}
sy++;
}
}
return TRUE;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dib4bpp.c,v 1.18 2003/08/13 20:24:04 chorns Exp $ */
/* $Id: dib4bpp.c,v 1.19 2003/10/06 16:25:53 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
@ -285,7 +285,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Source = 0;
for (k = 0; k < 8; k++)
{
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 4));
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 4));
}
}
if (UsesPattern)
@ -302,7 +302,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
{
if (UsesSource)
{
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
}
if (UsesPattern)
{
@ -313,6 +313,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Dest >>= 4;
}
}
sy++;
}
}
return TRUE;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dib8bpp.c,v 1.6 2003/08/31 07:56:24 gvg Exp $ */
/* $Id: dib8bpp.c,v 1.7 2003/10/06 16:25:53 gvg Exp $ */
#undef WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdlib.h>
@ -301,7 +301,7 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Source = 0;
for (k = 0; k < 4; k++)
{
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 8));
Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 8));
}
}
if (UsesPattern)
@ -321,7 +321,7 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
{
if (UsesSource)
{
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation);
Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation);
}
if (UsesPattern)
{
@ -335,6 +335,7 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf,
Dest >>= 8;
}
}
sy++;
}
}
return TRUE;

View file

@ -15,105 +15,8 @@
#define NDEBUG
#include <win32k/debug1.h>
BOOL FASTCALL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor )
{
ASSERT( pIconCursor );
if( pIconCursor->ANDBitmap.bmBits )
ExFreePool(pIconCursor->ANDBitmap.bmBits);
if( pIconCursor->XORBitmap.bmBits )
ExFreePool(pIconCursor->XORBitmap.bmBits);
return TRUE;
}
/*
* @implemented
*/
HICON
STDCALL
NtGdiCreateIcon(BOOL fIcon,
INT Width,
INT Height,
UINT Planes,
UINT BitsPerPel,
DWORD xHotspot,
DWORD yHotspot,
CONST VOID *ANDBits,
CONST VOID *XORBits)
{
PICONCURSOROBJ icon;
HICON hIcon;
Planes = (BYTE) Planes;
BitsPerPel = (BYTE) BitsPerPel;
/* Check parameters */
if (!Height || !Width)
{
return 0;
}
if (Planes != 1)
{
UNIMPLEMENTED;
return 0;
}
/* Create the ICONCURSOROBJ object*/
hIcon = ICONCURSOROBJ_AllocIconCursor ();
if (!hIcon)
{
DPRINT("NtGdiCreateIcon: ICONCURSOROBJ_AllocIconCursor(hIcon == 0x%x) returned 0\n", hIcon);
return 0;
}
icon = ICONCURSOROBJ_LockIconCursor(hIcon);
/* Set up the basic icon stuff */
icon->fIcon = TRUE;
icon->xHotspot = xHotspot;
icon->yHotspot = yHotspot;
/* Setup the icon mask and icon color bitmaps */
icon->ANDBitmap.bmType = 0;
icon->ANDBitmap.bmWidth = Width;
icon->ANDBitmap.bmHeight = Height;
icon->ANDBitmap.bmPlanes = 1;
icon->ANDBitmap.bmBitsPixel = 1;
icon->ANDBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, 1);
icon->ANDBitmap.bmBits = NULL;
icon->XORBitmap.bmType = 0;
icon->XORBitmap.bmWidth = Width;
icon->XORBitmap.bmHeight = Height;
icon->XORBitmap.bmPlanes = Planes;
icon->XORBitmap.bmBitsPixel = BitsPerPel;
icon->XORBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, BitsPerPel);
icon->XORBitmap.bmBits = NULL;
/* allocate memory for the icon mask and icon color bitmaps,
this will be freed in IconCursor_InternalDelete */
icon->ANDBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->ANDBitmap.bmWidthBytes);
icon->XORBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->XORBitmap.bmWidthBytes);
/* set the bits of the mask and color bitmaps */
if (ANDBits)
{
memcpy(icon->ANDBitmap.bmBits, (PVOID)ANDBits, Height * icon->ANDBitmap.bmWidthBytes);
}
if (XORBits)
{
memcpy(icon->XORBitmap.bmBits, (PVOID)XORBits, Height * icon->XORBitmap.bmWidthBytes);
}
ICONCURSOROBJ_UnlockIconCursor( hIcon );
return hIcon;
}
/*
* @implemented
* @unimplemented
*/
DWORD
STDCALL
@ -125,43 +28,14 @@ NtUserGetIconInfo(
HBITMAP *hbmMask,
HBITMAP *hbmColor)
{
PICONCURSOROBJ icon;
UNIMPLEMENTED
icon = ICONCURSOROBJ_LockIconCursor(hIcon);
if (!icon)
{
DPRINT1("NtUserGetIconInfo: ICONCURSOROBJ_LockIconCursor(hIcon == 0x%x) returned 0\n", hIcon);
return FALSE;
}
*fIcon = icon->fIcon ;
*xHotspot = icon->xHotspot;
*yHotspot = icon->yHotspot;
*hbmMask = NtGdiCreateBitmap(icon->ANDBitmap.bmWidth,
icon->ANDBitmap.bmHeight,
icon->ANDBitmap.bmPlanes,
icon->ANDBitmap.bmBitsPixel,
icon->ANDBitmap.bmBits);
*hbmColor = NtGdiCreateBitmap(icon->XORBitmap.bmWidth,
icon->XORBitmap.bmHeight,
icon->XORBitmap.bmPlanes,
icon->XORBitmap.bmBitsPixel,
icon->XORBitmap.bmBits);
ICONCURSOROBJ_UnlockIconCursor(hIcon);
if (!*hbmMask || !*hbmColor)
return FALSE;
return TRUE;
}
/*
* @implemented
* @unimplemented
*/
BOOL
STDCALL
@ -171,26 +45,9 @@ NtUserGetIconSize(
LONG *Width,
LONG *Height)
{
PICONCURSOROBJ icon;
UNIMPLEMENTED
if (!hIcon || !Width || !Width)
return FALSE;
icon = ICONCURSOROBJ_LockIconCursor(hIcon);
if (!icon)
{
DPRINT1("NtUserGetIconInfo: ICONCURSOROBJ_LockIconCursor() returned 0\n");
return FALSE;
}
if(fIcon) *fIcon = icon->fIcon;
*Width = icon->ANDBitmap.bmWidth;
*Width = icon->ANDBitmap.bmHeight;
ICONCURSOROBJ_UnlockIconCursor(hIcon);
return TRUE;
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dc.c,v 1.86 2003/10/04 20:26:43 gvg Exp $
/* $Id: dc.c,v 1.87 2003/10/06 16:25:53 gvg Exp $
*
* DC.C - Device context functions
*
@ -132,6 +132,7 @@ NtGdiCreateCompatableDC(HDC hDC)
HDC hNewDC;
HRGN hVisRgn;
BITMAPOBJ *pb;
PSURFGDI SurfGDI;
if (hDC == NULL)
{
@ -166,6 +167,8 @@ NtGdiCreateCompatableDC(HDC hDC)
sizeof(NewDC->FillPatternSurfaces));
NewDC->GDIInfo = &PrimarySurface.GDIInfo;
NewDC->DevInfo = &PrimarySurface.DevInfo;
SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) PrimarySurface.Handle);
NewDC->w.bitsPerPixel = SurfGDI->BitsPerPixel;
}
else
{
@ -176,6 +179,7 @@ NtGdiCreateCompatableDC(HDC hDC)
sizeof OrigDC->FillPatternSurfaces);
NewDC->GDIInfo = OrigDC->GDIInfo;
NewDC->DevInfo = OrigDC->DevInfo;
NewDC->w.bitsPerPixel = OrigDC->w.bitsPerPixel;
}
/* DriverName is copied in the AllocDC routine */
@ -197,7 +201,7 @@ NtGdiCreateCompatableDC(HDC hDC)
}
/* Create default bitmap */
if (!(hBitmap = NtGdiCreateBitmap( 1, 1, 1, 1, NULL )))
if (!(hBitmap = NtGdiCreateBitmap( 1, 1, 1, NewDC->w.bitsPerPixel, NULL )))
{
DC_UnlockDc( hDC );
DC_UnlockDc( hNewDC );
@ -205,7 +209,6 @@ NtGdiCreateCompatableDC(HDC hDC)
return NULL;
}
NewDC->w.flags = DC_MEMORY;
NewDC->w.bitsPerPixel = 1;
NewDC->w.hBitmap = hBitmap;
NewDC->w.hFirstBitmap = hBitmap;
pb = BITMAPOBJ_LockBitmap(hBitmap);