ReactOS 0.4.16-dev-2116-g5a43991
common.c File Reference
#include "precomp.h"
Include dependency graph for common.c:

Go to the source code of this file.

Functions

static VOID BitBlt (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
 
static VOID RleBitBlt (_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ PUCHAR Buffer)
 
VOID NTAPI VidBufferToScreenBlt (_In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ ULONG Delta)
 
VOID NTAPI VidBitBlt (_In_ PUCHAR Buffer, _In_ ULONG Left, _In_ ULONG Top)
 

Variables

const RGBQUAD VidpDefaultPalette [BV_MAX_COLORS]
 

Function Documentation

◆ BitBlt()

static VOID BitBlt ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_reads_bytes_(Delta *Height) PUCHAR  Buffer,
_In_ ULONG  BitsPerPixel,
_In_ ULONG  Delta 
)
static

Definition at line 42 of file common.c.

50{
51 ULONG X, Y, Pixel;
54 const ULONG Bottom = Top + Height;
55 const ULONG Right = Left + Width;
56
57 /* Check if the buffer isn't 4bpp */
58 if (BitsPerPixel != 4)
59 {
60 /* FIXME: TODO */
61 DbgPrint("Unhandled BitBlt\n"
62 "%lux%lu @ (%lu|%lu)\n"
63 "Bits Per Pixel %lu\n"
64 "Buffer: %p. Delta: %lu\n",
65 Width,
66 Height,
67 Left,
68 Top,
69 BitsPerPixel,
70 Buffer,
71 Delta);
72 return;
73 }
74
76
77 /* 4bpp blitting */
78 for (Y = Top; Y < Bottom; ++Y)
79 {
81
82 for (X = Left, Pixel = 0;
83 X < Right;
84 ++X, ++Pixel)
85 {
86 if (Pixel % 2 == 0)
87 {
88 /* Extract colors at every two pixels */
90
91 SetPixel(X, Y, Colors >> 4);
92 }
93 else
94 {
95 SetPixel(X, Y, Colors & 0x0F);
96 }
97 }
98
99 Buffer += Delta;
100 }
101}
Colors
Definition: ansiprsr.h:4
VOID SetPixel(_In_ ULONG Left, _In_ ULONG Top, _In_ UCHAR Color)
Definition: bootvid.c:52
#define PrepareForSetPixel()
Definition: arm.h:21
static LPHIST_ENTRY Bottom
Definition: history.c:54
static LPHIST_ENTRY Top
Definition: history.c:53
Definition: bufpool.h:45
#define Y(I)
#define DbgPrint
Definition: hal.h:12
#define X(b, s)
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by CMenuDeskBar::_OnPaint(), AboutDlgProc(), add_ruler_units(), alpha_blend_image(), ANIMATE_PaintFrame(), ANIMATE_TransparentBlt(), BitBltFromClipboard(), CDimmedWindow::Blt(), BltCard(), C1_DrawLabel(), C1_InvertButton(), C1_OnDraw(), CDimmedWindow::Capture(), CaptureScreen(), CardBlt(), CC_PaintColorGraph(), CC_PaintCross(), check_BitBlt_pixel(), check_bits(), cicChangeBitmapColor(), cicConvertBlackBKGBitmap(), cicCreateDisabledBitmap(), cicCreateMaskBmp(), cicCreateShadowMaskBmp(), cicDrawMaskBmpOnDC(), cicMirrorBitmap(), ClippedBitBlt(), ClockWndProc(), ColorKeyedMaskBlt(), COMCTL32_EnsureBitmapSize(), ConvertBitmapTo32Bpp(), CCicLibMenuItem::CreateBitmap(), CreateMDIMenuBitmap(), CreateStarBitmap(), ddraw_surface_update_frontbuffer(), device_load_logo(), RdpClientUI::Display_DrawGlyph(), RdpClientUI::Display_MemBlt(), RdpClientUI::Display_ScreenBlt(), RdpClientUI::Display_TriBlt(), RdpClientUI::DisplayWindowProc(), DoBlt(), CCanvasWindow::DoDraw(), Draw(), draw_graphics(), DrawCard(), DrawFace(), DrawGlyph(), DrawHorzCardStrip(), DrawIconOnOwnerDrawnButtons(), CUIFButton::DrawIconProc(), PictureButton::DrawItem(), DrawLeds(), DrawMine(), DrawProc(), DrawTileBitmap(), DrawVertCardStrip(), dup_bitmap(), EndBufferedPaint(), GeneralPageProc(), get_bitmap_info(), GetDiaogTextureBrush(), getSubImage(), Ghost_OnDraw(), GraphCtrl_AddPoint(), GraphCtrl_WndProc(), HEADER_DrawItem(), HelDdSurfBlt(), HelDdSurfLock(), HelDdSurfUnlock(), HEXEDIT_WM_PAINT(), HLPFILE_RtfAddTransparentBitmap(), ImageList_Add(), ImageList_AddMasked(), ImageList_BeginDrag(), ImageList_Copy(), imagelist_copy_images(), ImageList_DragMove(), ImageList_DragShowNolock(), ImageList_DrawIndirect(), ImageList_Duplicate(), ImageList_GetIcon(), IMAGELIST_InternalExpandBitmaps(), ImageList_Merge(), ImageList_Replace(), ImageList_ReplaceIcon(), Imm32DrawBitmap(), IntDrawState(), IntGetWindowBitmap(), IntGrayString(), LISTVIEW_Refresh(), LoadCardBitmapsFromLibrary(), MainWndProc(), mi_paint_rect(), CardRegion::MoveDragCardTo(), mstsc_WndProc(), NT5_DrawBaseBackground(), NT5_DrawLogoffIcon(), OLEPictureImpl_LoadWICSource(), CMainWindow::OnCommand(), OnDrawItem(), OnPaint(), CFullscreenWindow::OnPaint(), CMiniatureWindow::OnPaint(), CPaletteWindow::OnPaint(), CDownloaderProgress::OnPaint(), CBrandBand::OnPaint(), StartMenuRoot::Paint(), PaintBanner(), CardWindow::PaintCardRgn(), PaintCells(), PAINTING_DrawStateJam(), CAppScrnshotPreview::PaintOnDC(), PlayEnhMetaFileRecord(), PlayMetaFileRecord(), ProgressDlg::ProcessWindowMessage(), PROPSHEET_Paint(), putSubImage(), RosImageProc(), Run(), ScreenSaverProc(), show_image(), SIC_OverlayShortcutImage(), SkewDIB(), START_TEST(), StatusDialogProc(), StatusMessageWindowProc(), swapchain_gdi_frontbuffer_updated(), T1_DrawLabels(), T1_OnDraw(), test_32bit_ddb(), test_bitmap_colors(), test_clipping(), Test_CreateDIBitmap_CBM_CREATDIB(), test_D3DKMTCreateDCFromMemory(), test_dibsections(), test_emf_BitBlt(), test_printer_dc(), Test_Rectangle(), Test_SrcMono1(), ThemeEndBufferedPaint(), TOOLBAR_DrawMasked(), TRACKBAR_Refresh(), UXTHEME_SizedBlt(), VidBitBlt(), VidBufferToScreenBlt(), WinGBitBlt(), WndProc(), and ZoomWnd_OnDraw().

