From: H. Peter Anvin Date: Tue, 10 Apr 2007 23:19:52 +0000 (-0700) Subject: Make the pixel format canonicalization code a bit easier to read. X-Git-Tag: syslinux-3.50-pre6~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=595705ffad4f63cfeb84e9bb1243df03808c2fff;p=platform%2Fupstream%2Fsyslinux.git Make the pixel format canonicalization code a bit easier to read. --- diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c index 2103a9c..91c5424 100644 --- a/com32/lib/sys/vesa/background.c +++ b/com32/lib/sys/vesa/background.c @@ -123,42 +123,23 @@ static int read_png_file(FILE *fp) with 32-bit BGRA format, no more, no less. */ /* Expand to RGB first... */ - - switch (info_ptr->color_type) { - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_set_gray_to_rgb(png_ptr); - break; - - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - break; - - case PNG_COLOR_TYPE_PALETTE: + if (info_ptr->color_type & PNG_COLOR_MASK_PALETTE) png_set_palette_to_rgb(png_ptr); - break; - - default: - /* Huh? */ - break; - } - - /* ... then add an alpha channel ... */ - switch (info_ptr->color_type) { - case PNG_COLOR_TYPE_GRAY_ALPHA: - case PNG_COLOR_TYPE_RGB_ALPHA: - break; + else if (!(info_ptr->color_type & PNG_COLOR_MASK_COLOR)) + png_set_gray_to_rgb(png_ptr); - default: + /* Add alpha channel, if need be */ + if (!(png_ptr->color_type & PNG_COLOR_MASK_ALPHA)) { if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); else png_set_add_alpha(png_ptr, ~0, PNG_FILLER_AFTER); - break; } + /* Adjust the byte order, if necessary */ png_set_bgr(png_ptr); + /* Make sure we end up with 8-bit data */ if (info_ptr->bit_depth == 16) png_set_strip_16(png_ptr); else if (info_ptr->bit_depth < 8)