ReactOS 0.4.15-dev-7842-g558ab78
rlecomp.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: RLE compression
5 * FILE: win32ss/gdi/eng/rlecomp.c
6 * PROGRAMER: Jason Filby
7 */
8
9#include <win32k.h>
10
11#define NDEBUG
12#include <debug.h>
13
15{
16 RLE_EOL = 0, /* End of line */
17 RLE_END = 1, /* End of bitmap */
18 RLE_DELTA = 2 /* Delta */
19};
20
21VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits,
22 LONG Delta, ULONG Format, ULONG cjSizeImage)
23{
24 INT x = 0, y = Size.cy - 1;
25 INT i, c, c2, length;
26 INT width = Size.cx, height = y;
27 BYTE *begin = CompressedBits;
28 BYTE *bits = CompressedBits;
29 BYTE *temp;
30 BOOL is4bpp = FALSE;
31
32 if ((Format == BMF_4RLE) || (Format == BMF_4BPP))
33 is4bpp = TRUE;
34 else if ((Format != BMF_8RLE) && (Format != BMF_8BPP))
35 return;
36
38 {
39 while (y >= 0 && (bits - begin) <= cjSizeImage)
40 {
41 length = *bits++;
42 if (length)
43 {
44 c = *bits++;
45 for (i = 0; i < length; i++)
46 {
47 if (x >= width) break;
48 temp = UncompressedBits + (height - y) * Delta;
49 if (is4bpp)
50 {
51 temp += x / 2;
52 if (i & 1)
53 c2 = c & 0x0F;
54 else
55 c2 = c >> 4;
56 if (x & 1)
57 *temp |= c2;
58 else
59 *temp |= c2 << 4;
60 }
61 else
62 {
63 temp += x;
64 *temp = c;
65 }
66 x++;
67 }
68 }
69 else
70 {
71 length = *bits++;
72 switch (length)
73 {
74 case RLE_EOL:
75 x = 0;
76 y--;
77 break;
78 case RLE_END:
79 _SEH2_YIELD(return);
80 case RLE_DELTA:
81 x += *bits++;
82 y -= *bits++;
83 break;
84 default:
85 for (i = 0; i < length; i++)
86 {
87 if (!(is4bpp && i & 1))
88 c = *bits++;
89
90 if (x < width)
91 {
92 temp = UncompressedBits + (height - y) * Delta;
93 if (is4bpp)
94 {
95 temp += x / 2;
96 if (i & 1)
97 c2 = c & 0x0F;
98 else
99 c2 = c >> 4;
100 if (x & 1)
101 *temp |= c2;
102 else
103 *temp |= c2 << 4;
104 }
105 else
106 {
107 temp += x;
108 *temp = c;
109 }
110 x++;
111 }
112 }
113 if ((bits - begin) & 1)
114 {
115 bits++;
116 }
117 }
118 }
119 }
120 }
122 {
123 DPRINT1("Decoding error\n");
124 }
125 _SEH2_END;
126
127 return;
128}
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
const GLubyte * c
Definition: glext.h:8905
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define c
Definition: ke_i.h:80
long LONG
Definition: pedump.c:60
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
VOID DecompressBitmap(SIZEL Size, BYTE *CompressedBits, BYTE *UncompressedBits, LONG Delta, ULONG Format, ULONG cjSizeImage)
Definition: rlecomp.c:21
Rle_EscapeCodes
Definition: rlecomp.c:15
@ RLE_END
Definition: rlecomp.c:17
@ RLE_EOL
Definition: rlecomp.c:16
@ RLE_DELTA
Definition: rlecomp.c:18
static calc_node_t temp
Definition: rpn_ieee.c:38
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define BMF_8BPP
Definition: winddi.h:357
#define BMF_8RLE
Definition: winddi.h:362
#define BMF_4RLE
Definition: winddi.h:361
#define BMF_4BPP
Definition: winddi.h:356
static ULONG Delta
Definition: xboxvideo.c:33
static clock_t begin
Definition: xmllint.c:458
unsigned char BYTE
Definition: xxhash.c:193