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 | |
parent | be3ca424f6ae8f7d9f6b21563152aa894b729c45 (diff) | |
download | openttd-6179198c65ce616fb331cdaf89c7a90224ff38df.tar.xz |
(svn r18756) -Codechange: direct accesses to png_*_struct members are deprecated
Diffstat (limited to 'src')
-rw-r--r-- | src/heightmap.cpp | 22 | ||||
-rw-r--r-- | src/screenshot.cpp | 2 | ||||
-rw-r--r-- | src/spriteloader/png.cpp | 14 |
3 files changed, 19 insertions, 19 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); diff --git a/src/screenshot.cpp b/src/screenshot.cpp index bbfa80f72..eb0901fb1 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -207,7 +207,7 @@ static bool MakeBMPImage(const char *name, ScreenshotCallback *callb, void *user static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message) { DEBUG(misc, 0, "[libpng] error: %s - %s", message, (const char *)png_get_error_ptr(png_ptr)); - longjmp(png_ptr->jmpbuf, 1); + longjmp(png_jmpbuf(png_ptr), 1); } static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message) diff --git a/src/spriteloader/png.cpp b/src/spriteloader/png.cpp index e82ccf968..51ae23b8d 100644 --- a/src/spriteloader/png.cpp +++ b/src/spriteloader/png.cpp @@ -28,7 +28,7 @@ static void PNGAPI png_my_read(png_structp png_ptr, png_bytep data, png_size_t l static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message) { DEBUG(sprite, 0, "ERROR (libpng): %s - %s", message, (char *)png_get_error_ptr(png_ptr)); - longjmp(png_ptr->jmpbuf, 1); + longjmp(png_jmpbuf(png_ptr), 1); } static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message) @@ -105,8 +105,8 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i if (strcmp("y_offs", text_ptr[i].key) == 0) sprite->y_offs = strtol(text_ptr[i].text, NULL, 0); } - sprite->height = info_ptr->height; - sprite->width = info_ptr->width; + sprite->height = png_get_image_height(png_ptr, info_ptr); + sprite->width = png_get_image_width(png_ptr, info_ptr); sprite->AllocateData(sprite->width * sprite->height); } @@ -139,14 +139,14 @@ static bool LoadPNG(SpriteLoader::Sprite *sprite, const char *filename, uint32 i pixelsize = sizeof(uint8); } - png_bytep row_pointer = AllocaM(png_byte, info_ptr->width * pixelsize); + png_bytep row_pointer = AllocaM(png_byte, png_get_image_width(png_ptr, info_ptr) * pixelsize); - for (i = 0; i < info_ptr->height; i++) { + for (i = 0; i < png_get_image_height(png_ptr, info_ptr); i++) { png_read_row(png_ptr, row_pointer, NULL); - dst = sprite->data + i * info_ptr->width; + dst = sprite->data + i * png_get_image_width(png_ptr, info_ptr); - for (uint x = 0; x < info_ptr->width; x++) { + for (uint x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) { if (mask) { if (row_pointer[x * sizeof(uint8)] != 0) { dst[x].r = 0; |