◆ RleBitBlt()

static VOID RleBitBlt ( _In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_ PUCHAR  Buffer 
)
static

Definition at line 104 of file common.c.

110{
111 ULONG YDelta;
112 ULONG x;
113 ULONG RleValue, NewRleValue;
114 ULONG Color, Color2;
115 ULONG i, j;
116 ULONG Code;
117
119
120 /* Set Y height and current X value and start loop */
121 YDelta = Top + Height - 1;
122 x = Left;
123 for (;;)
124 {
125 /* Get the current value and advance in the buffer */
126 RleValue = *Buffer;
127 Buffer++;
128 if (RleValue)
129 {
130 /* Check if we've gone past the edge */
131 if ((x + RleValue) > (Width + Left))
132 {
133 /* Fixup the pixel value */
134 RleValue = Left - x + Width;
135 }
136
137 /* Get the new value */
138 NewRleValue = *Buffer;
139
140 /* Get the two colors */
141 Color = NewRleValue >> 4;
142 Color2 = NewRleValue & 0xF;
143
144 /* Increase buffer position */
145 Buffer++;
146
147 /* Check if we need to do a fill */
148 if (Color == Color2)
149 {
150 /* Do a fill and continue the loop */
151 RleValue += x;
152 VidSolidColorFill(x, YDelta, RleValue - 1, YDelta, (UCHAR)Color);
153 x = RleValue;
154 continue;
155 }
156
157 /* Check if the pixel value is 1 or below */
158 if (RleValue > 1)
159 {
160 /* Set loop variables */
161 for (i = (RleValue - 2) / 2 + 1; i > 0; --i)
162 {
163 /* Set the pixels */
164 SetPixel(x, YDelta, (UCHAR)Color);
165 x++;
166 SetPixel(x, YDelta, (UCHAR)Color2);
167 x++;
168
169 /* Decrease pixel value */
170 RleValue -= 2;
171 }
172 }
173
174 /* Check if there is any value at all */
175 if (RleValue)
176 {
177 /* Set the pixel and increase position */
178 SetPixel(x, YDelta, (UCHAR)Color);
179 x++;
180 }
181
182 /* Start over */
183 continue;
184 }
185
186 /* Get the current pixel value */
187 RleValue = *Buffer;
188 Code = RleValue;
189 switch (Code)
190 {
191 /* Case 0 */
192 case 0:
193 {
194 /* Set new x value, decrease distance and restart */
195 x = Left;
196 YDelta--;
197 Buffer++;
198 continue;
199 }
200
201 /* Case 1 */
202 case 1:
203 {
204 /* Done */
205 return;
206 }
207
208 /* Case 2 */
209 case 2:
210 {
211 /* Set new x value, decrease distance and restart */
212 Buffer++;
213 x += *Buffer;
214 Buffer++;
215 YDelta -= *Buffer;
216 Buffer++;
217 continue;
218 }
219
220 /* Other values */
221 default:
222 {
223 Buffer++;
224 break;
225 }
226 }
227
228 /* Check if we've gone past the edge */
229 if ((x + RleValue) > (Width + Left))
230 {
231 /* Set fixed up loop count */
232 i = RleValue - Left - Width + x;
233
234 /* Fixup pixel value */
235 RleValue -= i;
236 }
237 else
238 {
239 /* Clear loop count */
240 i = 0;
241 }
242
243 /* Check the value now */
244 if (RleValue > 1)
245 {
246 /* Set loop variables */
247 for (j = (RleValue - 2) / 2 + 1; j > 0; --j)
248 {
249 /* Get the new value */
250 NewRleValue = *Buffer;
251
252 /* Get the two colors */
253 Color = NewRleValue >> 4;
254 Color2 = NewRleValue & 0xF;
255
256 /* Increase buffer position */
257 Buffer++;
258
259 /* Set the pixels */
260 SetPixel(x, YDelta, (UCHAR)Color);
261 x++;
262 SetPixel(x, YDelta, (UCHAR)Color2);
263 x++;
264
265 /* Decrease pixel value */
266 RleValue -= 2;
267 }
268 }
269
270 /* Check if there is any value at all */
271 if (RleValue)
272 {
273 /* Set the pixel and increase position */
274 Color = *Buffer >> 4;
275 Buffer++;
276 SetPixel(x, YDelta, (UCHAR)Color);
277 x++;
278 i--;
279 }
280
281 /* Check loop count now */
282 if ((LONG)i > 0)
283 {
284 /* Decrease it */
285 i--;
286
287 /* Set new position */
288 Buffer = Buffer + (i / 2) + 1;
289 }
290
291 /* Check if we need to increase the buffer */
292 if ((ULONG_PTR)Buffer & 1) Buffer++;
293 }
294}
VOID NTAPI VidSolidColorFill(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Right, _In_ ULONG Bottom, _In_ UCHAR Color)
Definition: bootvid.c:298
#define Code
Definition: deflate.h:80
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
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
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 GLint GLint j
Definition: glfuncs.h:250
long LONG
Definition: pedump.c:60
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ UCHAR _In_ UCHAR _In_ ULONG Code
Definition: wdfdevice.h:1707

