From 55a36ac1e01205f2cd461cd2f89d92e3b64cddd2 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Mon, 4 Mar 2013 15:49:02 -0800 Subject: recovery: change font for menus to be an image Instead of representing the font used for menus and log messages in the recovery binary, load it from a resource PNG image. This allows different devices to substitute their own font images. Change-Id: Ib36b86db3d01298aa7ae2b62a26ca29e6ef18014 --- minui/resources.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'minui/resources.c') 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)) { -- cgit v1.2.3