[test/create-from-png] Check loading of various colour types.
Check that when loading from index/gray/rgb PNGs, with and without alpha/transparency, that the correct surface is generated by read_png(), i.e. if the PNG contains an alpha channel then the image must be an ARGB32 surface.
BIN
test/create-from-png-alpha-ref.png
Normal file
|
After Width: | Height: | Size: 150 B |
BIN
test/create-from-png-gray-alpha-ref.png
Normal file
|
After Width: | Height: | Size: 142 B |
BIN
test/create-from-png-gray-ref.png
Normal file
|
After Width: | Height: | Size: 124 B |
BIN
test/create-from-png-indexed-alpha-ref.png
Normal file
|
After Width: | Height: | Size: 172 B |
BIN
test/create-from-png-indexed-ref.png
Normal file
|
After Width: | Height: | Size: 159 B |
|
Before Width: | Height: | Size: 100 B After Width: | Height: | Size: 131 B |
|
|
@ -145,5 +145,126 @@ main (void)
|
|||
}
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
/* check that loading alpha/opaque PNGs generate the correct surfaces */
|
||||
xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
|
||||
"create-from-png-alpha-ref.png");
|
||||
surface = cairo_image_surface_create_from_png (filename);
|
||||
if (cairo_surface_status (surface)) {
|
||||
cairo_test_log ("Error reading PNG image %s: %s\n",
|
||||
filename,
|
||||
cairo_status_to_string (cairo_surface_status (surface)));
|
||||
free (filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
|
||||
cairo_test_log ("Error reading PNG image %s: did not create an ARGB32 image\n",
|
||||
filename);
|
||||
cairo_surface_destroy (surface);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
|
||||
"create-from-png-ref.png");
|
||||
surface = cairo_image_surface_create_from_png (filename);
|
||||
if (cairo_surface_status (surface)) {
|
||||
cairo_test_log ("Error reading PNG image %s: %s\n",
|
||||
filename,
|
||||
cairo_status_to_string (cairo_surface_status (surface)));
|
||||
free (filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
|
||||
cairo_test_log ("Error reading PNG image %s: did not create an RGB24 image\n",
|
||||
filename);
|
||||
cairo_surface_destroy (surface);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
/* check paletted PNGs */
|
||||
xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
|
||||
"create-from-png-indexed-alpha-ref.png");
|
||||
surface = cairo_image_surface_create_from_png (filename);
|
||||
if (cairo_surface_status (surface)) {
|
||||
cairo_test_log ("Error reading PNG image %s: %s\n",
|
||||
filename,
|
||||
cairo_status_to_string (cairo_surface_status (surface)));
|
||||
free (filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
|
||||
cairo_test_log ("Error reading PNG image %s: did not create an ARGB32 image\n",
|
||||
filename);
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
|
||||
"create-from-png-indexed-ref.png");
|
||||
surface = cairo_image_surface_create_from_png (filename);
|
||||
if (cairo_surface_status (surface)) {
|
||||
cairo_test_log ("Error reading PNG image %s: %s\n",
|
||||
filename,
|
||||
cairo_status_to_string (cairo_surface_status (surface)));
|
||||
free (filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
|
||||
cairo_test_log ("Error reading PNG image %s: did not create an RGB24 image\n",
|
||||
filename);
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
/* check grayscale PNGs */
|
||||
xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
|
||||
"create-from-png-gray-alpha-ref.png");
|
||||
surface = cairo_image_surface_create_from_png (filename);
|
||||
if (cairo_surface_status (surface)) {
|
||||
cairo_test_log ("Error reading PNG image %s: %s\n",
|
||||
filename,
|
||||
cairo_status_to_string (cairo_surface_status (surface)));
|
||||
free (filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_ARGB32) {
|
||||
cairo_test_log ("Error reading PNG image %s: did not create an ARGB32 image\n",
|
||||
filename);
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
xasprintf (&filename, "%s/%s", srcdir ? srcdir : ".",
|
||||
"create-from-png-gray-ref.png");
|
||||
surface = cairo_image_surface_create_from_png (filename);
|
||||
if (cairo_surface_status (surface)) {
|
||||
cairo_test_log ("Error reading PNG image %s: %s\n",
|
||||
filename,
|
||||
cairo_status_to_string (cairo_surface_status (surface)));
|
||||
free (filename);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
if (cairo_image_surface_get_format (surface) != CAIRO_FORMAT_RGB24) {
|
||||
cairo_test_log ("Error reading PNG image %s: did not create an RGB24 image\n",
|
||||
filename);
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
free (filename);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return cairo_test (&test);
|
||||
}
|
||||
|
|
|
|||