[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* PURPOSE: RLE compression
|
2015-11-10 17:41:55 +00:00
|
|
|
* FILE: win32ss/gdi/eng/rlecomp.c
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
* PROGRAMER: Jason Filby
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <win32k.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
enum Rle_EscapeCodes
|
|
|
|
{
|
|
|
|
RLE_EOL = 0, /* End of line */
|
|
|
|
RLE_END = 1, /* End of bitmap */
|
|
|
|
RLE_DELTA = 2 /* Delta */
|
|
|
|
};
|
|
|
|
|
2018-12-25 09:04:21 +00:00
|
|
|
VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits,
|
|
|
|
LONG Delta, ULONG Format, ULONG cjSizeImage)
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
{
|
2018-12-25 09:04:21 +00:00
|
|
|
INT x = 0, y = Size.cy - 1;
|
|
|
|
INT i, c, c2, length;
|
|
|
|
INT width = Size.cx, height = y;
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
BYTE *begin = CompressedBits;
|
|
|
|
BYTE *bits = CompressedBits;
|
|
|
|
BYTE *temp;
|
2018-12-25 09:04:21 +00:00
|
|
|
BOOL is4bpp = FALSE;
|
2010-10-24 23:40:23 +00:00
|
|
|
|
2012-05-01 14:57:23 +00:00
|
|
|
if ((Format == BMF_4RLE) || (Format == BMF_4BPP))
|
2018-12-25 09:04:21 +00:00
|
|
|
is4bpp = TRUE;
|
2012-05-01 14:59:24 +00:00
|
|
|
else if ((Format != BMF_8RLE) && (Format != BMF_8BPP))
|
2010-10-24 23:40:23 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
{
|
2015-10-31 20:37:20 +00:00
|
|
|
while (y >= 0 && (bits - begin) <= cjSizeImage)
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
{
|
2018-12-25 09:04:21 +00:00
|
|
|
length = *bits++;
|
2010-10-24 23:40:23 +00:00
|
|
|
if (length)
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
{
|
2010-10-24 23:40:23 +00:00
|
|
|
c = *bits++;
|
2018-12-25 09:04:21 +00:00
|
|
|
for (i = 0; i < length; i++)
|
2010-10-24 23:40:23 +00:00
|
|
|
{
|
|
|
|
if (x >= width) break;
|
2018-12-25 09:04:21 +00:00
|
|
|
temp = UncompressedBits + (height - y) * Delta;
|
|
|
|
if (is4bpp)
|
|
|
|
{
|
|
|
|
temp += x / 2;
|
|
|
|
if (i & 1)
|
|
|
|
c2 = c & 0x0F;
|
|
|
|
else
|
|
|
|
c2 = c >> 4;
|
|
|
|
if (x & 1)
|
|
|
|
*temp |= c2;
|
|
|
|
else
|
|
|
|
*temp |= c2 << 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
temp += x;
|
|
|
|
*temp = c;
|
|
|
|
}
|
2010-10-24 23:40:23 +00:00
|
|
|
x++;
|
|
|
|
}
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
}
|
2010-10-24 23:40:23 +00:00
|
|
|
else
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
{
|
2010-10-24 23:40:23 +00:00
|
|
|
length = *bits++;
|
|
|
|
switch (length)
|
|
|
|
{
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
case RLE_EOL:
|
|
|
|
x = 0;
|
|
|
|
y--;
|
|
|
|
break;
|
|
|
|
case RLE_END:
|
2010-10-24 23:40:23 +00:00
|
|
|
_SEH2_YIELD(return);
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
case RLE_DELTA:
|
2018-12-25 09:04:21 +00:00
|
|
|
x += *bits++;
|
|
|
|
y -= *bits++;
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
2018-12-25 09:04:21 +00:00
|
|
|
for (i = 0; i < length; i++)
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
{
|
2018-12-25 09:04:21 +00:00
|
|
|
if (!(is4bpp && i & 1))
|
|
|
|
c = *bits++;
|
|
|
|
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
if (x < width)
|
|
|
|
{
|
2018-12-25 09:04:21 +00:00
|
|
|
temp = UncompressedBits + (height - y) * Delta;
|
|
|
|
if (is4bpp)
|
|
|
|
{
|
|
|
|
temp += x / 2;
|
|
|
|
if (i & 1)
|
|
|
|
c2 = c & 0x0F;
|
|
|
|
else
|
|
|
|
c2 = c >> 4;
|
|
|
|
if (x & 1)
|
|
|
|
*temp |= c2;
|
|
|
|
else
|
|
|
|
*temp |= c2 << 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
temp += x;
|
|
|
|
*temp = c;
|
|
|
|
}
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
x++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((bits - begin) & 1)
|
|
|
|
{
|
|
|
|
bits++;
|
|
|
|
}
|
2010-10-24 23:40:23 +00:00
|
|
|
}
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-10-24 23:40:23 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
{
|
2010-10-24 23:40:23 +00:00
|
|
|
DPRINT1("Decoding error\n");
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
}
|
2010-10-24 23:40:23 +00:00
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
return;
|
[WIN32K]
- Move RLE specific code to it's own file (rlecomp.c)
- Relace BitsPerFormat function with an array of UCHARs
- Rewrite surface creation. Surfaces are now allocated from one central function SURFACE_AllocSurface, which sets the size, iType, iUniq, the handle and the default palette.
- Implement SURFACE_vSetDefaultPalette, which sets the default RGB palette, based on bit depth.
- Implement SURFACE_bSetBitmapBits, wich sets cjBits, pvBits, pvScan0 and lDelta and allocates memory if neccessary.
- Use these functions for EngCreateBitmap, EngCreateDeviceBitmap, EngCreateDeviceSurface and IntCreateBitmap
svn path=/branches/reactos-yarotows/; revision=47612
2010-06-06 07:02:15 +00:00
|
|
|
}
|