if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb (png);
- if (color_type == PNG_COLOR_TYPE_GRAY ||
- color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ if (color_type == PNG_COLOR_TYPE_GRAY)
png_set_expand_gray_1_2_4_to_8 (png);
if (png_get_valid (png, info, PNG_INFO_tRNS))
if (depth < 8)
png_set_packing (png);
- if (color_type == PNG_COLOR_TYPE_GRAY ||
- color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- png_set_gray_to_rgb (png);
-
if (interlace != PNG_INTERLACE_NONE)
png_set_interlace_handling (png);
format = GDK_MEMORY_R16G16B16;
}
break;
+ case PNG_COLOR_TYPE_GRAY:
+ if (depth == 8)
+ {
+ format = GDK_MEMORY_G8;
+ }
+ else if (depth == 16)
+ {
+ format = GDK_MEMORY_G16;
+ }
+ break;
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ if (depth == 8)
+ {
+ format = GDK_MEMORY_G8A8;
+ }
+ else if (depth == 16)
+ {
+ format = GDK_MEMORY_G16A16;
+ }
+ break;
default:
png_destroy_read_struct (&png, &info, NULL);
g_set_error (error,
depth = 16;
break;
+ case GDK_MEMORY_G8:
+ format = GDK_MEMORY_G8;
+ png_format = PNG_COLOR_TYPE_GRAY;
+ depth = 8;
+ break;
+
+ case GDK_MEMORY_G8A8_PREMULTIPLIED:
+ case GDK_MEMORY_G8A8:
+ case GDK_MEMORY_A8:
+ format = GDK_MEMORY_G8A8;
+ png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
+ depth = 8;
+ break;
+
+ case GDK_MEMORY_G16:
+ format = GDK_MEMORY_G16;
+ png_format = PNG_COLOR_TYPE_GRAY;
+ depth = 16;
+ break;
+
+ case GDK_MEMORY_G16A16_PREMULTIPLIED:
+ case GDK_MEMORY_G16A16:
+ case GDK_MEMORY_A16:
+ format = GDK_MEMORY_G16A16;
+ png_format = PNG_COLOR_TYPE_GRAY_ALPHA;
+ depth = 16;
+ break;
+
case GDK_MEMORY_N_FORMATS:
default:
g_assert_not_reached ();