]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
MdeModulePkg: Add BmpSupportLib class and instance
[mirror_edk2.git] / MdeModulePkg / Library / BaseBmpSupportLib / BmpSupportLib.c
1 /** @file
2
3 Provides services to convert a BMP graphics image to a GOP BLT buffer and
4 from a GOP BLT buffer to a BMP graphics image.
5
6 Caution: This module requires additional review when modified.
7 This module processes external input - BMP image.
8 This external input must be validated carefully to avoid security issue such
9 as buffer overflow, integer overflow.
10
11 TranslateBmpToGopBlt() receives untrusted input and performs basic validation.
12
13 Copyright (c) 2016-2017, Microsoft Corporation
14 Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
15
16 All rights reserved.
17 Redistribution and use in source and binary forms, with or without
18 modification, are permitted provided that the following conditions are met:
19 1. Redistributions of source code must retain the above copyright notice,
20 this list of conditions and the following disclaimer.
21 2. Redistributions in binary form must reproduce the above copyright notice,
22 this list of conditions and the following disclaimer in the documentation
23 and/or other materials provided with the distribution.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
36 **/
37
38 #include <PiDxe.h>
39 #include <Library/DebugLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/MemoryAllocationLib.h>
42 #include <Library/SafeIntLib.h>
43 #include <IndustryStandard/Bmp.h>
44
45 #include <Library/BmpSupportLib.h>
46
47 //
48 // BMP Image header for an uncompressed 24-bit per pixel BMP image.
49 //
50 const BMP_IMAGE_HEADER mBmpImageHeaderTemplate = {
51 'B', // CharB
52 'M', // CharM
53 0, // Size will be updated at runtime
54 {0, 0}, // Reserved
55 sizeof (BMP_IMAGE_HEADER), // ImageOffset
56 sizeof (BMP_IMAGE_HEADER) - OFFSET_OF (BMP_IMAGE_HEADER, HeaderSize), // HeaderSize
57 0, // PixelWidth will be updated at runtime
58 0, // PixelHeight will be updated at runtime
59 1, // Planes
60 24, // BitPerPixel
61 0, // CompressionType
62 0, // ImageSize will be updated at runtime
63 0, // XPixelsPerMeter
64 0, // YPixelsPerMeter
65 0, // NumberOfColors
66 0 // ImportantColors
67 };
68
69 /**
70 Translate a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
71 is passed in a GopBlt buffer will be allocated by this routine using
72 EFI_BOOT_SERVICES.AllocatePool(). If a GopBlt buffer is passed in it will be
73 used if it is big enough.
74
75 @param[in] BmpImage Pointer to BMP file.
76 @param[in] BmpImageSize Number of bytes in BmpImage.
77 @param[in, out] GopBlt Buffer containing GOP version of BmpImage.
78 @param[in, out] GopBltSize Size of GopBlt in bytes.
79 @param[out] PixelHeight Height of GopBlt/BmpImage in pixels.
80 @param[out] PixelWidth Width of GopBlt/BmpImage in pixels.
81
82 @retval RETURN_SUCCESS GopBlt and GopBltSize are returned.
83 @retval RETURN_INVALID_PARAMETER BmpImage is NULL.
84 @retval RETURN_INVALID_PARAMETER GopBlt is NULL.
85 @retval RETURN_INVALID_PARAMETER GopBltSize is NULL.
86 @retval RETURN_INVALID_PARAMETER PixelHeight is NULL.
87 @retval RETURN_INVALID_PARAMETER PixelWidth is NULL.
88 @retval RETURN_UNSUPPORTED BmpImage is not a valid *.BMP image.
89 @retval RETURN_BUFFER_TOO_SMALL The passed in GopBlt buffer is not big
90 enough. The required size is returned in
91 GopBltSize.
92 @retval RETURN_OUT_OF_RESOURCES The GopBlt buffer could not be allocated.
93
94 **/
95 RETURN_STATUS
96 EFIAPI
97 TranslateBmpToGopBlt (
98 IN VOID *BmpImage,
99 IN UINTN BmpImageSize,
100 IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL **GopBlt,
101 IN OUT UINTN *GopBltSize,
102 OUT UINTN *PixelHeight,
103 OUT UINTN *PixelWidth
104 )
105 {
106 UINT8 *Image;
107 UINT8 *ImageHeader;
108 BMP_IMAGE_HEADER *BmpHeader;
109 BMP_COLOR_MAP *BmpColorMap;
110 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
111 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
112 UINT32 BltBufferSize;
113 UINTN Index;
114 UINTN Height;
115 UINTN Width;
116 UINTN ImageIndex;
117 UINT32 DataSizePerLine;
118 BOOLEAN IsAllocated;
119 UINT32 ColorMapNum;
120 RETURN_STATUS Status;
121 UINT32 DataSize;
122 UINT32 Temp;
123
124 if (BmpImage == NULL || GopBlt == NULL || GopBltSize == NULL) {
125 return RETURN_INVALID_PARAMETER;
126 }
127 if (PixelHeight == NULL || PixelWidth == NULL) {
128 return RETURN_INVALID_PARAMETER;
129 }
130
131 if (BmpImageSize < sizeof (BMP_IMAGE_HEADER)) {
132 DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: BmpImageSize too small\n"));
133 return RETURN_UNSUPPORTED;
134 }
135
136 BmpHeader = (BMP_IMAGE_HEADER *)BmpImage;
137
138 if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
139 DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: BmpHeader->Char fields incorrect\n"));
140 return RETURN_UNSUPPORTED;
141 }
142
143 //
144 // Doesn't support compress.
145 //
146 if (BmpHeader->CompressionType != 0) {
147 DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: Compression Type unsupported.\n"));
148 return RETURN_UNSUPPORTED;
149 }
150
151 //
152 // Only support BITMAPINFOHEADER format.
153 // BITMAPFILEHEADER + BITMAPINFOHEADER = BMP_IMAGE_HEADER
154 //
155 if (BmpHeader->HeaderSize != sizeof (BMP_IMAGE_HEADER) - OFFSET_OF (BMP_IMAGE_HEADER, HeaderSize)) {
156 DEBUG ((
157 DEBUG_ERROR,
158 "TranslateBmpToGopBlt: BmpHeader->Headership is not as expected. Headersize is 0x%x\n",
159 BmpHeader->HeaderSize
160 ));
161 return RETURN_UNSUPPORTED;
162 }
163
164 //
165 // The data size in each line must be 4 byte alignment.
166 //
167 Status = SafeUint32Mult (
168 BmpHeader->PixelWidth,
169 BmpHeader->BitPerPixel,
170 &DataSizePerLine
171 );
172 if (EFI_ERROR (Status)) {
173 DEBUG ((
174 DEBUG_ERROR,
175 "TranslateBmpToGopBlt: invalid BmpImage... PixelWidth:0x%x BitPerPixel:0x%x\n",
176 BmpHeader->PixelWidth,
177 BmpHeader->BitPerPixel
178 ));
179 return RETURN_UNSUPPORTED;
180 }
181
182 Status = SafeUint32Add (DataSizePerLine, 31, &DataSizePerLine);
183 if (EFI_ERROR (Status)) {
184 DEBUG ((
185 DEBUG_ERROR,
186 "TranslateBmpToGopBlt: invalid BmpImage... DataSizePerLine:0x%x\n",
187 DataSizePerLine
188 ));
189
190 return RETURN_UNSUPPORTED;
191 }
192
193 DataSizePerLine = (DataSizePerLine >> 3) &(~0x3);
194 Status = SafeUint32Mult (
195 DataSizePerLine,
196 BmpHeader->PixelHeight,
197 &BltBufferSize
198 );
199
200 if (EFI_ERROR (Status)) {
201 DEBUG ((
202 DEBUG_ERROR,
203 "TranslateBmpToGopBlt: invalid BmpImage... DataSizePerLine:0x%x PixelHeight:0x%x\n",
204 DataSizePerLine, BmpHeader->PixelHeight
205 ));
206
207 return RETURN_UNSUPPORTED;
208 }
209
210 Status = SafeUint32Mult (
211 BmpHeader->PixelHeight,
212 DataSizePerLine,
213 &DataSize
214 );
215
216 if (EFI_ERROR (Status)) {
217 DEBUG ((
218 DEBUG_ERROR,
219 "TranslateBmpToGopBlt: invalid BmpImage... PixelHeight:0x%x DataSizePerLine:0x%x\n",
220 BmpHeader->PixelHeight, DataSizePerLine
221 ));
222
223 return RETURN_UNSUPPORTED;
224 }
225
226 if ((BmpHeader->Size != BmpImageSize) ||
227 (BmpHeader->Size < BmpHeader->ImageOffset) ||
228 (BmpHeader->Size - BmpHeader->ImageOffset != DataSize)) {
229
230 DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n"));
231 DEBUG ((DEBUG_ERROR, " BmpHeader->Size: 0x%x\n", BmpHeader->Size));
232 DEBUG ((DEBUG_ERROR, " BmpHeader->ImageOffset: 0x%x\n", BmpHeader->ImageOffset));
233 DEBUG ((DEBUG_ERROR, " BmpImageSize: 0x%lx\n", (UINTN)BmpImageSize));
234 DEBUG ((DEBUG_ERROR, " DataSize: 0x%lx\n", (UINTN)DataSize));
235
236 return RETURN_UNSUPPORTED;
237 }
238
239 //
240 // Calculate Color Map offset in the image.
241 //
242 Image = BmpImage;
243 BmpColorMap = (BMP_COLOR_MAP *)(Image + sizeof (BMP_IMAGE_HEADER));
244 if (BmpHeader->ImageOffset < sizeof (BMP_IMAGE_HEADER)) {
245 return RETURN_UNSUPPORTED;
246 }
247
248 if (BmpHeader->ImageOffset > sizeof (BMP_IMAGE_HEADER)) {
249 switch (BmpHeader->BitPerPixel) {
250 case 1:
251 ColorMapNum = 2;
252 break;
253 case 4:
254 ColorMapNum = 16;
255 break;
256 case 8:
257 ColorMapNum = 256;
258 break;
259 default:
260 ColorMapNum = 0;
261 break;
262 }
263 //
264 // BMP file may has padding data between the bmp header section and the
265 // bmp data section.
266 //
267 if (BmpHeader->ImageOffset - sizeof (BMP_IMAGE_HEADER) < sizeof (BMP_COLOR_MAP) * ColorMapNum) {
268 return RETURN_UNSUPPORTED;
269 }
270 }
271
272 //
273 // Calculate graphics image data address in the image
274 //
275 Image = ((UINT8 *)BmpImage) + BmpHeader->ImageOffset;
276 ImageHeader = Image;
277
278 //
279 // Calculate the BltBuffer needed size.
280 //
281 Status = SafeUint32Mult (
282 BmpHeader->PixelWidth,
283 BmpHeader->PixelHeight,
284 &BltBufferSize
285 );
286
287 if (EFI_ERROR (Status)) {
288 DEBUG ((
289 DEBUG_ERROR,
290 "TranslateBmpToGopBlt: invalid BltBuffer needed size... PixelWidth:0x%x PixelHeight:0x%x\n",
291 BltBufferSize
292 ));
293
294 return RETURN_UNSUPPORTED;
295 }
296
297 Temp = BltBufferSize;
298 Status = SafeUint32Mult (
299 BltBufferSize,
300 sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL),
301 &BltBufferSize
302 );
303
304 if (EFI_ERROR (Status)) {
305 DEBUG ((
306 DEBUG_ERROR,
307 "TranslateBmpToGopBlt: invalid BltBuffer needed size... BltBufferSize:0x%lx struct size:0x%x\n",
308 Temp, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
309 ));
310
311 return RETURN_UNSUPPORTED;
312 }
313
314 IsAllocated = FALSE;
315 if (*GopBlt == NULL) {
316 //
317 // GopBlt is not allocated by caller.
318 //
319 DEBUG ((DEBUG_INFO, "Bmp Support: Allocating 0x%X bytes of memory\n", BltBufferSize));
320 *GopBltSize = (UINTN)BltBufferSize;
321 *GopBlt = AllocatePool (*GopBltSize);
322 IsAllocated = TRUE;
323 if (*GopBlt == NULL) {
324 return RETURN_OUT_OF_RESOURCES;
325 }
326 } else {
327 //
328 // GopBlt has been allocated by caller.
329 //
330 if (*GopBltSize < (UINTN)BltBufferSize) {
331 *GopBltSize = (UINTN)BltBufferSize;
332 return RETURN_BUFFER_TOO_SMALL;
333 }
334 }
335
336 *PixelWidth = BmpHeader->PixelWidth;
337 *PixelHeight = BmpHeader->PixelHeight;
338 DEBUG ((DEBUG_INFO, "BmpHeader->ImageOffset 0x%X\n", BmpHeader->ImageOffset));
339 DEBUG ((DEBUG_INFO, "BmpHeader->PixelWidth 0x%X\n", BmpHeader->PixelWidth));
340 DEBUG ((DEBUG_INFO, "BmpHeader->PixelHeight 0x%X\n", BmpHeader->PixelHeight));
341 DEBUG ((DEBUG_INFO, "BmpHeader->BitPerPixel 0x%X\n", BmpHeader->BitPerPixel));
342 DEBUG ((DEBUG_INFO, "BmpHeader->ImageSize 0x%X\n", BmpHeader->ImageSize));
343 DEBUG ((DEBUG_INFO, "BmpHeader->HeaderSize 0x%X\n", BmpHeader->HeaderSize));
344 DEBUG ((DEBUG_INFO, "BmpHeader->Size 0x%X\n", BmpHeader->Size));
345
346 //
347 // Translate image from BMP to Blt buffer format
348 //
349 BltBuffer = *GopBlt;
350 for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {
351 Blt = &BltBuffer[ (BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
352 for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {
353 switch (BmpHeader->BitPerPixel) {
354 case 1:
355 //
356 // Translate 1-bit (2 colors) BMP to 24-bit color
357 //
358 for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {
359 Blt->Red = BmpColorMap[ ((*Image) >> (7 - Index)) & 0x1].Red;
360 Blt->Green = BmpColorMap[ ((*Image) >> (7 - Index)) & 0x1].Green;
361 Blt->Blue = BmpColorMap[ ((*Image) >> (7 - Index)) & 0x1].Blue;
362 Blt++;
363 Width++;
364 }
365
366 Blt--;
367 Width--;
368 break;
369
370 case 4:
371 //
372 // Translate 4-bit (16 colors) BMP Palette to 24-bit color
373 //
374 Index = (*Image) >> 4;
375 Blt->Red = BmpColorMap[Index].Red;
376 Blt->Green = BmpColorMap[Index].Green;
377 Blt->Blue = BmpColorMap[Index].Blue;
378 if (Width < (BmpHeader->PixelWidth - 1)) {
379 Blt++;
380 Width++;
381 Index = (*Image) & 0x0f;
382 Blt->Red = BmpColorMap[Index].Red;
383 Blt->Green = BmpColorMap[Index].Green;
384 Blt->Blue = BmpColorMap[Index].Blue;
385 }
386 break;
387
388 case 8:
389 //
390 // Translate 8-bit (256 colors) BMP Palette to 24-bit color
391 //
392 Blt->Red = BmpColorMap[*Image].Red;
393 Blt->Green = BmpColorMap[*Image].Green;
394 Blt->Blue = BmpColorMap[*Image].Blue;
395 break;
396
397 case 24:
398 //
399 // It is 24-bit BMP.
400 //
401 Blt->Blue = *Image++;
402 Blt->Green = *Image++;
403 Blt->Red = *Image;
404 break;
405
406 case 32:
407 //
408 //Conver 32 bit to 24bit bmp - just ignore the final byte of each pixel
409 Blt->Blue = *Image++;
410 Blt->Green = *Image++;
411 Blt->Red = *Image++;
412 break;
413
414 default:
415 //
416 // Other bit format BMP is not supported.
417 //
418 if (IsAllocated) {
419 FreePool (*GopBlt);
420 *GopBlt = NULL;
421 }
422 DEBUG ((DEBUG_ERROR, "Bmp Bit format not supported. 0x%X\n", BmpHeader->BitPerPixel));
423 return RETURN_UNSUPPORTED;
424 break;
425 };
426
427 }
428
429 ImageIndex = (UINTN)(Image - ImageHeader);
430 if ((ImageIndex % 4) != 0) {
431 //
432 // Bmp Image starts each row on a 32-bit boundary!
433 //
434 Image = Image + (4 - (ImageIndex % 4));
435 }
436 }
437
438 return RETURN_SUCCESS;
439 }
440
441 /**
442 Translate a GOP blt buffer to an uncompressed 24-bit per pixel BMP graphics
443 image. If a NULL BmpImage is passed in a BmpImage buffer will be allocated by
444 this routine using EFI_BOOT_SERVICES.AllocatePool(). If a BmpImage buffer is
445 passed in it will be used if it is big enough.
446
447 @param [in] GopBlt Pointer to GOP blt buffer.
448 @param [in] PixelHeight Height of GopBlt/BmpImage in pixels.
449 @param [in] PixelWidth Width of GopBlt/BmpImage in pixels.
450 @param [in, out] BmpImage Buffer containing BMP version of GopBlt.
451 @param [in, out] BmpImageSize Size of BmpImage in bytes.
452
453 @retval RETURN_SUCCESS BmpImage and BmpImageSize are returned.
454 @retval RETURN_INVALID_PARAMETER GopBlt is NULL.
455 @retval RETURN_INVALID_PARAMETER BmpImage is NULL.
456 @retval RETURN_INVALID_PARAMETER BmpImageSize is NULL.
457 @retval RETURN_UNSUPPORTED GopBlt cannot be converted to a *.BMP image.
458 @retval RETURN_BUFFER_TOO_SMALL The passed in BmpImage buffer is not big
459 enough. The required size is returned in
460 BmpImageSize.
461 @retval RETURN_OUT_OF_RESOURCES The BmpImage buffer could not be allocated.
462
463 **/
464 RETURN_STATUS
465 EFIAPI
466 TranslateGopBltToBmp (
467 IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *GopBlt,
468 IN UINT32 PixelHeight,
469 IN UINT32 PixelWidth,
470 IN OUT VOID **BmpImage,
471 IN OUT UINT32 *BmpImageSize
472 )
473 {
474 RETURN_STATUS Status;
475 UINT32 PaddingSize;
476 UINT32 BmpSize;
477 BMP_IMAGE_HEADER *BmpImageHeader;
478 UINT8 *Image;
479 UINTN Col;
480 UINTN Row;
481 EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltPixel;
482
483 if (GopBlt == NULL || BmpImage == NULL || BmpImageSize == NULL) {
484 return RETURN_INVALID_PARAMETER;
485 }
486
487 //
488 // Allocate memory for BMP file.
489 //
490 PaddingSize = PixelWidth & 0x3;
491
492 //
493 // First check PixelWidth * 3 + PaddingSize doesn't overflow
494 //
495 Status = SafeUint32Mult (PixelWidth, 3, &BmpSize);
496 if (EFI_ERROR (Status)) {
497 DEBUG ((
498 DEBUG_ERROR,
499 "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWidth:0x%x\n",
500 PixelHeight,
501 PixelWidth
502 ));
503 return RETURN_UNSUPPORTED;
504 }
505 Status = SafeUint32Add (BmpSize, PaddingSize, &BmpSize);
506 if (EFI_ERROR (Status)) {
507 DEBUG ((
508 DEBUG_ERROR,
509 "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWidth:0x%x\n",
510 PixelHeight,
511 PixelWidth
512 ));
513 return RETURN_UNSUPPORTED;
514 }
515
516 //
517 // Second check (mLogoWidth * 3 + PaddingSize) * mLogoHeight + sizeof (BMP_IMAGE_HEADER) doesn't overflow
518 //
519 Status = SafeUint32Mult (BmpSize, PixelHeight, &BmpSize);
520 if (EFI_ERROR (Status)) {
521 DEBUG ((
522 DEBUG_ERROR,
523 "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWidth:0x%x\n",
524 PixelHeight,
525 PixelWidth
526 ));
527 return RETURN_UNSUPPORTED;
528 }
529 Status = SafeUint32Add (BmpSize, sizeof (BMP_IMAGE_HEADER), &BmpSize);
530 if (EFI_ERROR (Status)) {
531 DEBUG ((
532 DEBUG_ERROR,
533 "TranslateGopBltToBmp: GopBlt is too large. PixelHeight:0x%x PixelWidth:0x%x\n",
534 PixelHeight,
535 PixelWidth
536 ));
537 return RETURN_UNSUPPORTED;
538 }
539
540 //
541 // The image should be stored in EfiBootServicesData, allowing the system to
542 // reclaim the memory
543 //
544 if (*BmpImage == NULL) {
545 *BmpImage = AllocateZeroPool (BmpSize);
546 if (*BmpImage == NULL) {
547 return EFI_OUT_OF_RESOURCES;
548 }
549 *BmpImageSize = BmpSize;
550 } else if (*BmpImageSize < BmpSize) {
551 *BmpImageSize = BmpSize;
552 return RETURN_BUFFER_TOO_SMALL;
553 }
554
555 BmpImageHeader = (BMP_IMAGE_HEADER *)*BmpImage;
556 CopyMem (BmpImageHeader, &mBmpImageHeaderTemplate, sizeof (BMP_IMAGE_HEADER));
557 BmpImageHeader->Size = *BmpImageSize;
558 BmpImageHeader->ImageSize = *BmpImageSize - sizeof (BMP_IMAGE_HEADER);
559 BmpImageHeader->PixelWidth = PixelWidth;
560 BmpImageHeader->PixelHeight = PixelHeight;
561
562 //
563 // Convert BLT buffer to BMP file.
564 //
565 Image = (UINT8 *)BmpImageHeader + sizeof (BMP_IMAGE_HEADER);
566 for (Row = 0; Row < PixelHeight; Row++) {
567 BltPixel = &GopBlt[(PixelHeight - Row - 1) * PixelWidth];
568
569 for (Col = 0; Col < PixelWidth; Col++) {
570 *Image++ = BltPixel->Blue;
571 *Image++ = BltPixel->Green;
572 *Image++ = BltPixel->Red;
573 BltPixel++;
574 }
575
576 //
577 // Padding for 4 byte alignment.
578 //
579 Image += PaddingSize;
580 }
581
582 return RETURN_SUCCESS;
583 }