summaryrefslogtreecommitdiffstats
path: root/minuitwrp/graphics_utils.c
diff options
context:
space:
mode:
authorxiaolu <server@163.com>2015-05-23 06:11:09 +0200
committerDees Troy <dees_troy@teamw.in>2015-06-17 23:26:24 +0200
commit26ffa869d085caa103140df87ff8efa12a592724 (patch)
tree1068d282e7d317212bceae5e9cc20b2b1e0ea3fb /minuitwrp/graphics_utils.c
parentpartition: recreate tw_internal_path(/data/media/0), after wipe media from data or format /data. (diff)
downloadandroid_bootable_recovery-26ffa869d085caa103140df87ff8efa12a592724.tar
android_bootable_recovery-26ffa869d085caa103140df87ff8efa12a592724.tar.gz
android_bootable_recovery-26ffa869d085caa103140df87ff8efa12a592724.tar.bz2
android_bootable_recovery-26ffa869d085caa103140df87ff8efa12a592724.tar.lz
android_bootable_recovery-26ffa869d085caa103140df87ff8efa12a592724.tar.xz
android_bootable_recovery-26ffa869d085caa103140df87ff8efa12a592724.tar.zst
android_bootable_recovery-26ffa869d085caa103140df87ff8efa12a592724.zip
Diffstat (limited to 'minuitwrp/graphics_utils.c')
-rw-r--r--minuitwrp/graphics_utils.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/minuitwrp/graphics_utils.c b/minuitwrp/graphics_utils.c
index 6083c7599..ea1182dd9 100644
--- a/minuitwrp/graphics_utils.c
+++ b/minuitwrp/graphics_utils.c
@@ -28,12 +28,12 @@ GGLSurface gr_mem_surface;
int gr_save_screenshot(const char *dest)
{
uint32_t y, stride_bytes;
- int res = -1;
+ volatile int res = -1;
GGLContext *gl = NULL;
GGLSurface surface;
uint8_t * volatile img_data = NULL;
uint8_t *ptr;
- FILE *fp = NULL;
+ FILE * volatile fp = NULL;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
@@ -41,18 +41,21 @@ int gr_save_screenshot(const char *dest)
if(!fp)
goto exit;
- img_data = malloc(vi.xres * vi.yres * 3);
+ img_data = malloc(gr_mem_surface.stride * vi.yres * 4);
surface.version = sizeof(surface);
surface.width = gr_mem_surface.width;
surface.height = gr_mem_surface.height;
- surface.stride = gr_mem_surface.width;
+ surface.stride = gr_mem_surface.stride;
surface.data = img_data;
- surface.format = GGL_PIXEL_FORMAT_RGB_888;
+ surface.format = GGL_PIXEL_FORMAT_RGBA_8888;
gglInit(&gl);
gl->colorBuffer(gl, &surface);
gl->activeTexture(gl, 0);
+ if(gr_mem_surface.format == GGL_PIXEL_FORMAT_RGBX_8888)
+ gl->disable(gl, GGL_BLEND);
+
gl->bindTexture(gl, &gr_mem_surface);
gl->texEnvi(gl, GGL_TEXTURE_ENV, GGL_TEXTURE_ENV_MODE, GGL_REPLACE);
gl->texGeni(gl, GGL_S, GGL_TEXTURE_GEN_MODE, GGL_ONE_TO_ONE);
@@ -81,8 +84,11 @@ int gr_save_screenshot(const char *dest)
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_write_info(png_ptr, info_ptr);
+ // To remove the alpha channel for PNG_COLOR_TYPE_RGB format,
+ png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
+
ptr = img_data;
- stride_bytes = surface.width*3;
+ stride_bytes = surface.stride*4;
for(y = 0; y < surface.height; ++y)
{
png_write_row(png_ptr, ptr);