[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 */
|
|
|
|
};
|
|
|
|
|
2015-10-31 20:37:20 +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
|
|
|
{
|
2010-10-24 23:40:23 +00:00
|
|
|
INT x = 0;
|
|
|
|
INT y = Size.cy - 1;
|
|
|
|
INT c;
|
|
|
|
INT length;
|
|
|
|
INT width;
|
2015-10-31 20:37:20 +00:00
|
|
|
INT 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;
|
2010-10-24 23:40:23 +00:00
|
|
|
INT shift = 0;
|
|
|
|
|
2012-05-01 14:57:23 +00:00
|
|
|
if ((Format == BMF_4RLE) || (Format == BMF_4BPP))
|
2010-10-24 23:40:23 +00:00
|
|
|
shift = 1;
|
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;
|
|
|
|
|
|
|
|
width = ((Size.cx + shift) >> shift);
|
|
|
|
|
|
|
|
_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
|
|
|
{
|
2010-10-24 23:40:23 +00:00
|
|
|
length = (*bits++) >> shift;
|
|
|
|
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++;
|
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
if (x >= width) break;
|
|
|
|
temp = UncompressedBits + (((height - y) * Delta) + x);
|
|
|
|
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
|
|
|
}
|
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:
|
2010-10-24 23:40:23 +00:00
|
|
|
x += (*bits++) >> shift;
|
|
|
|
y -= (*bits++) >> shift;
|
[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:
|
2010-10-24 23:40:23 +00:00
|
|
|
length = length >> shift;
|
[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
|
|
|
while (length--)
|
|
|
|
{
|
|
|
|
c = *bits++;
|
|
|
|
if (x < width)
|
|
|
|
{
|
|
|
|
temp = UncompressedBits + (((height - y) * Delta) + x);
|
|
|
|
x++;
|
|
|
|
*temp = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|