summaryrefslogtreecommitdiffstats
path: root/minui
diff options
context:
space:
mode:
Diffstat (limited to 'minui')
-rw-r--r--minui/Android.mk4
-rw-r--r--minui/graphics.c28
-rw-r--r--minui/resources.c11
3 files changed, 31 insertions, 12 deletions
diff --git a/minui/Android.mk b/minui/Android.mk
index 91dd939f6..7ded5d3d0 100644
--- a/minui/Android.mk
+++ b/minui/Android.mk
@@ -9,4 +9,8 @@ LOCAL_C_INCLUDES +=\
LOCAL_MODULE := libminui
+ifneq ($(RECOVERY_24_BIT),)
+ LOCAL_CFLAGS += -DRECOVERY_24_BIT
+endif
+
include $(BUILD_STATIC_LIBRARY)
diff --git a/minui/graphics.c b/minui/graphics.c
index 4127c400a..42c85e777 100644
--- a/minui/graphics.c
+++ b/minui/graphics.c
@@ -32,6 +32,14 @@
#include "font_10x18.h"
#include "minui.h"
+#ifdef RECOVERY_24_BIT
+#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGBX_8888
+#define PIXEL_SIZE 4
+#else
+#define PIXEL_FORMAT GGL_PIXEL_FORMAT_RGB_565
+#define PIXEL_SIZE 2
+#endif
+
typedef struct {
GGLSurface texture;
unsigned cwidth;
@@ -87,8 +95,8 @@ static int get_framebuffer(GGLSurface *fb)
fb->height = vi.yres;
fb->stride = vi.xres;
fb->data = bits;
- fb->format = GGL_PIXEL_FORMAT_RGB_565;
- memset(fb->data, 0, vi.yres * vi.xres * 2);
+ fb->format = PIXEL_FORMAT;
+ memset(fb->data, 0, vi.yres * vi.xres * PIXEL_SIZE);
fb++;
@@ -96,9 +104,9 @@ static int get_framebuffer(GGLSurface *fb)
fb->width = vi.xres;
fb->height = vi.yres;
fb->stride = vi.xres;
- fb->data = (void*) (((unsigned) bits) + vi.yres * vi.xres * 2);
- fb->format = GGL_PIXEL_FORMAT_RGB_565;
- memset(fb->data, 0, vi.yres * vi.xres * 2);
+ fb->data = (void*) (((unsigned) bits) + vi.yres * vi.xres * PIXEL_SIZE);
+ fb->format = PIXEL_FORMAT;
+ memset(fb->data, 0, vi.yres * vi.xres * PIXEL_SIZE);
return fd;
}
@@ -108,16 +116,16 @@ static void get_memory_surface(GGLSurface* ms) {
ms->width = vi.xres;
ms->height = vi.yres;
ms->stride = vi.xres;
- ms->data = malloc(vi.xres * vi.yres * 2);
- ms->format = GGL_PIXEL_FORMAT_RGB_565;
+ ms->data = malloc(vi.xres * vi.yres * PIXEL_SIZE);
+ ms->format = PIXEL_FORMAT;
}
static void set_active_framebuffer(unsigned n)
{
if (n > 1) return;
- vi.yres_virtual = vi.yres * 2;
+ vi.yres_virtual = vi.yres * PIXEL_SIZE;
vi.yoffset = n * vi.yres;
- vi.bits_per_pixel = 16;
+ vi.bits_per_pixel = PIXEL_SIZE * 8;
if (ioctl(gr_fb_fd, FBIOPUT_VSCREENINFO, &vi) < 0) {
perror("active fb swap failed");
}
@@ -133,7 +141,7 @@ void gr_flip(void)
/* copy data from the in-memory surface to the buffer we're about
* to make active. */
memcpy(gr_framebuffer[gr_active_fb].data, gr_mem_surface.data,
- vi.xres * vi.yres * 2);
+ vi.xres * vi.yres * PIXEL_SIZE);
/* inform the display driver */
set_active_framebuffer(gr_active_fb);
diff --git a/minui/resources.c b/minui/resources.c
index 3d2c727fb..b437a87cb 100644
--- a/minui/resources.c
+++ b/minui/resources.c
@@ -49,6 +49,8 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
+ *pSurface = NULL;
+
snprintf(resPath, sizeof(resPath)-1, "/res/images/%s.png", name);
resPath[sizeof(resPath)-1] = '\0';
FILE* fp = fopen(resPath, "rb");
@@ -119,12 +121,17 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
surface->format = (channels == 3) ?
GGL_PIXEL_FORMAT_RGBX_8888 : GGL_PIXEL_FORMAT_RGBA_8888;
+ int alpha = 0;
if (color_type == PNG_COLOR_TYPE_PALETTE) {
- png_set_palette_to_rgb(png_ptr);
+ png_set_palette_to_rgb(png_ptr);
+ }
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
+ png_set_tRNS_to_alpha(png_ptr);
+ alpha = 1;
}
int y;
- if (channels == 3) {
+ if (channels == 3 || (channels == 1 && !alpha)) {
for (y = 0; y < height; ++y) {
unsigned char* pRow = pData + y * stride;
png_read_row(png_ptr, pRow, NULL);