Referenced by VidBitBlt().

◆ VidBitBlt()

VOID NTAPI VidBitBlt ( _In_ PUCHAR  Buffer,
_In_ ULONG  Left,
_In_ ULONG  Top 
)

Definition at line 318 of file common.c.

322{
324 LONG Delta;
325 PUCHAR BitmapOffset;
326 ULONG PaletteCount;
327
328 /* Get the Bitmap Header */
330
331 /* Initialize the palette */
332 PaletteCount = BitmapInfoHeader->biClrUsed ?
335 PaletteCount);
336
337 /* Make sure we can support this bitmap */
339
340 /*
341 * Calculate the delta and align it on 32-bytes, then calculate
342 * the actual start of the bitmap data.
343 */
345 Delta >>= 3;
346 Delta &= ~3;
347 BitmapOffset = Buffer + sizeof(BITMAPINFOHEADER) + PaletteCount * sizeof(ULONG);
348
349 /* Check the compression of the bitmap */
351 {
352 /* Make sure we have a width and a height */
354 {
355 /* We can use RLE Bit Blt */
356 RleBitBlt(Left,
357 Top,
360 BitmapOffset);
361 }
362 }
363 else
364 {
365 /* Check if the height is negative */
366 if (BitmapInfoHeader->biHeight < 0)
367 {
368 /* Make it positive in the header */
370 }
371 else
372 {
373 /* Update buffer offset */
374 BitmapOffset += ((BitmapInfoHeader->biHeight - 1) * Delta);
375 Delta *= -1;
376 }
377
378 /* Make sure we have a width and a height */
380 {
381 /* Do the BitBlt */
382 BitBlt(Left,
383 Top,
386 BitmapOffset,
388 Delta);
389 }
390 }
391}
VOID InitPaletteWithTable(_In_reads_(Count) const ULONG *Table, _In_ ULONG Count)
Definition: bootvid.c:220
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:42
static VOID RleBitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_ PUCHAR Buffer)
Definition: common.c:104
#define BI_RLE4
Definition: precomp.h:56
struct tagBITMAPINFOHEADER * PBITMAPINFOHEADER
#define ASSERT(a)
Definition: mode.c:44
#define BV_MAX_COLORS
Definition: display.h:32
DWORD biCompression
Definition: amvideo.idl:35
uint32_t * PULONG
Definition: typedefs.h:59

