Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-gnome
Path: blob/main/games/allacrost/files/patch-src_engine_video_image__base.cpp
16135 views
1
--- src/engine/video/image_base.cpp.orig 2010-05-16 23:38:27 UTC
2
+++ src/engine/video/image_base.cpp
3
@@ -259,9 +259,9 @@ bool ImageMemory::_LoadPngImage(const st
4
uint8** row_pointers = png_get_rows(png_ptr, info_ptr);
5
6
// copy metadata
7
- width = info_ptr->width;
8
- height = info_ptr->height;
9
- pixels = malloc(info_ptr->width * info_ptr->height * 4);
10
+ width = png_get_image_width(png_ptr, info_ptr);
11
+ height = png_get_image_height(png_ptr, info_ptr);
12
+ pixels = malloc(width * height * 4);
13
14
// check that we were able to allocate enough memory for the PNG
15
if (pixels == NULL) {
16
@@ -274,18 +274,21 @@ bool ImageMemory::_LoadPngImage(const st
17
// convert the damn thing so that it works in our format
18
// this is mostly just byteswapping and adding extra data - we want everything in four channels
19
// for the moment, anyway
20
- uint32 bpp = info_ptr->channels;
21
+ uint32 bpp = png_get_channels(png_ptr, info_ptr);
22
uint8* img_pixel = NULL;
23
uint8* dst_pixel = NULL;
24
25
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
26
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
27
// colours come from a palette - for this colour type, we have to look up the colour from the palette
28
+ png_colorp palette;
29
+ int num_palette;
30
+ png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
31
png_color c;
32
- for (uint32 y = 0; y < info_ptr->height; y++) {
33
- for (uint32 x = 0; x < info_ptr->width; x++) {
34
+ for (uint32 y = 0; y < height; y++) {
35
+ for (uint32 x = 0; x < width; x++) {
36
img_pixel = row_pointers[y] + (x * bpp);
37
- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;
38
- c = info_ptr->palette[img_pixel[0]];
39
+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;
40
+ c = palette[img_pixel[0]];
41
42
dst_pixel[0] = c.red;
43
dst_pixel[1] = c.green;
44
@@ -295,10 +298,10 @@ bool ImageMemory::_LoadPngImage(const st
45
}
46
}
47
else if (bpp == 1) {
48
- for (uint32 y = 0; y < info_ptr->height; y++) {
49
- for (uint32 x = 0; x < info_ptr->width; x++) {
50
+ for (uint32 y = 0; y < height; y++) {
51
+ for (uint32 x = 0; x < width; x++) {
52
img_pixel = row_pointers[y] + (x * bpp);
53
- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;
54
+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;
55
dst_pixel[0] = img_pixel[0];
56
dst_pixel[1] = img_pixel[0];
57
dst_pixel[2] = img_pixel[0];
58
@@ -307,10 +310,10 @@ bool ImageMemory::_LoadPngImage(const st
59
}
60
}
61
else if (bpp == 3) {
62
- for (uint32 y = 0; y < info_ptr->height; y++) {
63
- for (uint32 x = 0; x < info_ptr->width; x++) {
64
+ for (uint32 y = 0; y < height; y++) {
65
+ for (uint32 x = 0; x < width; x++) {
66
img_pixel = row_pointers[y] + (x * bpp);
67
- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;
68
+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;
69
dst_pixel[0] = img_pixel[0];
70
dst_pixel[1] = img_pixel[1];
71
dst_pixel[2] = img_pixel[2];
72
@@ -319,10 +322,10 @@ bool ImageMemory::_LoadPngImage(const st
73
}
74
}
75
else if (bpp == 4) {
76
- for (uint32 y = 0; y < info_ptr->height; y++) {
77
- for (uint32 x = 0; x < info_ptr->width; x++) {
78
+ for (uint32 y = 0; y < height; y++) {
79
+ for (uint32 x = 0; x < width; x++) {
80
img_pixel = row_pointers[y] + (x * bpp);
81
- dst_pixel = ((uint8*)pixels) + ((y * info_ptr->width) + x) * 4;
82
+ dst_pixel = ((uint8*)pixels) + ((y * width) + x) * 4;
83
dst_pixel[0] = img_pixel[0];
84
dst_pixel[1] = img_pixel[1];
85
dst_pixel[2] = img_pixel[2];
86
87