mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 12:23:25 +00:00
[FORMATTING]
- fix indentation - move an internal function out of public functions area - Use small file header - No code change svn path=/trunk/; revision=40417
This commit is contained in:
@@ -1,23 +1,9 @@
|
||||
/*
|
||||
* ReactOS Win32 Subsystem
|
||||
*
|
||||
* Copyright (C) 1998 - 2004 ReactOS Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id$
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS win32 subsystem
|
||||
* PURPOSE: Functions for brushes
|
||||
* FILE: subsystem/win32/win32k/objects/brush.c
|
||||
* PROGRAMER:
|
||||
*/
|
||||
|
||||
#include <w32k.h>
|
||||
@@ -27,44 +13,46 @@
|
||||
|
||||
static const USHORT HatchBrushes[NB_HATCH_STYLES][8] =
|
||||
{
|
||||
{0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00}, /* HS_HORIZONTAL */
|
||||
{0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, /* HS_VERTICAL */
|
||||
{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, /* HS_FDIAGONAL */
|
||||
{0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, /* HS_BDIAGONAL */
|
||||
{0x08, 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08}, /* HS_CROSS */
|
||||
{0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81} /* HS_DIAGCROSS */
|
||||
{0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00}, /* HS_HORIZONTAL */
|
||||
{0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, /* HS_VERTICAL */
|
||||
{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, /* HS_FDIAGONAL */
|
||||
{0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, /* HS_BDIAGONAL */
|
||||
{0x08, 0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08}, /* HS_CROSS */
|
||||
{0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81} /* HS_DIAGCROSS */
|
||||
};
|
||||
|
||||
BOOL INTERNAL_CALL
|
||||
BOOL
|
||||
INTERNAL_CALL
|
||||
BRUSH_Cleanup(PVOID ObjectBody)
|
||||
{
|
||||
PBRUSH pbrush = (PBRUSH)ObjectBody;
|
||||
if(pbrush->flAttrs & (GDIBRUSH_IS_HATCH | GDIBRUSH_IS_BITMAP))
|
||||
{
|
||||
ASSERT(pbrush->hbmPattern);
|
||||
GDIOBJ_SetOwnership(pbrush->hbmPattern, PsGetCurrentProcess());
|
||||
GreDeleteObject(pbrush->hbmPattern);
|
||||
}
|
||||
PBRUSH pbrush = (PBRUSH)ObjectBody;
|
||||
if (pbrush->flAttrs & (GDIBRUSH_IS_HATCH | GDIBRUSH_IS_BITMAP))
|
||||
{
|
||||
ASSERT(pbrush->hbmPattern);
|
||||
GDIOBJ_SetOwnership(pbrush->hbmPattern, PsGetCurrentProcess());
|
||||
GreDeleteObject(pbrush->hbmPattern);
|
||||
}
|
||||
|
||||
/* Free the kmode styles array of EXTPENS */
|
||||
if (pbrush->pStyle)
|
||||
{
|
||||
ExFreePool(pbrush->pStyle);
|
||||
}
|
||||
/* Free the kmode styles array of EXTPENS */
|
||||
if (pbrush->pStyle)
|
||||
{
|
||||
ExFreePool(pbrush->pStyle);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
INT FASTCALL
|
||||
BRUSH_GetObject (PBRUSH pbrush, INT Count, LPLOGBRUSH Buffer)
|
||||
INT
|
||||
FASTCALL
|
||||
BRUSH_GetObject(PBRUSH pbrush, INT Count, LPLOGBRUSH Buffer)
|
||||
{
|
||||
if( Buffer == NULL ) return sizeof(LOGBRUSH);
|
||||
if (Count == 0) return 0;
|
||||
if (Buffer == NULL) return sizeof(LOGBRUSH);
|
||||
if (Count == 0) return 0;
|
||||
|
||||
/* Set colour */
|
||||
/* Set colour */
|
||||
Buffer->lbColor = pbrush->BrushAttr.lbColor;
|
||||
|
||||
/* set Hatch */
|
||||
/* Set Hatch */
|
||||
if ((pbrush->flAttrs & GDIBRUSH_IS_HATCH)!=0)
|
||||
{
|
||||
/* FIXME : this is not the right value */
|
||||
@@ -135,448 +123,453 @@ BRUSH_GetObject (PBRUSH pbrush, INT Count, LPLOGBRUSH Buffer)
|
||||
* @return
|
||||
* TRUE if the input values together form a valid image, FALSE otherwise.
|
||||
*/
|
||||
|
||||
BOOL APIENTRY
|
||||
BOOL
|
||||
APIENTRY
|
||||
CalculateColorTableSize(
|
||||
CONST BITMAPINFOHEADER *BitmapInfoHeader,
|
||||
UINT *ColorSpec,
|
||||
UINT *ColorTableSize)
|
||||
CONST BITMAPINFOHEADER *BitmapInfoHeader,
|
||||
UINT *ColorSpec,
|
||||
UINT *ColorTableSize)
|
||||
{
|
||||
WORD BitCount;
|
||||
DWORD ClrUsed;
|
||||
DWORD Compression;
|
||||
WORD BitCount;
|
||||
DWORD ClrUsed;
|
||||
DWORD Compression;
|
||||
|
||||
/*
|
||||
* At first get some basic parameters from the passed BitmapInfoHeader
|
||||
* structure. It can have one of the following formats:
|
||||
* - BITMAPCOREHEADER (the oldest one with totally different layout
|
||||
* from the others)
|
||||
* - BITMAPINFOHEADER (the standard and most common header)
|
||||
* - BITMAPV4HEADER (extension of BITMAPINFOHEADER)
|
||||
* - BITMAPV5HEADER (extension of BITMAPV4HEADER)
|
||||
*/
|
||||
/*
|
||||
* At first get some basic parameters from the passed BitmapInfoHeader
|
||||
* structure. It can have one of the following formats:
|
||||
* - BITMAPCOREHEADER (the oldest one with totally different layout
|
||||
* from the others)
|
||||
* - BITMAPINFOHEADER (the standard and most common header)
|
||||
* - BITMAPV4HEADER (extension of BITMAPINFOHEADER)
|
||||
* - BITMAPV5HEADER (extension of BITMAPV4HEADER)
|
||||
*/
|
||||
if (BitmapInfoHeader->biSize == sizeof(BITMAPCOREHEADER))
|
||||
{
|
||||
BitCount = ((LPBITMAPCOREHEADER)BitmapInfoHeader)->bcBitCount;
|
||||
ClrUsed = 0;
|
||||
Compression = BI_RGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
BitCount = BitmapInfoHeader->biBitCount;
|
||||
ClrUsed = BitmapInfoHeader->biClrUsed;
|
||||
Compression = BitmapInfoHeader->biCompression;
|
||||
}
|
||||
|
||||
if (BitmapInfoHeader->biSize == sizeof(BITMAPCOREHEADER))
|
||||
{
|
||||
BitCount = ((LPBITMAPCOREHEADER)BitmapInfoHeader)->bcBitCount;
|
||||
ClrUsed = 0;
|
||||
Compression = BI_RGB;
|
||||
}
|
||||
else
|
||||
{
|
||||
BitCount = BitmapInfoHeader->biBitCount;
|
||||
ClrUsed = BitmapInfoHeader->biClrUsed;
|
||||
Compression = BitmapInfoHeader->biCompression;
|
||||
}
|
||||
switch (Compression)
|
||||
{
|
||||
case BI_BITFIELDS:
|
||||
if (*ColorSpec == DIB_PAL_COLORS)
|
||||
*ColorSpec = DIB_RGB_COLORS;
|
||||
|
||||
switch (Compression)
|
||||
{
|
||||
case BI_BITFIELDS:
|
||||
if (*ColorSpec == DIB_PAL_COLORS)
|
||||
*ColorSpec = DIB_RGB_COLORS;
|
||||
if (BitCount != 16 && BitCount != 32)
|
||||
return FALSE;
|
||||
|
||||
if (BitCount != 16 && BitCount != 32)
|
||||
/* For BITMAPV4HEADER/BITMAPV5HEADER the masks are included in
|
||||
* the structure itself (bV4RedMask, bV4GreenMask, and bV4BlueMask).
|
||||
* For BITMAPINFOHEADER the color masks are stored in the palette. */
|
||||
if (BitmapInfoHeader->biSize > sizeof(BITMAPINFOHEADER))
|
||||
*ColorTableSize = 0;
|
||||
else
|
||||
*ColorTableSize = 3;
|
||||
|
||||
return TRUE;
|
||||
|
||||
case BI_RGB:
|
||||
switch (BitCount)
|
||||
{
|
||||
case 1:
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 2) : 2;
|
||||
return TRUE;
|
||||
|
||||
case 4:
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 16) : 16;
|
||||
return TRUE;
|
||||
|
||||
case 8:
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 256) : 256;
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
if (*ColorSpec == DIB_PAL_COLORS)
|
||||
*ColorSpec = DIB_RGB_COLORS;
|
||||
if (BitCount != 16 && BitCount != 24 && BitCount != 32)
|
||||
return FALSE;
|
||||
*ColorTableSize = ClrUsed;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case BI_RLE4:
|
||||
if (BitCount == 4)
|
||||
{
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 16) : 16;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* For BITMAPV4HEADER/BITMAPV5HEADER the masks are included in
|
||||
* the structure itself (bV4RedMask, bV4GreenMask, and bV4BlueMask).
|
||||
* For BITMAPINFOHEADER the color masks are stored in the palette.
|
||||
*/
|
||||
case BI_RLE8:
|
||||
if (BitCount == 8)
|
||||
{
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 256) : 256;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
if (BitmapInfoHeader->biSize > sizeof(BITMAPINFOHEADER))
|
||||
*ColorTableSize = 0;
|
||||
else
|
||||
*ColorTableSize = 3;
|
||||
|
||||
return TRUE;
|
||||
|
||||
case BI_RGB:
|
||||
switch (BitCount)
|
||||
{
|
||||
case 1:
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 2) : 2;
|
||||
return TRUE;
|
||||
|
||||
case 4:
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 16) : 16;
|
||||
return TRUE;
|
||||
|
||||
case 8:
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 256) : 256;
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
if (*ColorSpec == DIB_PAL_COLORS)
|
||||
*ColorSpec = DIB_RGB_COLORS;
|
||||
if (BitCount != 16 && BitCount != 24 && BitCount != 32)
|
||||
return FALSE;
|
||||
*ColorTableSize = ClrUsed;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case BI_RLE4:
|
||||
if (BitCount == 4)
|
||||
{
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 16) : 16;
|
||||
case BI_JPEG:
|
||||
case BI_PNG:
|
||||
*ColorTableSize = ClrUsed;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case BI_RLE8:
|
||||
if (BitCount == 8)
|
||||
{
|
||||
*ColorTableSize = ClrUsed ? min(ClrUsed, 256) : 256;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
case BI_JPEG:
|
||||
case BI_PNG:
|
||||
*ColorTableSize = ClrUsed;
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
IntGdiCreateDIBBrush(
|
||||
CONST BITMAPINFO *BitmapInfo,
|
||||
UINT ColorSpec,
|
||||
UINT BitmapInfoSize,
|
||||
CONST VOID *PackedDIB)
|
||||
CONST BITMAPINFO *BitmapInfo,
|
||||
UINT ColorSpec,
|
||||
UINT BitmapInfoSize,
|
||||
CONST VOID *PackedDIB)
|
||||
{
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBITMAP hPattern;
|
||||
ULONG_PTR DataPtr;
|
||||
UINT PaletteEntryCount;
|
||||
PSURFACE psurfPattern;
|
||||
INT PaletteType;
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBITMAP hPattern;
|
||||
ULONG_PTR DataPtr;
|
||||
UINT PaletteEntryCount;
|
||||
PSURFACE psurfPattern;
|
||||
INT PaletteType;
|
||||
|
||||
if (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
if (BitmapInfo->bmiHeader.biSize < sizeof(BITMAPINFOHEADER))
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!CalculateColorTableSize(&BitmapInfo->bmiHeader, &ColorSpec,
|
||||
&PaletteEntryCount))
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
if (!CalculateColorTableSize(&BitmapInfo->bmiHeader,
|
||||
&ColorSpec,
|
||||
&PaletteEntryCount))
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DataPtr = (ULONG_PTR)BitmapInfo + BitmapInfo->bmiHeader.biSize;
|
||||
if (ColorSpec == DIB_RGB_COLORS)
|
||||
DataPtr += PaletteEntryCount * sizeof(RGBQUAD);
|
||||
else
|
||||
DataPtr += PaletteEntryCount * sizeof(USHORT);
|
||||
// FIXME: What about BI_BITFIELDS
|
||||
DataPtr = (ULONG_PTR)BitmapInfo + BitmapInfo->bmiHeader.biSize;
|
||||
if (ColorSpec == DIB_RGB_COLORS)
|
||||
DataPtr += PaletteEntryCount * sizeof(RGBQUAD);
|
||||
else
|
||||
DataPtr += PaletteEntryCount * sizeof(USHORT);
|
||||
|
||||
hPattern = IntGdiCreateBitmap(BitmapInfo->bmiHeader.biWidth,
|
||||
BitmapInfo->bmiHeader.biHeight,
|
||||
BitmapInfo->bmiHeader.biPlanes,
|
||||
BitmapInfo->bmiHeader.biBitCount,
|
||||
(PVOID)DataPtr);
|
||||
if (hPattern == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hPattern = IntGdiCreateBitmap(BitmapInfo->bmiHeader.biWidth,
|
||||
BitmapInfo->bmiHeader.biHeight,
|
||||
BitmapInfo->bmiHeader.biPlanes,
|
||||
BitmapInfo->bmiHeader.biBitCount,
|
||||
(PVOID)DataPtr);
|
||||
if (hPattern == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
psurfPattern = SURFACE_LockSurface(hPattern);
|
||||
ASSERT(psurfPattern != NULL);
|
||||
psurfPattern->hDIBPalette = BuildDIBPalette(BitmapInfo, &PaletteType);
|
||||
SURFACE_UnlockSurface(psurfPattern);
|
||||
psurfPattern = SURFACE_LockSurface(hPattern);
|
||||
ASSERT(psurfPattern != NULL);
|
||||
psurfPattern->hDIBPalette = BuildDIBPalette(BitmapInfo, &PaletteType);
|
||||
SURFACE_UnlockSurface(psurfPattern);
|
||||
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
GreDeleteObject(hPattern);
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
GreDeleteObject(hPattern);
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_BITMAP | GDIBRUSH_IS_DIB;
|
||||
pbrush->hbmPattern = hPattern;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_BITMAP | GDIBRUSH_IS_DIB;
|
||||
pbrush->hbmPattern = hPattern;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
|
||||
return hBrush;
|
||||
return hBrush;
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
IntGdiCreateHatchBrush(
|
||||
INT Style,
|
||||
COLORREF Color)
|
||||
INT Style,
|
||||
COLORREF Color)
|
||||
{
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBITMAP hPattern;
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBITMAP hPattern;
|
||||
|
||||
if (Style < 0 || Style >= NB_HATCH_STYLES)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (Style < 0 || Style >= NB_HATCH_STYLES)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
hPattern = IntGdiCreateBitmap(8, 8, 1, 1, (LPBYTE)HatchBrushes[Style]);
|
||||
if (hPattern == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hPattern = IntGdiCreateBitmap(8, 8, 1, 1, (LPBYTE)HatchBrushes[Style]);
|
||||
if (hPattern == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
GreDeleteObject(hPattern);
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
GreDeleteObject(hPattern);
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_HATCH;
|
||||
pbrush->hbmPattern = hPattern;
|
||||
pbrush->BrushAttr.lbColor = Color & 0xFFFFFF;
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_HATCH;
|
||||
pbrush->hbmPattern = hPattern;
|
||||
pbrush->BrushAttr.lbColor = Color & 0xFFFFFF;
|
||||
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
|
||||
return hBrush;
|
||||
return hBrush;
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
IntGdiCreatePatternBrush(
|
||||
HBITMAP hBitmap)
|
||||
HBITMAP hBitmap)
|
||||
{
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBITMAP hPattern;
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBITMAP hPattern;
|
||||
|
||||
hPattern = BITMAP_CopyBitmap(hBitmap);
|
||||
if (hPattern == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hPattern = BITMAP_CopyBitmap(hBitmap);
|
||||
if (hPattern == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
GreDeleteObject(hPattern);
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
GreDeleteObject(hPattern);
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_BITMAP;
|
||||
pbrush->hbmPattern = hPattern;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_BITMAP;
|
||||
pbrush->hbmPattern = hPattern;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
GDIOBJ_SetOwnership(hPattern, NULL);
|
||||
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
|
||||
return hBrush;
|
||||
return hBrush;
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
IntGdiCreateSolidBrush(
|
||||
COLORREF Color)
|
||||
COLORREF Color)
|
||||
{
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_SOLID;
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_SOLID;
|
||||
|
||||
pbrush->BrushAttr.lbColor = Color;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
pbrush->BrushAttr.lbColor = Color;
|
||||
/* FIXME: Fill in the rest of fields!!! */
|
||||
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
|
||||
return hBrush;
|
||||
return hBrush;
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
IntGdiCreateNullBrush(VOID)
|
||||
{
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
HBRUSH hBrush;
|
||||
PBRUSH pbrush;
|
||||
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
pbrush = BRUSH_AllocBrushWithHandle();
|
||||
if (pbrush == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
hBrush = pbrush->BaseObject.hHmgr;
|
||||
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_NULL;
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
pbrush->flAttrs |= GDIBRUSH_IS_NULL;
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
|
||||
return hBrush;
|
||||
return hBrush;
|
||||
}
|
||||
|
||||
VOID
|
||||
FASTCALL
|
||||
IntGdiSetSolidBrushColor(HBRUSH hBrush, COLORREF Color)
|
||||
{
|
||||
PBRUSH pbrush;
|
||||
|
||||
pbrush = BRUSH_LockBrush(hBrush);
|
||||
if (pbrush->flAttrs & GDIBRUSH_IS_SOLID)
|
||||
{
|
||||
pbrush->BrushAttr.lbColor = Color & 0xFFFFFF;
|
||||
}
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
}
|
||||
|
||||
|
||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
NtGdiCreateDIBBrush(
|
||||
IN PVOID BitmapInfoAndData,
|
||||
IN FLONG ColorSpec,
|
||||
IN UINT BitmapInfoSize,
|
||||
IN BOOL b8X8,
|
||||
IN BOOL bPen,
|
||||
IN PVOID PackedDIB)
|
||||
IN PVOID BitmapInfoAndData,
|
||||
IN FLONG ColorSpec,
|
||||
IN UINT BitmapInfoSize,
|
||||
IN BOOL b8X8,
|
||||
IN BOOL bPen,
|
||||
IN PVOID PackedDIB)
|
||||
{
|
||||
BITMAPINFO *SafeBitmapInfoAndData;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
HBRUSH hBrush;
|
||||
BITMAPINFO *SafeBitmapInfoAndData;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
HBRUSH hBrush;
|
||||
|
||||
SafeBitmapInfoAndData = EngAllocMem(FL_ZERO_MEMORY, BitmapInfoSize, TAG_DIB);
|
||||
if (SafeBitmapInfoAndData == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
SafeBitmapInfoAndData = EngAllocMem(FL_ZERO_MEMORY, BitmapInfoSize, TAG_DIB);
|
||||
if (SafeBitmapInfoAndData == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForRead(BitmapInfoAndData,
|
||||
BitmapInfoSize,
|
||||
1);
|
||||
RtlCopyMemory(SafeBitmapInfoAndData,
|
||||
BitmapInfoAndData,
|
||||
BitmapInfoSize);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
}
|
||||
_SEH2_END;
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForRead(BitmapInfoAndData, BitmapInfoSize, 1);
|
||||
RtlCopyMemory(SafeBitmapInfoAndData, BitmapInfoAndData, BitmapInfoSize);
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
EngFreeMem(SafeBitmapInfoAndData);
|
||||
SetLastNtError(Status);
|
||||
return 0;
|
||||
}
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
EngFreeMem(SafeBitmapInfoAndData);
|
||||
SetLastNtError(Status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
hBrush = IntGdiCreateDIBBrush(SafeBitmapInfoAndData, ColorSpec,
|
||||
BitmapInfoSize, PackedDIB);
|
||||
hBrush = IntGdiCreateDIBBrush(SafeBitmapInfoAndData,
|
||||
ColorSpec,
|
||||
BitmapInfoSize,
|
||||
PackedDIB);
|
||||
|
||||
EngFreeMem(SafeBitmapInfoAndData);
|
||||
EngFreeMem(SafeBitmapInfoAndData);
|
||||
|
||||
return hBrush;
|
||||
return hBrush;
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
NtGdiCreateHatchBrushInternal(
|
||||
ULONG Style,
|
||||
COLORREF Color,
|
||||
BOOL bPen)
|
||||
ULONG Style,
|
||||
COLORREF Color,
|
||||
BOOL bPen)
|
||||
{
|
||||
return IntGdiCreateHatchBrush(Style, Color);
|
||||
return IntGdiCreateHatchBrush(Style, Color);
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
NtGdiCreatePatternBrushInternal(
|
||||
HBITMAP hBitmap,
|
||||
BOOL bPen,
|
||||
BOOL b8x8)
|
||||
HBITMAP hBitmap,
|
||||
BOOL bPen,
|
||||
BOOL b8x8)
|
||||
{
|
||||
return IntGdiCreatePatternBrush(hBitmap);
|
||||
return IntGdiCreatePatternBrush(hBitmap);
|
||||
}
|
||||
|
||||
HBRUSH APIENTRY
|
||||
HBRUSH
|
||||
APIENTRY
|
||||
NtGdiCreateSolidBrush(COLORREF Color,
|
||||
IN OPTIONAL HBRUSH hbr)
|
||||
{
|
||||
return IntGdiCreateSolidBrush(Color);
|
||||
return IntGdiCreateSolidBrush(Color);
|
||||
}
|
||||
|
||||
/*
|
||||
* NtGdiSetBrushOrg
|
||||
/**
|
||||
* \name NtGdiSetBrushOrg
|
||||
*
|
||||
* The NtGdiSetBrushOrg function sets the brush origin that GDI assigns to
|
||||
* \brief Sets the brush origin that GDI assigns to
|
||||
* the next brush an application selects into the specified device context.
|
||||
*
|
||||
* Status
|
||||
* @implemented
|
||||
* @implemented
|
||||
*/
|
||||
|
||||
BOOL APIENTRY
|
||||
BOOL
|
||||
APIENTRY
|
||||
NtGdiSetBrushOrg(HDC hDC, INT XOrg, INT YOrg, LPPOINT Point)
|
||||
{
|
||||
PDC dc;
|
||||
PDC_ATTR pdcattr;
|
||||
PDC dc;
|
||||
PDC_ATTR pdcattr;
|
||||
|
||||
dc = DC_LockDc(hDC);
|
||||
if (dc == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
pdcattr = dc->pdcattr;
|
||||
|
||||
if (Point != NULL)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
POINT SafePoint;
|
||||
SafePoint.x = pdcattr->ptlBrushOrigin.x;
|
||||
SafePoint.y = pdcattr->ptlBrushOrigin.y;
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForWrite(Point,
|
||||
sizeof(POINT),
|
||||
1);
|
||||
*Point = SafePoint;
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DC_UnlockDc(dc);
|
||||
SetLastNtError(Status);
|
||||
dc = DC_LockDc(hDC);
|
||||
if (dc == NULL)
|
||||
{
|
||||
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
pdcattr->ptlBrushOrigin.x = XOrg;
|
||||
pdcattr->ptlBrushOrigin.y = YOrg;
|
||||
DC_UnlockDc(dc);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
pdcattr = dc->pdcattr;
|
||||
|
||||
VOID FASTCALL
|
||||
IntGdiSetSolidBrushColor(HBRUSH hBrush, COLORREF Color)
|
||||
{
|
||||
PBRUSH pbrush;
|
||||
if (Point != NULL)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
POINT SafePoint;
|
||||
SafePoint.x = pdcattr->ptlBrushOrigin.x;
|
||||
SafePoint.y = pdcattr->ptlBrushOrigin.y;
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForWrite(Point, sizeof(POINT), 1);
|
||||
*Point = SafePoint;
|
||||
}
|
||||
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
Status = _SEH2_GetExceptionCode();
|
||||
}
|
||||
_SEH2_END;
|
||||
|
||||
pbrush = BRUSH_LockBrush(hBrush);
|
||||
if (pbrush->flAttrs & GDIBRUSH_IS_SOLID)
|
||||
{
|
||||
pbrush->BrushAttr.lbColor = Color & 0xFFFFFF;
|
||||
}
|
||||
BRUSH_UnlockBrush(pbrush);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DC_UnlockDc(dc);
|
||||
SetLastNtError(Status);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
pdcattr->ptlBrushOrigin.x = XOrg;
|
||||
pdcattr->ptlBrushOrigin.y = YOrg;
|
||||
DC_UnlockDc(dc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
||||
Reference in New Issue
Block a user