Fix types
This commit is contained in:
+33
-11
@@ -2,17 +2,20 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const guchar *data;
|
||||
gsize size;
|
||||
gsize offset;
|
||||
const unsigned char *data;
|
||||
size_t size;
|
||||
size_t offset;
|
||||
} PngBuffer;
|
||||
|
||||
static void
|
||||
glib_png_read (png_structp png_ptr, png_bytep out_bytes, png_size_t len)
|
||||
{
|
||||
PngBuffer *buf = (PngBuffer *) png_get_io_ptr (png_ptr);
|
||||
|
||||
if (buf->offset + len > buf->size)
|
||||
png_error (png_ptr, "Read beyond buffer");
|
||||
{
|
||||
png_error (png_ptr, "Read beyond buffer");
|
||||
}
|
||||
|
||||
memcpy (out_bytes, buf->data + buf->offset, len);
|
||||
buf->offset += len;
|
||||
@@ -70,20 +73,37 @@ World_load_from_path (const char *path)
|
||||
png_byte bit_depth = png_get_bit_depth (png_ptr, info_ptr);
|
||||
|
||||
if (bit_depth == 16)
|
||||
png_set_strip_16 (png_ptr);
|
||||
{
|
||||
png_set_strip_16 (png_ptr);
|
||||
}
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_palette_to_rgb (png_ptr);
|
||||
{
|
||||
png_set_palette_to_rgb (png_ptr);
|
||||
}
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
||||
png_set_expand_gray_1_2_4_to_8 (png_ptr);
|
||||
{
|
||||
png_set_expand_gray_1_2_4_to_8 (png_ptr);
|
||||
}
|
||||
|
||||
if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||
png_set_tRNS_to_alpha (png_ptr);
|
||||
{
|
||||
png_set_tRNS_to_alpha (png_ptr);
|
||||
}
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_RGB ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_filler (png_ptr, 0xFF, PNG_FILLER_AFTER);
|
||||
{
|
||||
png_set_filler (png_ptr, 0xFF, PNG_FILLER_AFTER);
|
||||
}
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
png_set_gray_to_rgb (png_ptr);
|
||||
{
|
||||
png_set_gray_to_rgb (png_ptr);
|
||||
}
|
||||
|
||||
png_read_update_info (png_ptr, info_ptr);
|
||||
|
||||
@@ -92,7 +112,9 @@ World_load_from_path (const char *path)
|
||||
png_bytep *row_pointers = g_new (png_bytep, self->height);
|
||||
|
||||
for (unsigned int y = 0; y < self->height; y++)
|
||||
row_pointers[y] = image_data + y * rowbytes;
|
||||
{
|
||||
row_pointers[y] = image_data + y * rowbytes;
|
||||
}
|
||||
|
||||
png_read_image (png_ptr, row_pointers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user