/** @file\r
+Implementation for EFI_HII_IMAGE_PROTOCOL.\r
+\r
\r
Copyright (c) 2007 - 2008, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- Image.c\r
-\r
-Abstract:\r
+**/\r
\r
- Implementation for EFI_HII_IMAGE_PROTOCOL.\r
\r
-Revision History\r
+#include "HiiDatabase.h"\r
\r
+#ifndef _DISABLE_UNUSED_HII_PROTOCOLS_\r
\r
-**/\r
+/**\r
+ Get the imageid of last image block: EFI_HII_IIBT_END_BLOCK when input\r
+ ImageId is zero, otherwise return the address of the\r
+ corresponding image block with identifier specified by ImageId.\r
\r
+ This is a internal function.\r
\r
-#include "HiiDatabase.h"\r
+ @param ImageBlock Points to the beginning of a series of image blocks stored in order.\r
+ @param ImageId If input ImageId is 0, output the image id of the EFI_HII_IIBT_END_BLOCK;\r
+ else use this id to find its corresponding image block address.\r
\r
-#ifndef DISABLE_UNUSED_HII_PROTOCOLS\r
+ @return The image block address when input ImageId is not zero; otherwise return NULL.\r
\r
-STATIC\r
+**/\r
UINT8*\r
GetImageIdOrAddress (\r
IN UINT8 *ImageBlock,\r
IN OUT EFI_IMAGE_ID *ImageId\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Get the imageid of last image block: EFI_HII_IIBT_END_BLOCK when input\r
- ImageId is zero, otherwise return the address of the\r
- corresponding image block with identifier specified by ImageId.\r
-\r
- Arguments:\r
- ImageBlock - Points to the beginning of a series of image blocks stored in order.\r
- ImageId - If input ImageId is 0, output the image id of the EFI_HII_IIBT_END_BLOCK;\r
- else use this id to find its corresponding image block address.\r
-\r
- Returns:\r
- The image block address when input ImageId is not zero; otherwise return NULL.\r
-\r
---*/\r
{\r
EFI_IMAGE_ID ImageIdCurrent;\r
UINT8 *ImageBlockHdr;\r
/**\r
Convert pixels from EFI_GRAPHICS_OUTPUT_BLT_PIXEL to EFI_HII_RGB_PIXEL style.\r
\r
+ This is a internal function.\r
+\r
+\r
@param BitMapOut Pixels in EFI_HII_RGB_PIXEL format.\r
@param BitMapIn Pixels in EFI_GRAPHICS_OUTPUT_BLT_PIXEL format.\r
@param PixelNum The number of pixels to be converted.\r
\r
\r
**/\r
-STATIC\r
VOID\r
CopyGopToRgbPixel (\r
OUT EFI_HII_RGB_PIXEL *BitMapOut,\r
/**\r
Convert pixels from EFI_HII_RGB_PIXEL to EFI_GRAPHICS_OUTPUT_BLT_PIXEL style.\r
\r
+ This is a internal function.\r
+\r
+\r
@param BitMapOut Pixels in EFI_GRAPHICS_OUTPUT_BLT_PIXEL format.\r
@param BitMapIn Pixels in EFI_HII_RGB_PIXEL format.\r
@param PixelNum The number of pixels to be converted.\r
\r
\r
**/\r
-STATIC\r
VOID\r
CopyRgbToGopPixel (\r
OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapOut,\r
/**\r
Output pixels in "1 bit per pixel" format to an image.\r
\r
+ This is a internal function.\r
+\r
+\r
@param Image Points to the image which will store the pixels.\r
@param Data Stores the value of output pixels, 0 or 1.\r
@param PaletteInfo PaletteInfo which stores the color of the output\r
\r
\r
**/\r
-STATIC\r
VOID\r
Output1bitPixel (\r
IN OUT EFI_IMAGE_INPUT *Image,\r
IN EFI_HII_IMAGE_PALETTE_INFO *PaletteInfo\r
)\r
{\r
- UINT16 X;\r
- UINT16 Y;\r
+ UINT16 Xpos;\r
+ UINT16 Ypos;\r
UINTN OffsetY;\r
UINT8 Index;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;\r
//\r
// Convert the pixel from one bit to corresponding color.\r
//\r
- for (Y = 0; Y < Image->Height; Y++) {\r
- OffsetY = BITMAP_LEN_1_BIT (Image->Width, Y);\r
+ for (Ypos = 0; Ypos < Image->Height; Ypos++) {\r
+ OffsetY = BITMAP_LEN_1_BIT (Image->Width, Ypos);\r
//\r
// All bits in these bytes are meaningful\r
//\r
- for (X = 0; X < Image->Width / 8; X++) {\r
- Byte = *(Data + OffsetY + X);\r
+ for (Xpos = 0; Xpos < Image->Width / 8; Xpos++) {\r
+ Byte = *(Data + OffsetY + Xpos);\r
for (Index = 0; Index < 8; Index++) {\r
if ((Byte & (1 << Index)) != 0) {\r
- BitMapPtr[Y * Image->Width + X * 8 + (8 - Index - 1)] = PaletteValue[1];\r
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + (8 - Index - 1)] = PaletteValue[1];\r
} else {\r
- BitMapPtr[Y * Image->Width + X * 8 + (8 - Index - 1)] = PaletteValue[0];\r
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + (8 - Index - 1)] = PaletteValue[0];\r
}\r
}\r
}\r
//\r
// Padding bits in this byte should be ignored.\r
//\r
- Byte = *(Data + OffsetY + X);\r
+ Byte = *(Data + OffsetY + Xpos);\r
for (Index = 0; Index < Image->Width % 8; Index++) {\r
if ((Byte & (1 << (8 - Index - 1))) != 0) {\r
- BitMapPtr[Y * Image->Width + X * 8 + Index] = PaletteValue[1];\r
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + Index] = PaletteValue[1];\r
} else {\r
- BitMapPtr[Y * Image->Width + X * 8 + Index] = PaletteValue[0];\r
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + Index] = PaletteValue[0];\r
}\r
}\r
}\r
/**\r
Output pixels in "4 bit per pixel" format to an image.\r
\r
+ This is a internal function.\r
+\r
+\r
@param Image Points to the image which will store the pixels.\r
@param Data Stores the value of output pixels, 0 ~ 15.\r
- @param PaletteInfo PaletteInfo which stores the color of the output\r
+ @param[in] PaletteInfo PaletteInfo which stores the color of the output\r
pixels. Each entry corresponds to a color within\r
[0, 15].\r
\r
\r
**/\r
-STATIC\r
VOID\r
Output4bitPixel (\r
IN OUT EFI_IMAGE_INPUT *Image,\r
IN EFI_HII_IMAGE_PALETTE_INFO *PaletteInfo\r
)\r
{\r
- UINT16 X;\r
- UINT16 Y;\r
+ UINT16 Xpos;\r
+ UINT16 Ypos;\r
UINTN OffsetY;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[16];\r
//\r
// Convert the pixel from 4 bit to corresponding color.\r
//\r
- for (Y = 0; Y < Image->Height; Y++) {\r
- OffsetY = BITMAP_LEN_4_BIT (Image->Width, Y);\r
+ for (Ypos = 0; Ypos < Image->Height; Ypos++) {\r
+ OffsetY = BITMAP_LEN_4_BIT (Image->Width, Ypos);\r
//\r
// All bits in these bytes are meaningful\r
//\r
- for (X = 0; X < Image->Width / 2; X++) {\r
- Byte = *(Data + OffsetY + X);\r
- BitMapPtr[Y * Image->Width + X * 2] = PaletteValue[Byte >> 4];\r
- BitMapPtr[Y * Image->Width + X * 2 + 1] = PaletteValue[Byte & 0x0F];\r
+ for (Xpos = 0; Xpos < Image->Width / 2; Xpos++) {\r
+ Byte = *(Data + OffsetY + Xpos);\r
+ BitMapPtr[Ypos * Image->Width + Xpos * 2] = PaletteValue[Byte >> 4];\r
+ BitMapPtr[Ypos * Image->Width + Xpos * 2 + 1] = PaletteValue[Byte & 0x0F];\r
}\r
\r
if (Image->Width % 2 != 0) {\r
//\r
// Padding bits in this byte should be ignored.\r
//\r
- Byte = *(Data + OffsetY + X);\r
- BitMapPtr[Y * Image->Width + X * 2] = PaletteValue[Byte >> 4];\r
+ Byte = *(Data + OffsetY + Xpos);\r
+ BitMapPtr[Ypos * Image->Width + Xpos * 2] = PaletteValue[Byte >> 4];\r
}\r
}\r
}\r
/**\r
Output pixels in "8 bit per pixel" format to an image.\r
\r
+ This is a internal function.\r
+\r
+\r
@param Image Points to the image which will store the pixels.\r
@param Data Stores the value of output pixels, 0 ~ 255.\r
- @param PaletteInfo PaletteInfo which stores the color of the output\r
+ @param[in] PaletteInfo PaletteInfo which stores the color of the output\r
pixels. Each entry corresponds to a color within\r
[0, 255].\r
\r
\r
**/\r
-STATIC\r
VOID\r
Output8bitPixel (\r
IN OUT EFI_IMAGE_INPUT *Image,\r
IN EFI_HII_IMAGE_PALETTE_INFO *PaletteInfo\r
)\r
{\r
- UINT16 X;\r
- UINT16 Y;\r
+ UINT16 Xpos;\r
+ UINT16 Ypos;\r
UINTN OffsetY;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[256];\r
//\r
// Convert the pixel from 8 bits to corresponding color.\r
//\r
- for (Y = 0; Y < Image->Height; Y++) {\r
- OffsetY = BITMAP_LEN_8_BIT (Image->Width, Y);\r
+ for (Ypos = 0; Ypos < Image->Height; Ypos++) {\r
+ OffsetY = BITMAP_LEN_8_BIT (Image->Width, Ypos);\r
//\r
// All bits are meaningful since the bitmap is 8 bits per pixel.\r
//\r
- for (X = 0; X < Image->Width; X++) {\r
- Byte = *(Data + OffsetY + X);\r
- BitMapPtr[OffsetY + X] = PaletteValue[Byte];\r
+ for (Xpos = 0; Xpos < Image->Width; Xpos++) {\r
+ Byte = *(Data + OffsetY + Xpos);\r
+ BitMapPtr[OffsetY + Xpos] = PaletteValue[Byte];\r
}\r
}\r
\r
/**\r
Output pixels in "24 bit per pixel" format to an image.\r
\r
+ This is a internal function.\r
+\r
+\r
@param Image Points to the image which will store the pixels.\r
@param Data Stores the color of output pixels, allowing 16.8\r
millions colors.\r
\r
\r
**/\r
-STATIC\r
VOID\r
Output24bitPixel (\r
IN OUT EFI_IMAGE_INPUT *Image,\r
IN EFI_HII_RGB_PIXEL *Data\r
)\r
{\r
- UINT16 Y;\r
+ UINT16 Ypos;\r
UINTN OffsetY;\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;\r
\r
\r
BitMapPtr = Image->Bitmap;\r
\r
- for (Y = 0; Y < Image->Height; Y++) {\r
- OffsetY = BITMAP_LEN_8_BIT (Image->Width, Y);\r
+ for (Ypos = 0; Ypos < Image->Height; Ypos++) {\r
+ OffsetY = BITMAP_LEN_8_BIT (Image->Width, Ypos);\r
CopyRgbToGopPixel (&BitMapPtr[OffsetY], &Data[OffsetY], Image->Width);\r
}\r
\r
/**\r
Convert the image from EFI_IMAGE_INPUT to EFI_IMAGE_OUTPUT format.\r
\r
+ This is a internal function.\r
+\r
+\r
@param BltBuffer Buffer points to bitmap data of incoming image.\r
+ @param BltX Specifies the offset from the left and top edge of\r
+ the output image of the first pixel in the image.\r
@param BltY Specifies the offset from the left and top edge of\r
the output image of the first pixel in the image.\r
@param Width Width of the incoming image, in pixels.\r
@retval EFI_INVALID_PARAMETER Any incoming parameter is invalid.\r
\r
**/\r
-STATIC\r
EFI_STATUS\r
ImageToBlt (\r
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,\r
)\r
{\r
EFI_IMAGE_OUTPUT *ImageOut;\r
- UINTN X;\r
- UINTN Y;\r
+ UINTN Xpos;\r
+ UINTN Ypos;\r
UINTN OffsetY1; // src buffer\r
UINTN OffsetY2; // dest buffer\r
EFI_GRAPHICS_OUTPUT_BLT_PIXEL SrcPixel;\r
\r
ZeroMem (&ZeroPixel, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));\r
\r
- for (Y = 0; Y < Height; Y++) {\r
- OffsetY1 = Width * Y;\r
- OffsetY2 = ImageOut->Width * (BltY + Y);\r
- for (X = 0; X < Width; X++) {\r
- SrcPixel = BltBuffer[OffsetY1 + X];\r
+ for (Ypos = 0; Ypos < Height; Ypos++) {\r
+ OffsetY1 = Width * Ypos;\r
+ OffsetY2 = ImageOut->Width * (BltY + Ypos);\r
+ for (Xpos = 0; Xpos < Width; Xpos++) {\r
+ SrcPixel = BltBuffer[OffsetY1 + Xpos];\r
if (Transparent) {\r
if (CompareMem (&SrcPixel, &ZeroPixel, 3) != 0) {\r
- ImageOut->Image.Bitmap[OffsetY2 + BltX + X] = SrcPixel;\r
+ ImageOut->Image.Bitmap[OffsetY2 + BltX + Xpos] = SrcPixel;\r
}\r
} else {\r
- ImageOut->Image.Bitmap[OffsetY2 + BltX + X] = SrcPixel;\r
+ ImageOut->Image.Bitmap[OffsetY2 + BltX + Xpos] = SrcPixel;\r
}\r
}\r
}\r
@param ImageId The image's id,, which is unique within\r
PackageList.\r
@param Image Points to the image.\r
- @param ImageSize On entry, points to the size of the buffer pointed\r
- to by Image, in bytes. On return, points to the\r
- length of the image, in bytes.\r
\r
@retval EFI_SUCCESS The new image was returned successfully.\r
@retval EFI_NOT_FOUND The image specified by ImageId is not in the\r
will be allocated to hold the generated image and\r
the pointer updated on exit. It is the caller's\r
responsibility to free this buffer.\r
+ @param BltX Specifies the offset from the left and top edge of\r
+ the output image of the first pixel in the image.\r
@param BltY Specifies the offset from the left and top edge of\r
the output image of the first pixel in the image.\r
\r
UINTN BufferLen;\r
UINTN Width;\r
UINTN Height;\r
- UINTN X;\r
- UINTN Y;\r
+ UINTN Xpos;\r
+ UINTN Ypos;\r
UINTN OffsetY1;\r
UINTN OffsetY2;\r
EFI_FONT_DISPLAY_INFO *FontInfo;\r
if (Width == ImageIn->Width && Height == ImageIn->Height) {\r
CopyMem (BltBuffer, ImageIn->Bitmap, BufferLen);\r
} else {\r
- for (Y = 0; Y < Height; Y++) {\r
- OffsetY1 = ImageIn->Width * Y;\r
- OffsetY2 = Width * Y;\r
- for (X = 0; X < Width; X++) {\r
- BltBuffer[OffsetY2 + X] = ImageIn->Bitmap[OffsetY1 + X];\r
+ for (Ypos = 0; Ypos < Height; Ypos++) {\r
+ OffsetY1 = ImageIn->Width * Ypos;\r
+ OffsetY2 = Width * Ypos;\r
+ for (Xpos = 0; Xpos < Width; Xpos++) {\r
+ BltBuffer[OffsetY2 + Xpos] = ImageIn->Bitmap[OffsetY1 + Xpos];\r
}\r
}\r
}\r
allocated to hold the generated image and the\r
pointer updated on exit. It is the caller's\r
responsibility to free this buffer.\r
+ @param BltX Specifies the offset from the left and top edge of\r
+ the output image of the first pixel in the image.\r
@param BltY Specifies the offset from the left and top edge of\r
the output image of the first pixel in the image.\r
\r