2003-05-18 17:16:18 +00:00
|
|
|
/*
|
|
|
|
* ReactOS W32 Subsystem
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 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.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-05-18 17:16:18 +00:00
|
|
|
*/
|
2005-06-29 07:09:25 +00:00
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
1999-07-02 00:54:01 +00:00
|
|
|
|
2005-06-29 07:09:25 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
LONG APIENTRY
|
|
|
|
IntSetBitmapBits(
|
|
|
|
PSURFACE psurf,
|
|
|
|
DWORD Bytes,
|
|
|
|
IN PBYTE Bits)
|
2002-07-13 21:37:27 +00:00
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
/* Don't copy more bytes than the buffer has */
|
|
|
|
Bytes = min(Bytes, psurf->SurfObj.cjBits);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
RtlCopyMemory(psurf->SurfObj.pvBits, Bits, Bytes);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
return Bytes;
|
|
|
|
}
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
void
|
|
|
|
NTAPI
|
|
|
|
UnsafeSetBitmapBits(
|
|
|
|
PSURFACE psurf,
|
|
|
|
IN ULONG cjBits,
|
|
|
|
IN PVOID pvBits)
|
|
|
|
{
|
|
|
|
PUCHAR pjDst, pjSrc;
|
|
|
|
LONG lDeltaDst, lDeltaSrc;
|
|
|
|
ULONG nWidth, nHeight, cBitsPixel;
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
nWidth = psurf->SurfObj.sizlBitmap.cx;
|
|
|
|
nHeight = psurf->SurfObj.sizlBitmap.cy;
|
|
|
|
cBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
/* Get pointers */
|
|
|
|
pjDst = psurf->SurfObj.pvScan0;
|
|
|
|
pjSrc = pvBits;
|
|
|
|
lDeltaDst = psurf->SurfObj.lDelta;
|
|
|
|
lDeltaSrc = BITMAP_GetWidthBytes(nWidth, cBitsPixel);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
while (nHeight--)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
/* Copy one line */
|
|
|
|
memcpy(pjDst, pjSrc, lDeltaSrc);
|
|
|
|
pjSrc += lDeltaSrc;
|
|
|
|
pjDst += lDeltaDst;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HBITMAP
|
|
|
|
APIENTRY
|
2010-06-07 15:55:03 +00:00
|
|
|
GreCreateBitmapEx(
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
IN INT nWidth,
|
|
|
|
IN INT nHeight,
|
2010-06-07 15:55:03 +00:00
|
|
|
IN ULONG cjWidthBytes,
|
|
|
|
IN ULONG iFormat,
|
|
|
|
IN USHORT fjBitmap,
|
|
|
|
IN ULONG cjSizeImage,
|
2010-08-02 00:53:25 +00:00
|
|
|
IN OPTIONAL PVOID pvBits,
|
|
|
|
IN FLONG flags)
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
{
|
|
|
|
PSURFACE psurf;
|
|
|
|
SURFOBJ *pso;
|
|
|
|
HBITMAP hbmp;
|
|
|
|
PVOID pvCompressedBits;
|
|
|
|
SIZEL sizl;
|
|
|
|
|
|
|
|
/* Verify format */
|
|
|
|
if (iFormat < BMF_1BPP || iFormat > BMF_PNG) return NULL;
|
|
|
|
|
|
|
|
/* Allocate a surface */
|
|
|
|
psurf = SURFACE_AllocSurface(STYPE_BITMAP, nWidth, nHeight, iFormat);
|
|
|
|
if (!psurf)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
DPRINT1("SURFACE_AllocSurface failed.\n");
|
2009-03-17 06:34:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
/* Get the handle for the bitmap and the surfobj */
|
|
|
|
hbmp = (HBITMAP)psurf->SurfObj.hsurf;
|
|
|
|
pso = &psurf->SurfObj;
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
/* The infamous RLE hack */
|
|
|
|
if (iFormat == BMF_4RLE)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
sizl.cx = nWidth; sizl.cy = nHeight;
|
|
|
|
pvCompressedBits = pvBits;
|
|
|
|
pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
|
|
|
|
Decompress4bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
|
2010-08-02 00:53:25 +00:00
|
|
|
fjBitmap |= BMF_RLE_HACK;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
else if (iFormat == BMF_8RLE)
|
2010-05-14 18:51:48 +00:00
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
sizl.cx = nWidth; sizl.cy = nHeight;
|
|
|
|
pvCompressedBits = pvBits;
|
|
|
|
pvBits = EngAllocMem(FL_ZERO_MEMORY, pso->cjBits, TAG_DIB);
|
|
|
|
Decompress8bpp(sizl, pvCompressedBits, pvBits, pso->lDelta);
|
2010-08-02 00:53:25 +00:00
|
|
|
fjBitmap |= BMF_RLE_HACK;
|
2010-05-14 18:51:48 +00:00
|
|
|
}
|
|
|
|
|
2010-08-02 00:53:25 +00:00
|
|
|
/* Mark as API bitmap */
|
|
|
|
psurf->flags |= (flags | API_BITMAP);
|
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
/* Set the bitmap bits */
|
2010-06-07 15:55:03 +00:00
|
|
|
if (!SURFACE_bSetBitmapBits(psurf, fjBitmap, cjWidthBytes, pvBits))
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
{
|
|
|
|
/* Bail out if that failed */
|
|
|
|
DPRINT1("SURFACE_bSetBitmapBits failed.\n");
|
|
|
|
SURFACE_FreeSurfaceByHandle(hbmp);
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-03-17 06:34:09 +00:00
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
/* Unlock the surface and return */
|
|
|
|
SURFACE_UnlockSurface(psurf);
|
|
|
|
return hbmp;
|
2004-03-22 20:46:33 +00:00
|
|
|
}
|
|
|
|
|
2010-08-02 00:53:25 +00:00
|
|
|
/* Creates a DDB surface,
|
|
|
|
* as in CreateCompatibleBitmap or CreateBitmap.
|
|
|
|
*/
|
2010-06-07 15:55:03 +00:00
|
|
|
HBITMAP
|
|
|
|
APIENTRY
|
|
|
|
GreCreateBitmap(
|
|
|
|
IN INT nWidth,
|
|
|
|
IN INT nHeight,
|
|
|
|
IN UINT cPlanes,
|
|
|
|
IN UINT cBitsPixel,
|
|
|
|
IN OPTIONAL PVOID pvBits)
|
|
|
|
{
|
|
|
|
/* Call the extended function */
|
|
|
|
return GreCreateBitmapEx(nWidth,
|
|
|
|
nHeight,
|
|
|
|
0, /* auto width */
|
|
|
|
BitmapFormat(cBitsPixel * cPlanes, BI_RGB),
|
|
|
|
0, /* no bitmap flags */
|
|
|
|
0, /* auto size */
|
2010-08-02 00:53:25 +00:00
|
|
|
pvBits,
|
|
|
|
DDB_SURFACE /* DDB */);
|
2010-06-07 15:55:03 +00:00
|
|
|
}
|
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
HBITMAP
|
|
|
|
APIENTRY
|
2007-08-14 23:22:07 +00:00
|
|
|
NtGdiCreateBitmap(
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
IN INT nWidth,
|
|
|
|
IN INT nHeight,
|
|
|
|
IN UINT cPlanes,
|
|
|
|
IN UINT cBitsPixel,
|
2007-08-14 23:22:07 +00:00
|
|
|
IN OPTIONAL LPBYTE pUnsafeBits)
|
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
HBITMAP hbmp;
|
|
|
|
ULONG cjWidthBytes, iFormat;
|
|
|
|
|
|
|
|
/* NOTE: Windows also doesn't store nr. of planes separately! */
|
|
|
|
cBitsPixel = BITMAP_GetRealBitsPixel(cBitsPixel * cPlanes);
|
|
|
|
|
|
|
|
/* Calculate bitmap format */
|
|
|
|
iFormat = BitmapFormat(cBitsPixel, BI_RGB);
|
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
if (iFormat == 0 || nWidth <= 0 || nWidth >= 0x8000000 || nHeight <= 0)
|
|
|
|
{
|
|
|
|
DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
|
|
|
|
nWidth, nHeight, cBitsPixel);
|
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that cjBits will not overflow */
|
2010-08-02 00:53:25 +00:00
|
|
|
cjWidthBytes = BITMAP_GetWidthBytes(nWidth, cBitsPixel);
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
if ((ULONGLONG)cjWidthBytes * nHeight >= 0x100000000ULL)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
DPRINT1("Width = %d, Height = %d BitsPixel = %d\n",
|
|
|
|
nWidth, nHeight, cBitsPixel);
|
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-08-02 00:53:25 +00:00
|
|
|
/* cBitsPixel = cBitsPixel * cPlanes now! */
|
|
|
|
hbmp = GreCreateBitmap(nWidth, nHeight, 1, cBitsPixel, NULL);
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
|
|
|
|
if (pUnsafeBits)
|
|
|
|
{
|
2010-08-02 00:53:25 +00:00
|
|
|
PSURFACE psurf = SURFACE_LockSurface(hbmp);
|
2009-03-17 06:34:09 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
ProbeForRead(pUnsafeBits, cjWidthBytes * nHeight, 1);
|
|
|
|
UnsafeSetBitmapBits(psurf, 0, pUnsafeBits);
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
2010-08-02 00:53:25 +00:00
|
|
|
SURFACE_UnlockSurface(psurf);
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
SURFACE_FreeSurfaceByHandle(hbmp);
|
|
|
|
_SEH2_YIELD(return NULL;)
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
2010-08-02 00:53:25 +00:00
|
|
|
SURFACE_UnlockSurface(psurf);
|
|
|
|
}
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
|
|
|
|
return hbmp;
|
2007-08-14 23:22:07 +00:00
|
|
|
}
|
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
|
2004-03-15 22:06:55 +00:00
|
|
|
HBITMAP FASTCALL
|
2004-03-22 20:46:33 +00:00
|
|
|
IntCreateCompatibleBitmap(
|
2009-03-17 06:34:09 +00:00
|
|
|
PDC Dc,
|
|
|
|
INT Width,
|
|
|
|
INT Height)
|
1999-07-23 19:57:18 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
HBITMAP Bmp = NULL;
|
|
|
|
|
|
|
|
/* MS doc says if width or height is 0, return 1-by-1 pixel, monochrome bitmap */
|
|
|
|
if (0 == Width || 0 == Height)
|
|
|
|
{
|
|
|
|
Bmp = NtGdiGetStockObject(DEFAULT_BITMAP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-20 01:35:49 +00:00
|
|
|
if (Dc->dctype != DC_TYPE_MEMORY)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
2010-05-08 22:10:41 +00:00
|
|
|
PSURFACE psurf;
|
2010-05-14 18:51:48 +00:00
|
|
|
SIZEL size;
|
|
|
|
|
|
|
|
size.cx = abs(Width);
|
|
|
|
size.cy = abs(Height);
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
Bmp = GreCreateBitmap(abs(Width),
|
|
|
|
abs(Height),
|
|
|
|
1,
|
|
|
|
Dc->ppdev->gdiinfo.cBitsPixel,
|
2010-05-14 18:51:48 +00:00
|
|
|
NULL);
|
2010-05-08 22:10:41 +00:00
|
|
|
psurf = SURFACE_LockSurface(Bmp);
|
2010-05-09 11:35:36 +00:00
|
|
|
ASSERT(psurf);
|
2010-05-14 18:51:48 +00:00
|
|
|
/* Set palette */
|
2010-05-09 11:35:36 +00:00
|
|
|
psurf->ppal = PALETTE_ShareLockPalette(Dc->ppdev->devinfo.hpalDefault);
|
2010-05-14 18:51:48 +00:00
|
|
|
/* Set flags */
|
2010-06-05 21:19:41 +00:00
|
|
|
psurf->flags = API_BITMAP;
|
|
|
|
psurf->hdc = NULL; // Fixme
|
2010-05-09 11:35:36 +00:00
|
|
|
SURFACE_UnlockSurface(psurf);
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
else
|
2008-12-01 00:13:45 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
DIBSECTION dibs;
|
|
|
|
INT Count;
|
2009-04-14 20:50:02 +00:00
|
|
|
PSURFACE psurf = Dc->dclevel.pSurface;
|
2009-03-17 06:34:09 +00:00
|
|
|
Count = BITMAP_GetObject(psurf, sizeof(dibs), &dibs);
|
|
|
|
|
|
|
|
if (Count)
|
|
|
|
{
|
|
|
|
if (Count == sizeof(BITMAP))
|
|
|
|
{
|
2010-05-14 18:51:48 +00:00
|
|
|
SIZEL size;
|
|
|
|
PSURFACE psurfBmp;
|
|
|
|
size.cx = abs(Width);
|
|
|
|
size.cy = abs(Height);
|
2010-07-25 11:35:45 +00:00
|
|
|
Bmp = GreCreateBitmap(abs(Width),
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
abs(Height),
|
|
|
|
1,
|
|
|
|
dibs.dsBm.bmBitsPixel,
|
|
|
|
NULL);
|
2010-05-14 18:51:48 +00:00
|
|
|
psurfBmp = SURFACE_LockSurface(Bmp);
|
|
|
|
ASSERT(psurfBmp);
|
2010-05-09 11:35:36 +00:00
|
|
|
/* Assign palette */
|
2010-05-14 18:51:48 +00:00
|
|
|
psurfBmp->ppal = psurf->ppal;
|
|
|
|
GDIOBJ_IncrementShareCount((POBJ)psurf->ppal);
|
|
|
|
/* Set flags */
|
2010-06-05 21:19:41 +00:00
|
|
|
psurfBmp->flags = API_BITMAP;
|
|
|
|
psurfBmp->hdc = NULL; // Fixme
|
2010-05-14 18:51:48 +00:00
|
|
|
SURFACE_UnlockSurface(psurfBmp);
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* A DIB section is selected in the DC */
|
2010-07-29 16:12:43 +00:00
|
|
|
BYTE buf[sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD)] = {0};
|
2009-03-17 06:34:09 +00:00
|
|
|
PVOID Bits;
|
2010-07-29 16:12:43 +00:00
|
|
|
BITMAPINFO* bi = (BITMAPINFO*)buf;
|
|
|
|
|
|
|
|
bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
|
|
|
|
bi->bmiHeader.biWidth = Width;
|
|
|
|
bi->bmiHeader.biHeight = Height;
|
|
|
|
bi->bmiHeader.biPlanes = dibs.dsBmih.biPlanes;
|
|
|
|
bi->bmiHeader.biBitCount = dibs.dsBmih.biBitCount;
|
|
|
|
bi->bmiHeader.biCompression = dibs.dsBmih.biCompression;
|
|
|
|
bi->bmiHeader.biSizeImage = 0;
|
|
|
|
bi->bmiHeader.biXPelsPerMeter = dibs.dsBmih.biXPelsPerMeter;
|
|
|
|
bi->bmiHeader.biYPelsPerMeter = dibs.dsBmih.biYPelsPerMeter;
|
|
|
|
bi->bmiHeader.biClrUsed = dibs.dsBmih.biClrUsed;
|
|
|
|
bi->bmiHeader.biClrImportant = dibs.dsBmih.biClrImportant;
|
|
|
|
|
|
|
|
if (bi->bmiHeader.biCompression == BI_BITFIELDS)
|
2010-07-25 11:35:45 +00:00
|
|
|
{
|
|
|
|
/* Copy the color masks */
|
2010-07-29 16:12:43 +00:00
|
|
|
RtlCopyMemory(bi->bmiColors, dibs.dsBitfields, 3*sizeof(RGBQUAD));
|
2010-07-25 11:35:45 +00:00
|
|
|
}
|
2010-07-29 16:12:43 +00:00
|
|
|
else if (bi->bmiHeader.biBitCount <= 8)
|
2008-12-01 00:13:45 +00:00
|
|
|
{
|
2010-07-25 11:35:45 +00:00
|
|
|
/* Copy the color table */
|
|
|
|
UINT Index;
|
|
|
|
PPALETTE PalGDI;
|
|
|
|
|
|
|
|
if (!psurf->ppal)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
2010-07-25 11:35:45 +00:00
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return 0;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
2010-07-25 11:35:45 +00:00
|
|
|
|
|
|
|
PalGDI = PALETTE_LockPalette(psurf->ppal->BaseObject.hHmgr);
|
|
|
|
|
|
|
|
for (Index = 0;
|
|
|
|
Index < 256 && Index < PalGDI->NumColors;
|
|
|
|
Index++)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
2010-07-29 16:12:43 +00:00
|
|
|
bi->bmiColors[Index].rgbRed = PalGDI->IndexedColors[Index].peRed;
|
|
|
|
bi->bmiColors[Index].rgbGreen = PalGDI->IndexedColors[Index].peGreen;
|
|
|
|
bi->bmiColors[Index].rgbBlue = PalGDI->IndexedColors[Index].peBlue;
|
|
|
|
bi->bmiColors[Index].rgbReserved = 0;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
2010-07-25 11:35:45 +00:00
|
|
|
PALETTE_UnlockPalette(PalGDI);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
|
|
|
Bmp = DIB_CreateDIBSection(Dc,
|
2010-07-29 16:12:43 +00:00
|
|
|
bi,
|
2009-03-17 06:34:09 +00:00
|
|
|
DIB_RGB_COLORS,
|
|
|
|
&Bits,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
return Bmp;
|
2008-12-01 00:13:45 +00:00
|
|
|
}
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-01 00:13:45 +00:00
|
|
|
}
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
return Bmp;
|
2004-03-15 22:06:55 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
HBITMAP APIENTRY
|
2004-03-22 20:46:33 +00:00
|
|
|
NtGdiCreateCompatibleBitmap(
|
2009-03-17 06:34:09 +00:00
|
|
|
HDC hDC,
|
|
|
|
INT Width,
|
|
|
|
INT Height)
|
2004-03-15 22:06:55 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
HBITMAP Bmp;
|
|
|
|
PDC Dc;
|
2004-03-15 22:06:55 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
if (Width <= 0 || Height <= 0 || (Width * Height) > 0x3FFFFFFF)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-11-21 18:34:31 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
if (!hDC)
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
return GreCreateBitmap(Width, Height, 1, 1, 0);
|
2008-12-01 00:13:45 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
Dc = DC_LockDc(hDC);
|
2004-03-15 22:06:55 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
DPRINT("NtGdiCreateCompatibleBitmap(%04x,%d,%d, bpp:%d) = \n",
|
2009-08-16 12:57:41 +00:00
|
|
|
hDC, Width, Height, Dc->ppdev->gdiinfo.cBitsPixel);
|
2004-03-15 22:06:55 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
if (NULL == Dc)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-03-15 22:06:55 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
Bmp = IntCreateCompatibleBitmap(Dc, Width, Height);
|
2004-03-15 22:06:55 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
DPRINT("\t\t%04x\n", Bmp);
|
|
|
|
DC_UnlockDc(Dc);
|
|
|
|
return Bmp;
|
1999-07-23 19:57:18 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL APIENTRY
|
2007-08-12 15:20:09 +00:00
|
|
|
NtGdiGetBitmapDimension(
|
2009-03-17 06:34:09 +00:00
|
|
|
HBITMAP hBitmap,
|
|
|
|
LPSIZE Dimension)
|
1999-07-02 02:06:52 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
PSURFACE psurfBmp;
|
|
|
|
BOOL Ret = TRUE;
|
|
|
|
|
|
|
|
if (hBitmap == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
psurfBmp = SURFACE_LockSurface(hBitmap);
|
|
|
|
if (psurfBmp == NULL)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(Dimension, sizeof(SIZE), 1);
|
2010-06-05 21:19:41 +00:00
|
|
|
*Dimension = psurfBmp->sizlDim;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Ret = FALSE;
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
SURFACE_UnlockSurface(psurfBmp);
|
|
|
|
|
|
|
|
return Ret;
|
1999-07-02 02:06:52 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
COLORREF APIENTRY
|
2004-03-16 02:15:06 +00:00
|
|
|
NtGdiGetPixel(HDC hDC, INT XPos, INT YPos)
|
1999-07-02 02:06:52 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
PDC dc = NULL;
|
|
|
|
COLORREF Result = (COLORREF)CLR_INVALID; // default to failure
|
|
|
|
BOOL bInRect = FALSE;
|
|
|
|
SURFACE *psurf;
|
|
|
|
SURFOBJ *pso;
|
2009-08-04 20:37:10 +00:00
|
|
|
PPALETTE ppal;
|
|
|
|
EXLATEOBJ exlo;
|
2009-03-17 06:34:09 +00:00
|
|
|
HBITMAP hBmpTmp;
|
|
|
|
|
|
|
|
dc = DC_LockDc(hDC);
|
|
|
|
|
|
|
|
if (!dc)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2009-03-20 01:35:49 +00:00
|
|
|
if (dc->dctype == DC_TYPE_INFO)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
XPos += dc->ptlDCOrig.x;
|
|
|
|
YPos += dc->ptlDCOrig.y;
|
2009-03-20 01:35:49 +00:00
|
|
|
if (RECTL_bPointInRect(&dc->rosdc.CombinedClip->rclBounds, XPos, YPos))
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
|
|
|
bInRect = TRUE;
|
2009-04-14 20:50:02 +00:00
|
|
|
psurf = dc->dclevel.pSurface;
|
2009-03-17 06:34:09 +00:00
|
|
|
if (psurf)
|
|
|
|
{
|
2009-08-04 20:37:10 +00:00
|
|
|
pso = &psurf->SurfObj;
|
2010-05-12 22:56:24 +00:00
|
|
|
if (psurf->ppal)
|
2010-05-08 22:10:41 +00:00
|
|
|
{
|
|
|
|
ppal = psurf->ppal;
|
|
|
|
GDIOBJ_IncrementShareCount(&ppal->BaseObject);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ppal = PALETTE_ShareLockPalette(dc->ppdev->devinfo.hpalDefault);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
2009-08-04 20:37:10 +00:00
|
|
|
if (psurf->SurfObj.iBitmapFormat == BMF_1BPP && !psurf->hSecure)
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
2009-08-04 20:37:10 +00:00
|
|
|
/* FIXME: palette should be gpalMono already ! */
|
|
|
|
EXLATEOBJ_vInitialize(&exlo, &gpalMono, &gpalRGB, 0, 0xffffff, 0);
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
2009-08-04 20:37:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
EXLATEOBJ_vInitialize(&exlo, ppal, &gpalRGB, 0, 0xffffff, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if this DC has a DIB behind it...
|
|
|
|
if (pso->pvScan0) // STYPE_BITMAP == pso->iType
|
|
|
|
{
|
|
|
|
ASSERT(pso->lDelta);
|
|
|
|
Result = XLATEOBJ_iXlate(&exlo.xlo,
|
|
|
|
DibFunctionsForBitmapFormat[pso->iBitmapFormat].DIB_GetPixel(pso, XPos, YPos));
|
|
|
|
}
|
|
|
|
|
|
|
|
EXLATEOBJ_vCleanup(&exlo);
|
|
|
|
PALETTE_ShareUnlockPalette(ppal);
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DC_UnlockDc(dc);
|
|
|
|
|
|
|
|
// if Result is still CLR_INVALID, then the "quick" method above didn't work
|
|
|
|
if (bInRect && Result == CLR_INVALID)
|
|
|
|
{
|
|
|
|
// FIXME: create a 1x1 32BPP DIB, and blit to it
|
|
|
|
HDC hDCTmp = NtGdiCreateCompatibleDC(hDC);
|
|
|
|
if (hDCTmp)
|
|
|
|
{
|
|
|
|
static const BITMAPINFOHEADER bih = { sizeof(BITMAPINFOHEADER), 1, 1, 1, 32, BI_RGB, 0, 0, 0, 0, 0 };
|
|
|
|
BITMAPINFO bi;
|
|
|
|
RtlMoveMemory(&(bi.bmiHeader), &bih, sizeof(bih));
|
|
|
|
hBmpTmp = NtGdiCreateDIBitmapInternal(hDC,
|
2008-03-30 22:37:42 +00:00
|
|
|
bi.bmiHeader.biWidth,
|
|
|
|
bi.bmiHeader.biHeight,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
&bi,
|
|
|
|
DIB_RGB_COLORS,
|
|
|
|
bi.bmiHeader.biBitCount,
|
|
|
|
bi.bmiHeader.biSizeImage,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
//HBITMAP hBmpTmp = GreCreateBitmap(1, 1, 1, 32, NULL);
|
2009-03-17 06:34:09 +00:00
|
|
|
if (hBmpTmp)
|
|
|
|
{
|
|
|
|
HBITMAP hBmpOld = (HBITMAP)NtGdiSelectBitmap(hDCTmp, hBmpTmp);
|
|
|
|
if (hBmpOld)
|
|
|
|
{
|
|
|
|
PSURFACE psurf;
|
|
|
|
|
|
|
|
NtGdiBitBlt(hDCTmp, 0, 0, 1, 1, hDC, XPos, YPos, SRCCOPY, 0, 0);
|
|
|
|
NtGdiSelectBitmap(hDCTmp, hBmpOld);
|
|
|
|
|
|
|
|
// our bitmap is no longer selected, so we can access it's stuff...
|
|
|
|
psurf = SURFACE_LockSurface(hBmpTmp);
|
|
|
|
if (psurf)
|
|
|
|
{
|
|
|
|
// Dont you need to convert something here?
|
|
|
|
Result = *(COLORREF*)psurf->SurfObj.pvScan0;
|
|
|
|
SURFACE_UnlockSurface(psurf);
|
|
|
|
}
|
|
|
|
}
|
2009-03-25 20:24:34 +00:00
|
|
|
GreDeleteObject(hBmpTmp);
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
NtGdiDeleteObjectApp(hDCTmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
1999-07-02 02:06:52 +00:00
|
|
|
}
|
|
|
|
|
2007-08-02 22:14:32 +00:00
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
LONG APIENTRY
|
2007-08-02 22:14:32 +00:00
|
|
|
IntGetBitmapBits(
|
2009-03-17 06:34:09 +00:00
|
|
|
PSURFACE psurf,
|
|
|
|
DWORD Bytes,
|
|
|
|
OUT PBYTE Bits)
|
1999-07-02 02:06:52 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
LONG ret;
|
2004-03-22 20:46:33 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
ASSERT(Bits);
|
2007-08-02 22:14:32 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
/* Don't copy more bytes than the buffer has */
|
|
|
|
Bytes = min(Bytes, psurf->SurfObj.cjBits);
|
2007-08-02 22:14:32 +00:00
|
|
|
|
|
|
|
#if 0
|
2009-03-17 06:34:09 +00:00
|
|
|
/* FIXME: Call DDI CopyBits here if available */
|
|
|
|
if (psurf->DDBitmap)
|
|
|
|
{
|
|
|
|
DPRINT("Calling device specific BitmapBits\n");
|
|
|
|
if (psurf->DDBitmap->funcs->pBitmapBits)
|
|
|
|
{
|
|
|
|
ret = psurf->DDBitmap->funcs->pBitmapBits(hbitmap,
|
|
|
|
bits,
|
|
|
|
count,
|
|
|
|
DDB_GET);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR_(bitmap)("BitmapBits == NULL??\n");
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-08-02 22:14:32 +00:00
|
|
|
#endif
|
2009-03-17 06:34:09 +00:00
|
|
|
{
|
|
|
|
RtlCopyMemory(Bits, psurf->SurfObj.pvBits, Bytes);
|
|
|
|
ret = Bytes;
|
|
|
|
}
|
|
|
|
return ret;
|
2007-08-02 22:14:32 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
LONG APIENTRY
|
2009-03-17 06:34:09 +00:00
|
|
|
NtGdiGetBitmapBits(
|
|
|
|
HBITMAP hBitmap,
|
|
|
|
ULONG Bytes,
|
|
|
|
OUT OPTIONAL PBYTE pUnsafeBits)
|
2007-08-02 22:14:32 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
PSURFACE psurf;
|
2009-03-21 19:15:52 +00:00
|
|
|
LONG bmSize, ret;
|
2009-03-17 06:34:09 +00:00
|
|
|
|
|
|
|
if (pUnsafeBits != NULL && Bytes == 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
psurf = SURFACE_LockSurface(hBitmap);
|
|
|
|
if (!psurf)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-04 20:37:10 +00:00
|
|
|
bmSize = BITMAP_GetWidthBytes(psurf->SurfObj.sizlBitmap.cx,
|
|
|
|
BitsPerFormat(psurf->SurfObj.iBitmapFormat)) *
|
2009-03-21 19:15:52 +00:00
|
|
|
abs(psurf->SurfObj.sizlBitmap.cy);
|
2009-08-04 20:37:10 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
/* If the bits vector is null, the function should return the read size */
|
|
|
|
if (pUnsafeBits == NULL)
|
|
|
|
{
|
|
|
|
SURFACE_UnlockSurface(psurf);
|
2009-03-21 19:15:52 +00:00
|
|
|
return bmSize;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't copy more bytes than the buffer has */
|
2009-03-21 19:15:52 +00:00
|
|
|
Bytes = min(Bytes, bmSize);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
|
|
|
// FIXME: use MmSecureVirtualMemory
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(pUnsafeBits, Bytes, 1);
|
|
|
|
ret = IntGetBitmapBits(psurf, Bytes, pUnsafeBits);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
SURFACE_UnlockSurface(psurf);
|
|
|
|
|
|
|
|
return ret;
|
2007-08-02 22:14:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
LONG APIENTRY
|
2007-08-02 22:14:32 +00:00
|
|
|
NtGdiSetBitmapBits(
|
2009-03-17 06:34:09 +00:00
|
|
|
HBITMAP hBitmap,
|
|
|
|
DWORD Bytes,
|
|
|
|
IN PBYTE pUnsafeBits)
|
2007-08-02 22:14:32 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
LONG ret;
|
|
|
|
PSURFACE psurf;
|
|
|
|
|
|
|
|
if (pUnsafeBits == NULL || Bytes == 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
psurf = SURFACE_LockSurface(hBitmap);
|
|
|
|
if (psurf == NULL)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForRead(pUnsafeBits, Bytes, 1);
|
[WIN32K]
Rewrite the bitmap API. There were a lot of bugs. NtGdiCreateBitmap allowed a negative height, leading to either topdown or bottomup bitmaps, a behaviour that Windows doesn't have. The function copied the bitmap bits directly from the caller to the bitmap using RtlCopyMemory, ignoring different scanline length and direction (resulting in bitmaps being upside down), not SEH protected. This function (IntSetBitmapBits) is replaced by a better solution UnsafeSetBitmapBits, that takes these things into account. The name is chosen to give a hint that the function can/should be SEH protected. IntSetBitmapBits is still there, as its retarded behaviour is actually required in some places. There were also IntCreateBitmap and IntGdiCreateBitmap, now both being replaced by GreCreateBitmap. The code that set the palette is removed, as it's already done in SURFACE_AllocSurface, here gpalRGB is replaced with gpalBGR, fixing some inverted color issues. The alignment correction in SURFACE_bSetBitmapBits is reapplied, now that the callers are behaving as they are supposed to do.
svn path=/branches/reactos-yarotows/; revision=47641
2010-06-06 22:01:41 +00:00
|
|
|
UnsafeSetBitmapBits(psurf, Bytes, pUnsafeBits);
|
|
|
|
ret = 1;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
SURFACE_UnlockSurface(psurf);
|
|
|
|
|
|
|
|
return ret;
|
1999-07-02 02:06:52 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL APIENTRY
|
2007-08-11 06:29:31 +00:00
|
|
|
NtGdiSetBitmapDimension(
|
2009-03-17 06:34:09 +00:00
|
|
|
HBITMAP hBitmap,
|
|
|
|
INT Width,
|
|
|
|
INT Height,
|
|
|
|
LPSIZE Size)
|
1999-07-02 02:06:52 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
PSURFACE psurf;
|
|
|
|
BOOL Ret = TRUE;
|
|
|
|
|
|
|
|
if (hBitmap == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
psurf = SURFACE_LockSurface(hBitmap);
|
|
|
|
if (psurf == NULL)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Size)
|
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(Size, sizeof(SIZE), 1);
|
2010-06-05 21:19:41 +00:00
|
|
|
*Size = psurf->sizlDim;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Ret = FALSE;
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The dimension is changed even if writing the old value failed */
|
2010-06-05 21:19:41 +00:00
|
|
|
psurf->sizlDim.cx = Width;
|
|
|
|
psurf->sizlDim.cy = Height;
|
2009-03-17 06:34:09 +00:00
|
|
|
|
|
|
|
SURFACE_UnlockSurface(psurf);
|
|
|
|
|
|
|
|
return Ret;
|
1999-07-02 02:06:52 +00:00
|
|
|
}
|
|
|
|
|
2009-12-22 16:17:44 +00:00
|
|
|
VOID IntHandleSpecialColorType(HDC hDC, COLORREF* Color)
|
|
|
|
{
|
|
|
|
PDC pdc = NULL;
|
|
|
|
RGBQUAD quad;
|
|
|
|
PALETTEENTRY palEntry;
|
|
|
|
UINT index;
|
|
|
|
|
|
|
|
switch (*Color >> 24)
|
|
|
|
{
|
|
|
|
case 0x10: /* DIBINDEX */
|
2010-04-21 15:52:52 +00:00
|
|
|
if (IntGetDIBColorTable(hDC, LOWORD(*Color), 1, &quad) == 1)
|
2009-12-22 16:17:44 +00:00
|
|
|
{
|
2009-12-27 15:08:41 +00:00
|
|
|
*Color = RGB(quad.rgbRed, quad.rgbGreen, quad.rgbBlue);
|
2009-12-22 16:17:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Out of color table bounds - use black */
|
|
|
|
*Color = RGB(0, 0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x02: /* PALETTERGB */
|
|
|
|
pdc = DC_LockDc(hDC);
|
2009-12-27 15:08:41 +00:00
|
|
|
if (pdc->dclevel.hpal != NtGdiGetStockObject(DEFAULT_PALETTE))
|
2009-12-22 16:17:44 +00:00
|
|
|
{
|
2009-12-27 15:08:41 +00:00
|
|
|
index = NtGdiGetNearestPaletteIndex(pdc->dclevel.hpal, *Color);
|
|
|
|
IntGetPaletteEntries(pdc->dclevel.hpal, index, 1, &palEntry);
|
|
|
|
*Color = RGB(palEntry.peRed, palEntry.peGreen, palEntry.peBlue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Use the pure color */
|
|
|
|
*Color = *Color & 0x00FFFFFF;
|
2009-12-22 16:17:44 +00:00
|
|
|
}
|
|
|
|
DC_UnlockDc(pdc);
|
|
|
|
break;
|
|
|
|
case 0x01: /* PALETTEINDEX */
|
|
|
|
pdc = DC_LockDc(hDC);
|
|
|
|
if (IntGetPaletteEntries(pdc->dclevel.hpal, LOWORD(*Color), 1, &palEntry) == 1)
|
|
|
|
{
|
2009-12-27 15:08:41 +00:00
|
|
|
*Color = RGB(palEntry.peRed, palEntry.peGreen, palEntry.peBlue);
|
2009-12-22 16:17:44 +00:00
|
|
|
}
|
2009-12-27 15:43:48 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Index does not exist, use zero index */
|
|
|
|
IntGetPaletteEntries(pdc->dclevel.hpal, 0, 1, &palEntry);
|
|
|
|
*Color = RGB(palEntry.peRed, palEntry.peGreen, palEntry.peBlue);
|
|
|
|
}
|
2009-12-22 16:17:44 +00:00
|
|
|
DC_UnlockDc(pdc);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DPRINT("Unsupported color type %d passed\n", *Color >> 24);
|
|
|
|
break;
|
2010-04-21 15:52:52 +00:00
|
|
|
}
|
2009-12-22 16:17:44 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL APIENTRY
|
2007-09-01 02:51:48 +00:00
|
|
|
GdiSetPixelV(
|
2009-03-17 06:34:09 +00:00
|
|
|
HDC hDC,
|
|
|
|
INT X,
|
|
|
|
INT Y,
|
|
|
|
COLORREF Color)
|
1999-07-02 02:06:52 +00:00
|
|
|
{
|
2009-12-22 16:17:44 +00:00
|
|
|
HBRUSH hBrush;
|
2009-03-17 06:34:09 +00:00
|
|
|
HGDIOBJ OldBrush;
|
|
|
|
|
2009-12-22 16:17:44 +00:00
|
|
|
if ((Color & 0xFF000000) != 0)
|
|
|
|
{
|
|
|
|
IntHandleSpecialColorType(hDC, &Color);
|
|
|
|
}
|
2009-03-17 06:34:09 +00:00
|
|
|
|
2009-12-22 16:17:44 +00:00
|
|
|
hBrush = NtGdiCreateSolidBrush(Color, NULL);
|
|
|
|
if (hBrush == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
OldBrush = NtGdiSelectBrush(hDC, hBrush);
|
2009-03-17 06:34:09 +00:00
|
|
|
if (OldBrush == NULL)
|
|
|
|
{
|
2009-12-22 16:17:44 +00:00
|
|
|
GreDeleteObject(hBrush);
|
|
|
|
return FALSE;
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NtGdiPatBlt(hDC, X, Y, 1, 1, PATCOPY);
|
|
|
|
NtGdiSelectBrush(hDC, OldBrush);
|
2009-12-22 16:17:44 +00:00
|
|
|
GreDeleteObject(hBrush);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1999-07-02 02:06:52 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
COLORREF APIENTRY
|
2007-09-01 02:51:48 +00:00
|
|
|
NtGdiSetPixel(
|
2009-03-17 06:34:09 +00:00
|
|
|
HDC hDC,
|
|
|
|
INT X,
|
|
|
|
INT Y,
|
|
|
|
COLORREF Color)
|
2007-09-01 02:51:48 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
DPRINT("0 NtGdiSetPixel X %ld Y %ld C %ld\n", X, Y, Color);
|
|
|
|
|
|
|
|
if (GdiSetPixelV(hDC,X,Y,Color))
|
|
|
|
{
|
|
|
|
Color = NtGdiGetPixel(hDC,X,Y);
|
|
|
|
DPRINT("1 NtGdiSetPixel X %ld Y %ld C %ld\n", X, Y, Color);
|
|
|
|
return Color;
|
|
|
|
}
|
|
|
|
|
|
|
|
Color = (COLORREF)CLR_INVALID;
|
|
|
|
DPRINT("2 NtGdiSetPixel X %ld Y %ld C %ld\n", X, Y, Color);
|
|
|
|
return Color;
|
2007-09-01 02:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-29 01:58:20 +00:00
|
|
|
/* Internal Functions */
|
|
|
|
|
2008-07-07 16:03:14 +00:00
|
|
|
UINT FASTCALL
|
2009-01-09 02:06:39 +00:00
|
|
|
BITMAP_GetRealBitsPixel(UINT nBitsPixel)
|
2007-08-14 23:22:07 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
if (nBitsPixel <= 1)
|
|
|
|
return 1;
|
|
|
|
if (nBitsPixel <= 4)
|
|
|
|
return 4;
|
|
|
|
if (nBitsPixel <= 8)
|
|
|
|
return 8;
|
|
|
|
if (nBitsPixel <= 16)
|
|
|
|
return 16;
|
|
|
|
if (nBitsPixel <= 24)
|
|
|
|
return 24;
|
|
|
|
if (nBitsPixel <= 32)
|
|
|
|
return 32;
|
|
|
|
|
|
|
|
return 0;
|
2007-08-14 23:22:07 +00:00
|
|
|
}
|
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
INT FASTCALL
|
2009-03-17 06:34:09 +00:00
|
|
|
BITMAP_GetWidthBytes(INT bmWidth, INT bpp)
|
1999-10-29 01:58:20 +00:00
|
|
|
{
|
2003-06-03 22:26:52 +00:00
|
|
|
#if 0
|
2009-03-17 06:34:09 +00:00
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return 2 * ((bmWidth+15) >> 4);
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
case 24:
|
|
|
|
bmWidth *= 3; /* fall through */
|
|
|
|
case 8:
|
|
|
|
return bmWidth + (bmWidth & 1);
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
case 32:
|
|
|
|
return bmWidth * 4;
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
case 16:
|
|
|
|
case 15:
|
|
|
|
return bmWidth * 2;
|
1999-10-29 01:58:20 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
case 4:
|
|
|
|
return 2 * ((bmWidth+3) >> 2);
|
2002-07-13 21:37:27 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
default:
|
|
|
|
DPRINT ("stub");
|
|
|
|
}
|
1999-10-29 01:58:20 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
return -1;
|
2003-06-03 22:26:52 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
return ((bmWidth * bpp + 15) & ~15) >> 3;
|
1999-10-29 01:58:20 +00:00
|
|
|
}
|
|
|
|
|
2004-03-22 20:46:33 +00:00
|
|
|
HBITMAP FASTCALL
|
2009-03-17 06:34:09 +00:00
|
|
|
BITMAP_CopyBitmap(HBITMAP hBitmap)
|
1999-11-17 20:54:05 +00:00
|
|
|
{
|
2009-03-17 06:34:09 +00:00
|
|
|
HBITMAP res;
|
|
|
|
BITMAP bm;
|
|
|
|
SURFACE *Bitmap, *resBitmap;
|
|
|
|
SIZEL Size;
|
|
|
|
|
|
|
|
if (hBitmap == NULL)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-08-01 12:17:35 +00:00
|
|
|
Bitmap = SURFACE_LockSurface(hBitmap);
|
2009-03-17 06:34:09 +00:00
|
|
|
if (Bitmap == NULL)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BITMAP_GetObject(Bitmap, sizeof(BITMAP), (PVOID)&bm);
|
|
|
|
bm.bmBits = NULL;
|
|
|
|
if (Bitmap->SurfObj.lDelta >= 0)
|
|
|
|
bm.bmHeight = -bm.bmHeight;
|
|
|
|
|
|
|
|
Size.cx = abs(bm.bmWidth);
|
|
|
|
Size.cy = abs(bm.bmHeight);
|
2010-08-01 12:17:35 +00:00
|
|
|
res = GreCreateBitmapEx(Size.cx,
|
|
|
|
Size.cy,
|
|
|
|
bm.bmWidthBytes,
|
|
|
|
Bitmap->SurfObj.iBitmapFormat,
|
|
|
|
Bitmap->SurfObj.fjBitmap,
|
|
|
|
Bitmap->SurfObj.cjBits,
|
2010-08-02 00:53:25 +00:00
|
|
|
NULL,
|
|
|
|
Bitmap->flags);
|
2010-08-01 12:17:35 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
|
|
|
|
if (res)
|
|
|
|
{
|
2010-08-01 12:17:35 +00:00
|
|
|
resBitmap = SURFACE_LockSurface(res);
|
2009-03-17 06:34:09 +00:00
|
|
|
if (resBitmap)
|
|
|
|
{
|
2010-08-01 12:17:35 +00:00
|
|
|
IntSetBitmapBits(resBitmap, Bitmap->SurfObj.cjBits, Bitmap->SurfObj.pvBits);
|
|
|
|
SURFACE_UnlockSurface(resBitmap);
|
2009-03-17 06:34:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-25 20:24:34 +00:00
|
|
|
GreDeleteObject(res);
|
2009-03-17 06:34:09 +00:00
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-01 12:17:35 +00:00
|
|
|
SURFACE_UnlockSurface(Bitmap);
|
2009-03-17 06:34:09 +00:00
|
|
|
|
|
|
|
return res;
|
1999-11-17 20:54:05 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
INT APIENTRY
|
2009-01-09 02:06:39 +00:00
|
|
|
BITMAP_GetObject(SURFACE *psurf, INT Count, LPVOID buffer)
|
1999-11-17 20:54:05 +00:00
|
|
|
{
|
2009-01-09 02:06:39 +00:00
|
|
|
PBITMAP pBitmap;
|
|
|
|
|
|
|
|
if (!buffer) return sizeof(BITMAP);
|
2009-03-17 06:34:09 +00:00
|
|
|
if ((UINT)Count < sizeof(BITMAP)) return 0;
|
2006-09-25 05:25:11 +00:00
|
|
|
|
2009-01-09 02:06:39 +00:00
|
|
|
/* always fill a basic BITMAP structure */
|
|
|
|
pBitmap = buffer;
|
|
|
|
pBitmap->bmType = 0;
|
|
|
|
pBitmap->bmWidth = psurf->SurfObj.sizlBitmap.cx;
|
|
|
|
pBitmap->bmHeight = psurf->SurfObj.sizlBitmap.cy;
|
|
|
|
pBitmap->bmPlanes = 1;
|
|
|
|
pBitmap->bmBitsPixel = BitsPerFormat(psurf->SurfObj.iBitmapFormat);
|
2010-08-02 01:41:16 +00:00
|
|
|
pBitmap->bmWidthBytes = BITMAP_GetWidthBytes(pBitmap->bmWidth, pBitmap->bmBitsPixel);
|
2009-01-09 02:06:39 +00:00
|
|
|
|
|
|
|
/* Check for DIB section */
|
2009-03-17 06:34:09 +00:00
|
|
|
if (psurf->hSecure)
|
|
|
|
{
|
|
|
|
/* Set bmBits in this case */
|
2009-01-09 02:06:39 +00:00
|
|
|
pBitmap->bmBits = psurf->SurfObj.pvBits;
|
2010-08-02 01:41:16 +00:00
|
|
|
/* DIBs data are 32 bits aligned */
|
|
|
|
pBitmap->bmWidthBytes = DIB_GetDIBWidthBytes(pBitmap->bmWidth, pBitmap->bmBitsPixel);
|
2009-01-09 02:06:39 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
if (Count >= sizeof(DIBSECTION))
|
|
|
|
{
|
2009-01-09 02:06:39 +00:00
|
|
|
/* Fill rest of DIBSECTION */
|
|
|
|
PDIBSECTION pds = buffer;
|
|
|
|
|
2009-01-28 15:43:02 +00:00
|
|
|
pds->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
|
2009-01-09 02:06:39 +00:00
|
|
|
pds->dsBmih.biWidth = pds->dsBm.bmWidth;
|
|
|
|
pds->dsBmih.biHeight = pds->dsBm.bmHeight;
|
|
|
|
pds->dsBmih.biPlanes = pds->dsBm.bmPlanes;
|
|
|
|
pds->dsBmih.biBitCount = pds->dsBm.bmBitsPixel;
|
2009-03-21 19:15:52 +00:00
|
|
|
switch (psurf->SurfObj.iBitmapFormat)
|
|
|
|
{
|
|
|
|
/* FIXME: What about BI_BITFIELDS? */
|
|
|
|
case BMF_1BPP:
|
|
|
|
case BMF_4BPP:
|
|
|
|
case BMF_8BPP:
|
|
|
|
case BMF_16BPP:
|
|
|
|
case BMF_24BPP:
|
|
|
|
case BMF_32BPP:
|
|
|
|
pds->dsBmih.biCompression = BI_RGB;
|
|
|
|
break;
|
|
|
|
case BMF_4RLE:
|
|
|
|
pds->dsBmih.biCompression = BI_RLE4;
|
|
|
|
break;
|
|
|
|
case BMF_8RLE:
|
|
|
|
pds->dsBmih.biCompression = BI_RLE8;
|
|
|
|
break;
|
|
|
|
case BMF_JPEG:
|
|
|
|
pds->dsBmih.biCompression = BI_JPEG;
|
|
|
|
break;
|
|
|
|
case BMF_PNG:
|
|
|
|
pds->dsBmih.biCompression = BI_PNG;
|
|
|
|
break;
|
|
|
|
}
|
2009-01-09 02:06:39 +00:00
|
|
|
pds->dsBmih.biSizeImage = psurf->SurfObj.cjBits;
|
|
|
|
pds->dsBmih.biXPelsPerMeter = 0;
|
|
|
|
pds->dsBmih.biYPelsPerMeter = 0;
|
2010-07-30 02:15:46 +00:00
|
|
|
pds->dsBmih.biClrUsed = psurf->ppal->NumColors;
|
2009-01-09 02:06:39 +00:00
|
|
|
pds->dsBmih.biClrImportant = psurf->biClrImportant;
|
2010-07-30 02:15:46 +00:00
|
|
|
pds->dsBitfields[0] = psurf->ppal->RedMask;
|
|
|
|
pds->dsBitfields[1] = psurf->ppal->GreenMask;
|
|
|
|
pds->dsBitfields[2] = psurf->ppal->BlueMask;
|
2009-01-09 02:06:39 +00:00
|
|
|
pds->dshSection = psurf->hDIBSection;
|
|
|
|
pds->dsOffset = psurf->dwOffset;
|
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
return sizeof(DIBSECTION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* not set according to wine test, confirmed in win2k */
|
|
|
|
pBitmap->bmBits = NULL;
|
|
|
|
}
|
2009-01-09 02:06:39 +00:00
|
|
|
|
2009-03-17 06:34:09 +00:00
|
|
|
return sizeof(BITMAP);
|
1999-11-17 20:54:05 +00:00
|
|
|
}
|
2008-04-18 20:43:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HDC
|
|
|
|
APIENTRY
|
|
|
|
NtGdiGetDCforBitmap(
|
|
|
|
IN HBITMAP hsurf)
|
|
|
|
{
|
2010-06-05 21:19:41 +00:00
|
|
|
HDC hdc = NULL;
|
2009-03-17 06:34:09 +00:00
|
|
|
PSURFACE psurf = SURFACE_LockSurface(hsurf);
|
|
|
|
if (psurf)
|
|
|
|
{
|
2010-06-05 21:19:41 +00:00
|
|
|
hdc = psurf->hdc;
|
2009-03-17 06:34:09 +00:00
|
|
|
SURFACE_UnlockSurface(psurf);
|
|
|
|
}
|
2010-06-05 21:19:41 +00:00
|
|
|
return hdc;
|
2008-04-18 20:43:25 +00:00
|
|
|
}
|
|
|
|
|
2010-08-02 00:53:25 +00:00
|
|
|
|
2003-05-18 17:16:18 +00:00
|
|
|
/* EOF */
|