# HG changeset patch # User Tero Marttila # Date 1264380185 -7200 # Node ID 35515b3a82b70079fbd433fac5949ff617431465 # Parent 1d188aa94aee8b7378390319e4edb799412e08e3 more constness for pt_png diff -r 1d188aa94aee -r 35515b3a82b7 src/lib/png.c --- a/src/lib/png.c Mon Jan 25 02:40:19 2010 +0200 +++ b/src/lib/png.c Mon Jan 25 02:43:05 2010 +0200 @@ -268,7 +268,7 @@ /** * Return a pointer to the pixel data on \a row, starting at \a col. */ -static inline void* tile_row_col (const struct pt_png_header *header, uint8_t *data, size_t row, size_t col) +static inline const void* tile_row_col (const struct pt_png_header *header, const uint8_t *data, size_t row, size_t col) { return data + (row * header->row_bytes) + (col * header->col_bytes); } @@ -285,11 +285,12 @@ /** * Write raw tile image data, directly from the cache */ -static int pt_png_encode_direct (struct pt_png_img *img, const struct pt_png_header *header, uint8_t *data, const struct pt_tile_info *ti) +static int pt_png_encode_direct (struct pt_png_img *img, const struct pt_png_header *header, const uint8_t *data, const struct pt_tile_info *ti) { for (size_t row = ti->y; row < ti->y + ti->height; row++) // write data directly - png_write_row(img->png, tile_row_col(header, data, row, ti->x)); + // missing const... + png_write_row(img->png, (const png_bytep) tile_row_col(header, data, row, ti->x)); return 0; } @@ -297,7 +298,7 @@ /** * Write clipped tile image data (a tile that goes over the edge of the actual image) by aligning the data from the cache as needed */ -static int pt_png_encode_clipped (struct pt_png_img *img, const struct pt_png_header *header, uint8_t *data, const struct pt_tile_info *ti) +static int pt_png_encode_clipped (struct pt_png_img *img, const struct pt_png_header *header, const uint8_t *data, const struct pt_tile_info *ti) { png_byte *rowbuf; size_t row; @@ -358,7 +359,7 @@ #define ADD_AVG(l, r) (l) = ((l) + (r)) / 2 -static int png_pixel_data (png_color *out, const struct pt_png_header *header, uint8_t *data, size_t row, size_t col) +static int png_pixel_data (png_color *out, const struct pt_png_header *header, const uint8_t *data, size_t row, size_t col) { if (header->color_type == PNG_COLOR_TYPE_PALETTE) { // palette entry number @@ -385,7 +386,7 @@ /** * Write unscaled tile data */ -static int pt_png_encode_unzoomed (struct pt_png_img *img, const struct pt_png_header *header, uint8_t *data, const struct pt_tile_info *ti) +static int pt_png_encode_unzoomed (struct pt_png_img *img, const struct pt_png_header *header, const uint8_t *data, const struct pt_tile_info *ti) { int err; @@ -420,7 +421,7 @@ /** * Write scaled tile data */ -static int pt_png_encode_zoomed (struct pt_png_img *img, const struct pt_png_header *header, uint8_t *data, const struct pt_tile_info *ti) +static int pt_png_encode_zoomed (struct pt_png_img *img, const struct pt_png_header *header, const uint8_t *data, const struct pt_tile_info *ti) { // size of the image data in px size_t data_width = scale_by_zoom_factor(ti->width, -ti->zoom); @@ -494,7 +495,7 @@ return 0; } -int pt_png_tile (struct pt_png_header *header, uint8_t *data, struct pt_tile *tile) +int pt_png_tile (const struct pt_png_header *header, const uint8_t *data, struct pt_tile *tile) { struct pt_png_img _img, *img = &_img; struct pt_tile_info *ti = &tile->info; diff -r 1d188aa94aee -r 35515b3a82b7 src/lib/png.h --- a/src/lib/png.h Mon Jan 25 02:40:19 2010 +0200 +++ b/src/lib/png.h Mon Jan 25 02:43:05 2010 +0200 @@ -82,7 +82,7 @@ /** * Render out a tile */ -int pt_png_tile (struct pt_png_header *header, uint8_t *data, struct pt_tile *tile); +int pt_png_tile (const struct pt_png_header *header, const uint8_t *data, struct pt_tile *tile); /** * Release pt_png_ctx resources as allocated by pt_png_open