diff options
author | glx <glx@openttd.org> | 2010-01-08 03:17:12 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2010-01-08 03:17:12 +0000 |
commit | 6179198c65ce616fb331cdaf89c7a90224ff38df (patch) | |
tree | ed4ec8d329a8f3618e2878c5485842ef7473b2fe /src/heightmap.cpp | |
parent | be3ca424f6ae8f7d9f6b21563152aa894b729c45 (diff) | |
download | openttd-6179198c65ce616fb331cdaf89c7a90224ff38df.tar.xz |
(svn r18756) -Codechange: direct accesses to png_*_struct members are deprecated
Diffstat (limited to 'src/heightmap.cpp')
-rw-r--r-- | src/heightmap.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/heightmap.cpp b/src/heightmap.cpp index 089d96d46..68a1ecffb 100644 --- a/src/heightmap.cpp +++ b/src/heightmap.cpp @@ -49,7 +49,7 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop png_bytep *row_pointers = NULL; /* Get palette and convert it to grayscale */ - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { + if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) { int i; int palette_size; png_color *palette; @@ -77,14 +77,14 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop row_pointers = png_get_rows(png_ptr, info_ptr); /* Read the raw image data and convert in 8-bit grayscale */ - for (x = 0; x < info_ptr->width; x++) { - for (y = 0; y < info_ptr->height; y++) { - byte *pixel = &map[y * info_ptr->width + x]; - uint x_offset = x * info_ptr->channels; + for (x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) { + for (y = 0; y < png_get_image_height(png_ptr, info_ptr); y++) { + byte *pixel = &map[y * png_get_image_width(png_ptr, info_ptr) + x]; + uint x_offset = x * png_get_channels(png_ptr, info_ptr); - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { + if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) { *pixel = gray_palette[row_pointers[y][x_offset]]; - } else if (info_ptr->channels == 3) { + } else if (png_get_channels(png_ptr, info_ptr) == 3) { *pixel = RGBToGrayscale(row_pointers[y][x_offset + 0], row_pointers[y][x_offset + 1], row_pointers[y][x_offset + 2]); } else { @@ -135,7 +135,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map) /* Maps of wrong colour-depth are not used. * (this should have been taken care of by stripping alpha and 16-bit samples on load) */ - if ((info_ptr->channels != 1) && (info_ptr->channels != 3) && (info_ptr->bit_depth != 8)) { + if ((png_get_channels(png_ptr, info_ptr) != 1) && (png_get_channels(png_ptr, info_ptr) != 3) && (png_get_bit_depth(png_ptr, info_ptr) != 8)) { ShowErrorMessage(STR_ERROR_PNGMAP, STR_ERROR_PNGMAP_IMAGE_TYPE, 0, 0); fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); @@ -143,12 +143,12 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map) } if (map != NULL) { - *map = MallocT<byte>(info_ptr->width * info_ptr->height); + *map = MallocT<byte>(png_get_image_width(png_ptr, info_ptr) * png_get_image_height(png_ptr, info_ptr)); ReadHeightmapPNGImageData(*map, png_ptr, info_ptr); } - *x = info_ptr->width; - *y = info_ptr->height; + *x = png_get_image_width(png_ptr, info_ptr); + *y = png_get_image_height(png_ptr, info_ptr); fclose(fp); png_destroy_read_struct(&png_ptr, &info_ptr, NULL); |