Annotation of ports/games/megaglest/base/patches/patch-source_shared_lib_sources_graphics_PNGReader_cpp, Revision 1.1
1.1 ! yason 1: $OpenBSD$
! 2: --- source/shared_lib/sources/graphics/PNGReader.cpp.orig Wed Sep 14 21:27:05 2011
! 3: +++ source/shared_lib/sources/graphics/PNGReader.cpp Wed Sep 14 21:48:50 2011
! 4: @@ -93,13 +93,13 @@ Pixmap2D* PNGReader::read(ifstream& is, const string&
! 5: png_set_sig_bytes(png_ptr, 8);
! 6: png_read_info(png_ptr, info_ptr);
! 7:
! 8: - int width = info_ptr->width;
! 9: - int height = info_ptr->height;
! 10: - int color_type = info_ptr->color_type;
! 11: - int bit_depth = info_ptr->bit_depth;
! 12: + int width = png_get_image_width(png_ptr, info_ptr);
! 13: + int height = png_get_image_height(png_ptr, info_ptr);
! 14: + int color_type = png_get_color_type(png_ptr, info_ptr);
! 15: + int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
! 16:
! 17: //We want RGB, 24 bit
! 18: - if (color_type == PNG_COLOR_TYPE_PALETTE || (color_type == PNG_COLOR_TYPE_GRAY && info_ptr->bit_depth < 8) || (info_ptr->valid & PNG_INFO_tRNS)) {
! 19: + if (color_type == PNG_COLOR_TYPE_PALETTE || (color_type == PNG_COLOR_TYPE_GRAY && png_get_bit_depth(png_ptr, info_ptr) < 8) || (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) {
! 20: png_set_expand(png_ptr);
! 21: }
! 22:
! 23: @@ -117,17 +117,17 @@ Pixmap2D* PNGReader::read(ifstream& is, const string&
! 24: return NULL; //error during read_image
! 25: }
! 26: for (int y = 0; y < height; ++y) {
! 27: - row_pointers[y] = new png_byte[info_ptr->rowbytes];
! 28: + row_pointers[y] = new png_byte[png_get_rowbytes(png_ptr, info_ptr)];
! 29: }
! 30: png_read_image(png_ptr, row_pointers);
! 31: - size_t fileComponents = info_ptr->rowbytes/info_ptr->width;
! 32: + size_t fileComponents = png_get_rowbytes(png_ptr, info_ptr)/png_get_image_width(png_ptr, info_ptr);
! 33: size_t picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
! 34: //std::cout << "PNG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl;
! 35: //picComponents = 4;
! 36: //Copy image
! 37: ret->init(width,height,(int)picComponents);
! 38: uint8* pixels = ret->getPixels();
! 39: - const size_t rowbytes = info_ptr->rowbytes;
! 40: + const size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
! 41: size_t location = 0;
! 42: for (int y = height-1; y >= 0; --y) { //you have to somehow invert the lines
! 43: if (picComponents == fileComponents) {
CVSweb