Referenced by BootLogoFadeIn(), and InbvBitBlt().

◆ VidBufferToScreenBlt()

VOID NTAPI VidBufferToScreenBlt ( _In_reads_bytes_(Delta *Height) PUCHAR  Buffer,
_In_ ULONG  Left,
_In_ ULONG  Top,
_In_ ULONG  Width,
_In_ ULONG  Height,
_In_ ULONG  Delta 
)

Definition at line 300 of file common.c.

307{
308 /* Make sure we have a width and height */
309 if (!Width || !Height)
310 return;
311
312 /* Call the helper function */
313 BitBlt(Left, Top, Width, Height, Buffer, 4, Delta);
314}

Referenced by InbvBufferToScreenBlt(), and InbvRotationThread().

Variable Documentation

◆ VidpDefaultPalette

const RGBQUAD VidpDefaultPalette[BV_MAX_COLORS]
Initial value:
=
{
RGB( 0, 0, 0),
RGB(128, 0, 0),
RGB( 0, 128, 0),
RGB(128, 128, 0),
RGB( 0, 0, 128),
RGB(128, 0, 128),
RGB( 0, 128, 128),
RGB(128, 128, 128),
RGB(192, 192, 192),
RGB(255, 0, 0),
RGB( 0, 255, 0),
RGB(255, 255, 0),
RGB( 0, 0, 255),
RGB(255, 0, 255),
RGB( 0, 255, 255),
RGB(255, 255, 255),
}
#define RGB(r, g, b)
Definition: precomp.h:78

Definition at line 19 of file common.c.

Referenced by InitPaletteWithTable(), and VidpBuildColor().