2 This library provides image decoding service by managing the different
3 image decoding libraries.
5 Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Protocol/GraphicsOutput.h>
18 #include <Library/ImageDecoderLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/DebugLib.h>
27 } IMAGE_DECODER_ENTRY
;
28 #define IMAGE_DECODER_ENTRY_SIGNATURE SIGNATURE_32 ('i', 'm', 'g', 'd')
29 #define IMAGE_DECODER_ENTRY_FROM_LINK(Link) \
30 CR (Link, IMAGE_DECODER_ENTRY, Link, IMAGE_DECODER_ENTRY_SIGNATURE)
32 LIST_ENTRY mImageDecoderLibDecoders
= INITIALIZE_LIST_HEAD_VARIABLE (mImageDecoderLibDecoders
);
35 Convert a graphics image to a callee allocated GOP blt buffer.
37 @param ImageFormat Format of the image file.
38 @param Image Pointer to image file.
39 @param ImageSize Number of bytes in Image.
40 @param GopBlt Buffer containing GOP version of Image.
41 @param GopBltSize Size of GopBlt in bytes.
42 @param PixelWidth Width of GopBlt/Image in pixels.
43 @param PixelHeight Height of GopBlt/Image in pixels.
45 @retval EFI_SUCCESS GopBlt and GopBltSize are returned.
46 @retval EFI_INVALID_PARAMETER GopBlt or GopBltSize is NULL.
47 @retval EFI_INVALID_PARAMETER Image is NULL or ImageSize is 0.
48 @retval EFI_UNSUPPORTED Image is not supported.
49 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate.
55 IN IMAGE_FORMAT ImageFormat
,
58 OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL
**GopBlt
,
59 OUT UINTN
*GopBltSize
,
60 OUT UINTN
*PixelWidth
,
61 OUT UINTN
*PixelHeight
64 IMAGE_DECODER_ENTRY
*Entry
;
68 if ((GopBlt
== NULL
) || (GopBltSize
== NULL
)) {
69 return EFI_INVALID_PARAMETER
;
72 if ((Image
== NULL
) || (ImageSize
== 0)) {
73 return EFI_INVALID_PARAMETER
;
76 for ( Link
= GetFirstNode (&mImageDecoderLibDecoders
)
77 ; !IsNull (&mImageDecoderLibDecoders
, Link
)
78 ; Link
= GetNextNode (&mImageDecoderLibDecoders
, Link
)
80 Entry
= IMAGE_DECODER_ENTRY_FROM_LINK (Link
);
81 Status
= Entry
->Decoder (ImageFormat
, Image
, ImageSize
, GopBlt
, GopBltSize
, PixelWidth
, PixelHeight
);
82 if (!EFI_ERROR (Status
)) {
87 if (IsNull (&mImageDecoderLibDecoders
, Link
)) {
88 return EFI_UNSUPPORTED
;
95 Register an image decoder.
97 @param Decoder An image decoder.
99 @retval EFI_SUCCESS The decoder was successfully registered.
100 @retval EFI_OUT_OF_RESOURCES No enough resource to register the decoder.
105 RegisterImageDecoder (
106 IN DECODE_IMAGE Decoder
109 IMAGE_DECODER_ENTRY
*Entry
;
111 Entry
= AllocatePool (sizeof (IMAGE_DECODER_ENTRY
));
113 return EFI_OUT_OF_RESOURCES
;
116 Entry
->Signature
= IMAGE_DECODER_ENTRY_SIGNATURE
;
117 Entry
->Decoder
= Decoder
;
118 InsertTailList (&mImageDecoderLibDecoders
, &Entry
->Link
);