FS-7500: libpng 1.6.0 has much simpler APIs, also add a new switch_img_patch_png to possible patch a transparent png to an img

While this is not optimal, we should cache the png:
1) cache the whole buffer, with comes with RGBARGBA pixel formats
2) Allow switch_image_t to be other formats e.g. VPX_IMG_FMT_ARGB, VPX_IMG_FMT_ARGB_LE, or VPX_IMG_FMT_444A
   those can have alpha channels so we can check the alpha channel before we patch

Note all PNG are created equel, or maybe a bug in libpng since for some PNG files with alpha the returned buffer
     not seems like RGBARGBA... while docs says it should default be RGBA
This commit is contained in:
Seven Du
2015-02-15 13:49:43 +08:00
committed by Michael Jerris
parent f4fad4e756
commit e02ff26569
2 changed files with 142 additions and 0 deletions
+1
View File
@@ -210,6 +210,7 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_render(switch_img_txt_hand
SWITCH_DECLARE(void) switch_img_patch_hole(switch_image_t *IMG, switch_image_t *img, int x, int y, switch_image_rect_t *rect);
SWITCH_DECLARE(switch_image_t *) switch_img_read_png(const char* file_name);
SWITCH_DECLARE(switch_status_t) switch_img_write_png(switch_image_t *img, char* file_name);
SWITCH_DECLARE(switch_status_t) switch_img_patch_png(switch_image_t *img, int x, int y, const char *file_name);
SWITCH_DECLARE(void) switch_img_get_yuv_pixel(switch_image_t *img, switch_yuv_color_t *yuv, int x, int y);