Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-02-15 18:03:44 +0000
committerStijn Buys <ingar@osirion.org>2010-02-15 18:03:44 +0000
commit9ce5ea1d2235cf2849acfe02b370cf1c65f8f458 (patch)
treed4a04ba52cabc300efc11e18cecc4d9fbde9fedb /src/render
parentfb95f7b74c1a4286e02b95c461bdc5068f2532e4 (diff)
Replace depricated png functions, fixes compilation with libpng 1.4
Diffstat (limited to 'src/render')
-rw-r--r--src/render/pngfile.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/render/pngfile.cc b/src/render/pngfile.cc
index da434db..ca8c8d5 100644
--- a/src/render/pngfile.cc
+++ b/src/render/pngfile.cc
@@ -75,15 +75,14 @@ Image *PNG::load(const char *filename)
/* read the PNG header */
png_init_io(png_ptr, png_file->handle());
png_set_sig_bytes(png_ptr, 8);
-
png_read_info(png_ptr, info_ptr);
- int png_width = info_ptr->width;
- int png_height = info_ptr->height;
- //int png_color_type = info_ptr->color_type;
- int png_depth = info_ptr->bit_depth;
+ int png_width = png_get_image_width(png_ptr, info_ptr); // image width
+ int png_height = png_get_image_height(png_ptr, info_ptr); // image height
+ int png_depth = png_get_bit_depth(png_ptr, info_ptr); // bits per channel
+ int png_channels = png_get_channels(png_ptr, info_ptr); // channels
+ int png_rowbytes = png_get_rowbytes(png_ptr, info_ptr); // bytes per row
- //int number_of_passes = png_set_interlace_handling(png_ptr);
png_set_interlace_handling(png_ptr);
png_read_update_info(png_ptr, info_ptr);
@@ -94,8 +93,7 @@ Image *PNG::load(const char *filename)
return 0;
}
- unsigned int channels = info_ptr->rowbytes / png_width;
- image = new Image(png_width, png_height, channels);
+ image = new Image(png_width, png_height, png_channels);
/* read image data */
if (setjmp(png_jmpbuf(png_ptr))) {
@@ -109,7 +107,7 @@ Image *PNG::load(const char *filename)
png_bytep row_pointers[png_height];
for (size_t i = 0; i < (size_t)png_height; i++)
- row_pointers[i] = (png_bytep)(*image)[i * info_ptr->rowbytes];
+ row_pointers[i] = (png_bytep)(*image)[i * png_rowbytes];
// read pixel data
png_read_image(png_ptr, row_pointers);