summaryrefslogtreecommitdiffstats
path: root/minui/resources.c
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2013-03-05 00:49:02 +0100
committerDoug Zongker <dougz@android.com>2013-03-05 01:37:44 +0100
commit55a36ac1e01205f2cd461cd2f89d92e3b64cddd2 (patch)
treef51ded2ae67f844bfb39457b58ae2dff9f83805b /minui/resources.c
parentam ec838b88: Merge "minadbd: remove unnecessary header files." (diff)
downloadandroid_bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar
android_bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar.gz
android_bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar.bz2
android_bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar.lz
android_bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar.xz
android_bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.tar.zst
android_bootable_recovery-55a36ac1e01205f2cd461cd2f89d92e3b64cddd2.zip
Diffstat (limited to 'minui/resources.c')
-rw-r--r--minui/resources.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/minui/resources.c b/minui/resources.c
index 065f4317e..72f39fbaa 100644
--- a/minui/resources.c
+++ b/minui/resources.c
@@ -93,22 +93,23 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
png_set_sig_bytes(png_ptr, sizeof(header));
png_read_info(png_ptr, info_ptr);
- size_t width = info_ptr->width;
- size_t height = info_ptr->height;
- size_t stride = 4 * width;
- size_t pixelSize = stride * height;
-
int color_type = info_ptr->color_type;
int bit_depth = info_ptr->bit_depth;
int channels = info_ptr->channels;
if (!(bit_depth == 8 &&
((channels == 3 && color_type == PNG_COLOR_TYPE_RGB) ||
(channels == 4 && color_type == PNG_COLOR_TYPE_RGBA) ||
- (channels == 1 && color_type == PNG_COLOR_TYPE_PALETTE)))) {
+ (channels == 1 && (color_type == PNG_COLOR_TYPE_PALETTE ||
+ color_type == PNG_COLOR_TYPE_GRAY))))) {
return -7;
goto exit;
}
+ size_t width = info_ptr->width;
+ size_t height = info_ptr->height;
+ size_t stride = (color_type == PNG_COLOR_TYPE_GRAY ? 1 : 4) * width;
+ size_t pixelSize = stride * height;
+
surface = malloc(sizeof(GGLSurface) + pixelSize);
if (surface == NULL) {
result = -8;
@@ -120,8 +121,8 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
surface->height = height;
surface->stride = width; /* Yes, pixels, not bytes */
surface->data = pData;
- surface->format = (channels == 3) ?
- GGL_PIXEL_FORMAT_RGBX_8888 : GGL_PIXEL_FORMAT_RGBA_8888;
+ surface->format = (channels == 3) ? GGL_PIXEL_FORMAT_RGBX_8888 :
+ ((color_type == PNG_COLOR_TYPE_PALETTE ? GGL_PIXEL_FORMAT_RGBA_8888 : GGL_PIXEL_FORMAT_L_8));
int alpha = 0;
if (color_type == PNG_COLOR_TYPE_PALETTE) {
@@ -131,6 +132,9 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
png_set_tRNS_to_alpha(png_ptr);
alpha = 1;
}
+ if (color_type == PNG_COLOR_TYPE_GRAY) {
+ alpha = 1;
+ }
unsigned int y;
if (channels == 3 || (channels == 1 && !alpha)) {