equal
deleted
inserted
replaced
169 if (image.size() != QSize(width, height) || image.format() != QImage::Format_Mono) { |
169 if (image.size() != QSize(width, height) || image.format() != QImage::Format_Mono) { |
170 image = QImage(width, height, QImage::Format_Mono); |
170 image = QImage(width, height, QImage::Format_Mono); |
171 if (image.isNull()) |
171 if (image.isNull()) |
172 return; |
172 return; |
173 } |
173 } |
174 image.setNumColors(2); |
174 image.setColorCount(2); |
175 image.setColor(1, qRgb(0,0,0)); |
175 image.setColor(1, qRgb(0,0,0)); |
176 image.setColor(0, qRgb(255,255,255)); |
176 image.setColor(0, qRgb(255,255,255)); |
177 } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { |
177 } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { |
178 png_set_expand(png_ptr); |
178 png_set_expand(png_ptr); |
179 png_set_strip_16(png_ptr); |
179 png_set_strip_16(png_ptr); |
197 if (image.size() != QSize(width, height) || image.format() != QImage::Format_Indexed8) { |
197 if (image.size() != QSize(width, height) || image.format() != QImage::Format_Indexed8) { |
198 image = QImage(width, height, QImage::Format_Indexed8); |
198 image = QImage(width, height, QImage::Format_Indexed8); |
199 if (image.isNull()) |
199 if (image.isNull()) |
200 return; |
200 return; |
201 } |
201 } |
202 image.setNumColors(ncols); |
202 image.setColorCount(ncols); |
203 for (int i=0; i<ncols; i++) { |
203 for (int i=0; i<ncols; i++) { |
204 int c = i*255/(ncols-1); |
204 int c = i*255/(ncols-1); |
205 image.setColor(i, qRgba(c,c,c,0xff)); |
205 image.setColor(i, qRgba(c,c,c,0xff)); |
206 } |
206 } |
207 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { |
207 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { |
228 if (image.size() != QSize(width, height) || image.format() != format) { |
228 if (image.size() != QSize(width, height) || image.format() != format) { |
229 image = QImage(width, height, format); |
229 image = QImage(width, height, format); |
230 if (image.isNull()) |
230 if (image.isNull()) |
231 return; |
231 return; |
232 } |
232 } |
233 image.setNumColors(info_ptr->num_palette); |
233 image.setColorCount(info_ptr->num_palette); |
234 int i = 0; |
234 int i = 0; |
235 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { |
235 if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { |
236 while (i < info_ptr->num_trans) { |
236 while (i < info_ptr->num_trans) { |
237 image.setColor(i, qRgba( |
237 image.setColor(i, qRgba( |
238 info_ptr->palette[i].red, |
238 info_ptr->palette[i].red, |
506 state = Ready; |
506 state = Ready; |
507 |
507 |
508 // sanity check palette entries |
508 // sanity check palette entries |
509 if (color_type == PNG_COLOR_TYPE_PALETTE |
509 if (color_type == PNG_COLOR_TYPE_PALETTE |
510 && outImage->format() == QImage::Format_Indexed8) { |
510 && outImage->format() == QImage::Format_Indexed8) { |
511 int color_table_size = outImage->numColors(); |
511 int color_table_size = outImage->colorCount(); |
512 for (int y=0; y<(int)height; ++y) { |
512 for (int y=0; y<(int)height; ++y) { |
513 uchar *p = outImage->scanLine(y); |
513 uchar *p = outImage->scanLine(y); |
514 uchar *end = p + width; |
514 uchar *end = p + width; |
515 while (p < end) { |
515 while (p < end) { |
516 if (*p >= color_table_size) |
516 if (*p >= color_table_size) |
760 if (image.format() == QImage::Format_MonoLSB) |
760 if (image.format() == QImage::Format_MonoLSB) |
761 png_set_packswap(png_ptr); |
761 png_set_packswap(png_ptr); |
762 |
762 |
763 png_colorp palette = 0; |
763 png_colorp palette = 0; |
764 png_bytep copy_trans = 0; |
764 png_bytep copy_trans = 0; |
765 if (image.numColors()) { |
765 if (image.colorCount()) { |
766 // Paletted |
766 // Paletted |
767 int num_palette = image.numColors(); |
767 int num_palette = image.colorCount(); |
768 palette = new png_color[num_palette]; |
768 palette = new png_color[num_palette]; |
769 png_set_PLTE(png_ptr, info_ptr, palette, num_palette); |
769 png_set_PLTE(png_ptr, info_ptr, palette, num_palette); |
770 int* trans = new int[num_palette]; |
770 int* trans = new int[num_palette]; |
771 int num_trans = 0; |
771 int num_trans = 0; |
772 for (int i=0; i<num_palette; i++) { |
772 for (int i=0; i<num_palette; i++) { |