Path: blob/main/games/allacrost/files/patch-src_engine_video_image__base.cpp
16135 views
--- src/engine/video/image_base.cpp.orig 2010-05-16 23:38:27 UTC1+++ src/engine/video/image_base.cpp2@@ -259,9 +259,9 @@ bool ImageMemory::_LoadPngImage(const st3uint8** row_pointers = png_get_rows(png_ptr, info_ptr);45// copy metadata6- width = info_ptr->width;7- height = info_ptr->height;8- pixels = malloc(info_ptr->width * info_ptr->height * 4);9+ width = png_get_image_width(png_ptr, info_ptr);10+ height = png_get_image_height(png_ptr, info_ptr);11+ pixels = malloc(width * height * 4);1213// check that we were able to allocate enough memory for the PNG14if (pixels == NULL) {15@@ -274,18 +274,21 @@ bool ImageMemory::_LoadPngImage(const st16// convert the damn thing so that it works in our format17// this is mostly just byteswapping and adding extra data - we want everything in four channels18// for the moment, anyway19- uint32 bpp = info_ptr->channels;20+ uint32 bpp = png_get_channels(png_ptr, info_ptr);21uint8* img_pixel = NULL;22uint8* dst_pixel = NULL;2324- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {25+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {26// colours come from a palette - for this colour type, we have to look up the colour from the palette27+ png_colorp palette;28+ int num_palette;29+ png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);30png_color c;31- for (uint32 y = 0; y < info_ptr->height; y++) {32- for (uint32 x = 0; x < info_ptr->width; x++) {33+ for (uint32 y = 0; y < height; y++) {34+ for (uint32 x = 0; x < width; x++) {35img_pixel = row_pointers[y] + (x * bpp);36- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;37- c = info_ptr->palette[img_pixel[0]];38+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;39+ c = palette[img_pixel[0]];4041dst_pixel[0] = c.red;42dst_pixel[1] = c.green;43@@ -295,10 +298,10 @@ bool ImageMemory::_LoadPngImage(const st44}45}46else if (bpp == 1) {47- for (uint32 y = 0; y < info_ptr->height; y++) {48- for (uint32 x = 0; x < info_ptr->width; x++) {49+ for (uint32 y = 0; y < height; y++) {50+ for (uint32 x = 0; x < width; x++) {51img_pixel = row_pointers[y] + (x * bpp);52- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;53+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;54dst_pixel[0] = img_pixel[0];55dst_pixel[1] = img_pixel[0];56dst_pixel[2] = img_pixel[0];57@@ -307,10 +310,10 @@ bool ImageMemory::_LoadPngImage(const st58}59}60else if (bpp == 3) {61- for (uint32 y = 0; y < info_ptr->height; y++) {62- for (uint32 x = 0; x < info_ptr->width; x++) {63+ for (uint32 y = 0; y < height; y++) {64+ for (uint32 x = 0; x < width; x++) {65img_pixel = row_pointers[y] + (x * bpp);66- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;67+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;68dst_pixel[0] = img_pixel[0];69dst_pixel[1] = img_pixel[1];70dst_pixel[2] = img_pixel[2];71@@ -319,10 +322,10 @@ bool ImageMemory::_LoadPngImage(const st72}73}74else if (bpp == 4) {75- for (uint32 y = 0; y < info_ptr->height; y++) {76- for (uint32 x = 0; x < info_ptr->width; x++) {77+ for (uint32 y = 0; y < height; y++) {78+ for (uint32 x = 0; x < width; x++) {79img_pixel = row_pointers[y] + (x * bpp);80- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;81+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;82dst_pixel[0] = img_pixel[0];83dst_pixel[1] = img_pixel[1];84dst_pixel[2] = img_pixel[2];858687