Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/Libeg/egpng.c

  • Property svn:executable set to *
1/*
2 * egpng.c
3 * Loading function for PNG images (extension for libeg)
4 *
5 * Copyright (c) 2012-2013 Cadet-Petit Armel
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the
18 * distribution.
19 *
20 * * Neither the name of Cadet-Petit Armel nor the names of the
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#include "libegint.h"
38#include <pexpert/i386/modules.h>
39#include "PngFile.h"
40
41EG_IMAGE * egDecodePNG(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN IconSize, IN BOOLEAN WantAlpha)
42{
43 EG_IMAGE *NewImage;
44UINT8*imagedata;
45intwidth,height;
46intpiChannels;
47VOID*BkgColor = NULL;
48BOOLEANret ;
49
50if (FileData == NULL)
51return NULL;
52
53width = 0;
54height = 0;
55piChannels = 0;
56imagedata = NULL;
57BkgColor = NULL;
58
59 ret = PngLoadData(FileData, FileDataLength, &width,
60 &height, &imagedata, &piChannels, BkgColor);
61
62if (ret == FALSE)
63{
64return NULL;
65}
66
67 if (width && height && imagedata && piChannels)
68{
69NewImage = egCreateImageFromData((EG_PIXEL*)imagedata, width, height, (piChannels == 4) ? TRUE : FALSE, FALSE);
70
71if (NewImage) {
72egFlipRB(NewImage);
73return NewImage;
74}
75
76}
77
78return NULL;
79}

Archive Download this file

Revision: 2182