By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release. View | Details | Raw Unified | Return to bug 683
Collapse All | Expand All

(-)qt3.orig/src/kernel/qpngio.cpp (-3 / +111 lines)
Lines 46-51 Link Here
46
#include "qiodevice.h"
46
#include "qiodevice.h"
47
47
48
#include <png.h>
48
#include <png.h>
49
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
50
#include <zlib.h>
51
#endif /* LIBPNG 1.5 */
49
52
50
53
51
#ifdef Q_OS_TEMP
54
#ifdef Q_OS_TEMP
Lines 126-134 Link Here
126
    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
129
    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
127
	0, 0, 0);
130
	0, 0, 0);
128
131
132
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
133
    png_colorp info_ptr_palette = NULL;
134
    int info_ptr_num_palette = 0;
135
    if (png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)) {
136
	png_get_PLTE(png_ptr, info_ptr, &info_ptr_palette, &info_ptr_num_palette);
137
    }
138
139
    png_bytep info_ptr_trans_alpha = NULL;
140
    int info_ptr_num_trans = 0;
141
    png_color_16p info_ptr_trans_color = NULL;
142
143
    if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
144
	png_get_tRNS(png_ptr, info_ptr, &info_ptr_trans_alpha, &info_ptr_num_trans, &info_ptr_trans_color);
145
    }
146
#endif /* LIBPNG 1.5 */
147
129
    if ( color_type == PNG_COLOR_TYPE_GRAY ) {
148
    if ( color_type == PNG_COLOR_TYPE_GRAY ) {
130
	// Black & White or 8-bit grayscale
149
	// Black & White or 8-bit grayscale
150
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
151
	if ( bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1 ) {
152
#else /* LIBPNG 1.5 */
131
	if ( bit_depth == 1 && info_ptr->channels == 1 ) {
153
	if ( bit_depth == 1 && info_ptr->channels == 1 ) {
154
#endif /* LIBPNG 1.5 */
132
	    png_set_invert_mono( png_ptr );
155
	    png_set_invert_mono( png_ptr );
133
	    png_read_update_info( png_ptr, info_ptr );
156
	    png_read_update_info( png_ptr, info_ptr );
134
	    if (!image.create( width, height, 1, 2, QImage::BigEndian ))
157
	    if (!image.create( width, height, 1, 2, QImage::BigEndian ))
Lines 162-168 Link Here
162
		image.setColor( i, qRgba(c,c,c,0xff) );
185
		image.setColor( i, qRgba(c,c,c,0xff) );
163
	    }
186
	    }
164
	    if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
187
	    if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
165
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=4 )
188
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
189
		const int g = info_ptr_trans_color->gray;
190
#elif ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=4 )
166
		const int g = info_ptr->trans_color.gray;
191
		const int g = info_ptr->trans_color.gray;
167
#else
192
#else
168
		const int g = info_ptr->trans_values.gray;
193
		const int g = info_ptr->trans_values.gray;
Lines 175-181 Link Here
175
	}
200
	}
176
    } else if ( color_type == PNG_COLOR_TYPE_PALETTE
201
    } else if ( color_type == PNG_COLOR_TYPE_PALETTE
177
     && png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)
202
     && png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)
203
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
204
     && info_ptr_num_palette <= 256 )
205
#else /* LIBPNG 1.5 */
178
     && info_ptr->num_palette <= 256 )
206
     && info_ptr->num_palette <= 256 )
207
#endif /* LIBPNG 1.5 */
179
    {
208
    {
180
	// 1-bit and 8-bit color
209
	// 1-bit and 8-bit color
181
	if ( bit_depth != 1 )
210
	if ( bit_depth != 1 )
Lines 183-200 Link Here
183
	png_read_update_info( png_ptr, info_ptr );
212
	png_read_update_info( png_ptr, info_ptr );
184
	png_get_IHDR(png_ptr, info_ptr,
213
	png_get_IHDR(png_ptr, info_ptr,
185
	    &width, &height, &bit_depth, &color_type, 0, 0, 0);
214
	    &width, &height, &bit_depth, &color_type, 0, 0, 0);
215
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
216
	if (!image.create(width, height, bit_depth, info_ptr_num_palette,
217
#else /* LIBPNG 1.5 */
186
	if (!image.create(width, height, bit_depth, info_ptr->num_palette,
218
	if (!image.create(width, height, bit_depth, info_ptr->num_palette,
219
#endif /* LIBPNG 1.5 */
187
	    QImage::BigEndian))
220
	    QImage::BigEndian))
188
	    return;
221
	    return;
189
	int i = 0;
222
	int i = 0;
190
	if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
223
	if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
191
	    image.setAlphaBuffer( TRUE );
224
	    image.setAlphaBuffer( TRUE );
225
226
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
227
	    while ( i < info_ptr_num_trans ) {
228
		image.setColor(i, qRgba(
229
		    info_ptr_palette[i].red,
230
		    info_ptr_palette[i].green,
231
		    info_ptr_palette[i].blue,
232
#else /* LIBPNG 1.5 */
192
	    while ( i < info_ptr->num_trans ) {
233
	    while ( i < info_ptr->num_trans ) {
193
		image.setColor(i, qRgba(
234
		image.setColor(i, qRgba(
194
		    info_ptr->palette[i].red,
235
		    info_ptr->palette[i].red,
195
		    info_ptr->palette[i].green,
236
		    info_ptr->palette[i].green,
196
		    info_ptr->palette[i].blue,
237
		    info_ptr->palette[i].blue,
197
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=4 )
238
#endif /* LIBPNG 1.5 */
239
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
240
		    info_ptr_trans_alpha[i]
241
#elif ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=4 )
198
		    info_ptr->trans_alpha[i]
242
		    info_ptr->trans_alpha[i]
199
#else
243
#else
200
		    info_ptr->trans[i]
244
		    info_ptr->trans[i]
Lines 204-214 Link Here
204
		i++;
248
		i++;
205
	    }
249
	    }
206
	}
250
	}
251
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
252
	while ( i < info_ptr_num_palette ) {
253
	    image.setColor(i, qRgba(
254
		info_ptr_palette[i].red,
255
		info_ptr_palette[i].green,
256
		info_ptr_palette[i].blue,
257
#else /* LIBPNG 1.5 */
207
	while ( i < info_ptr->num_palette ) {
258
	while ( i < info_ptr->num_palette ) {
208
	    image.setColor(i, qRgba(
259
	    image.setColor(i, qRgba(
209
		info_ptr->palette[i].red,
260
		info_ptr->palette[i].red,
210
		info_ptr->palette[i].green,
261
		info_ptr->palette[i].green,
211
		info_ptr->palette[i].blue,
262
		info_ptr->palette[i].blue,
263
#endif /* LIBPNG 1.5 */
212
		0xff
264
		0xff
213
		)
265
		)
214
	    );
266
	    );
Lines 295-301 Link Here
295
	return;
347
	return;
296
    }
348
    }
297
349
350
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
351
    if (setjmp(png_jmpbuf(png_ptr))) {
352
#else /* LIBPNG 1.5 */
298
    if (setjmp(png_ptr->jmpbuf)) {
353
    if (setjmp(png_ptr->jmpbuf)) {
354
#endif /* LIBPNG 1.5 */
299
	png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
355
	png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
300
	iio->setStatus(-4);
356
	iio->setStatus(-4);
301
	return;
357
	return;
Lines 486-492 Link Here
486
	return FALSE;
542
	return FALSE;
487
    }
543
    }
488
544
545
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
546
    if (setjmp(png_jmpbuf(png_ptr))) {
547
#else /* LIBPNG 1.5 */
489
    if (setjmp(png_ptr->jmpbuf)) {
548
    if (setjmp(png_ptr->jmpbuf)) {
549
#endif /* LIBPNG 1.5 */
490
	png_destroy_write_struct(&png_ptr, &info_ptr);
550
	png_destroy_write_struct(&png_ptr, &info_ptr);
491
	return FALSE;
551
	return FALSE;
492
    }
552
    }
Lines 508-517 Link Here
508
568
509
    png_set_write_fn(png_ptr, (void*)this, qpiw_write_fn, qpiw_flush_fn);
569
    png_set_write_fn(png_ptr, (void*)this, qpiw_write_fn, qpiw_flush_fn);
510
570
571
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
572
#warning XXXtnn not too sure about this
573
/* 
574
according to png.h, channels is only used on read, not writes, so we
575
should be able to comment this out.
576
*/
577
#else /* LIBPNG 1.5 */
511
    info_ptr->channels =
578
    info_ptr->channels =
512
	(image.depth() == 32)
579
	(image.depth() == 32)
513
	    ? (image.hasAlphaBuffer() ? 4 : 3)
580
	    ? (image.hasAlphaBuffer() ? 4 : 3)
514
	    : 1;
581
	    : 1;
582
#endif /* LIBPNG 1.5 */
515
583
516
    png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(),
584
    png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(),
517
	image.depth() == 1 ? 1 : 8 /* per channel */,
585
	image.depth() == 1 ? 1 : 8 /* per channel */,
Lines 521-531 Link Here
521
		: PNG_COLOR_TYPE_RGB
589
		: PNG_COLOR_TYPE_RGB
522
	    : PNG_COLOR_TYPE_PALETTE, 0, 0, 0);
590
	    : PNG_COLOR_TYPE_PALETTE, 0, 0, 0);
523
591
524
592
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
593
    png_color_8 sig_bit;
594
    sig_bit.red = 8;
595
    sig_bit.green = 8;
596
    sig_bit.blue = 8;
597
    png_set_sBIT(png_ptr, info_ptr, &sig_bit);
598
#else /* LIBPNG 1.5 */
525
    //png_set_sBIT(png_ptr, info_ptr, 8);
599
    //png_set_sBIT(png_ptr, info_ptr, 8);
526
    info_ptr->sig_bit.red = 8;
600
    info_ptr->sig_bit.red = 8;
527
    info_ptr->sig_bit.green = 8;
601
    info_ptr->sig_bit.green = 8;
528
    info_ptr->sig_bit.blue = 8;
602
    info_ptr->sig_bit.blue = 8;
603
#endif /* LIBPNG 1.5 */
529
604
530
    if (image.depth() == 1 && image.bitOrder() == QImage::LittleEndian)
605
    if (image.depth() == 1 && image.bitOrder() == QImage::LittleEndian)
531
       png_set_packswap(png_ptr);
606
       png_set_packswap(png_ptr);
Lines 539-549 Link Here
539
	png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
614
	png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
540
	int* trans = new int[num_palette];
615
	int* trans = new int[num_palette];
541
	int num_trans = 0;
616
	int num_trans = 0;
617
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
618
	png_colorp info_ptr_palette = NULL;
619
	int tmp;
620
	png_get_PLTE(png_ptr, info_ptr, &info_ptr_palette, &tmp);
621
#endif /* LIBPNG 1.5 */
542
	for (int i=0; i<num_palette; i++) {
622
	for (int i=0; i<num_palette; i++) {
543
	    QRgb rgb=image.color(i);
623
	    QRgb rgb=image.color(i);
624
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
625
	    info_ptr_palette[i].red = qRed(rgb);
626
	    info_ptr_palette[i].green = qGreen(rgb);
627
	    info_ptr_palette[i].blue = qBlue(rgb);
628
#else /* LIBPNG 1.5 */
544
	    info_ptr->palette[i].red = qRed(rgb);
629
	    info_ptr->palette[i].red = qRed(rgb);
545
	    info_ptr->palette[i].green = qGreen(rgb);
630
	    info_ptr->palette[i].green = qGreen(rgb);
546
	    info_ptr->palette[i].blue = qBlue(rgb);
631
	    info_ptr->palette[i].blue = qBlue(rgb);
632
#endif /* LIBPNG 1.5 */
547
	    if (image.hasAlphaBuffer()) {
633
	    if (image.hasAlphaBuffer()) {
548
		trans[i] = rgb >> 24;
634
		trans[i] = rgb >> 24;
549
		if (trans[i] < 255) {
635
		if (trans[i] < 255) {
Lines 551-556 Link Here
551
		}
637
		}
552
	    }
638
	    }
553
	}
639
	}
640
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
641
	png_set_PLTE(png_ptr, info_ptr, info_ptr_palette, num_palette);
642
#endif /* LIBPNG 1.5 */
554
	if (num_trans) {
643
	if (num_trans) {
555
	    copy_trans = new png_byte[num_trans];
644
	    copy_trans = new png_byte[num_trans];
556
	    for (int i=0; i<num_trans; i++)
645
	    for (int i=0; i<num_trans; i++)
Lines 561-567 Link Here
561
    }
650
    }
562
651
563
    if ( image.hasAlphaBuffer() ) {
652
    if ( image.hasAlphaBuffer() ) {
653
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
654
        png_color_8p sig_bit;
655
        png_get_sBIT(png_ptr, info_ptr, &sig_bit);
656
        sig_bit->alpha = 8;
657
        png_set_sBIT(png_ptr, info_ptr, sig_bit);
658
#else /* LIBPNG 1.5 */
564
	info_ptr->sig_bit.alpha = 8;
659
	info_ptr->sig_bit.alpha = 8;
660
#endif /* LIBPNG 1.5 */
565
    }
661
    }
566
662
567
    // Swap ARGB to RGBA (normal PNG format) before saving on
663
    // Swap ARGB to RGBA (normal PNG format) before saving on
Lines 1047-1053 Link Here
1047
	    return -1;
1143
	    return -1;
1048
	}
1144
	}
1049
1145
1146
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
1147
	if (setjmp(png_jmpbuf(png_ptr))) {
1148
#else /* LIBPNG 1.5 */
1050
	if (setjmp((png_ptr)->jmpbuf)) {
1149
	if (setjmp((png_ptr)->jmpbuf)) {
1150
#endif /* LIBPNG 1.5 */
1051
	    png_destroy_read_struct(&png_ptr, &info_ptr, 0);
1151
	    png_destroy_read_struct(&png_ptr, &info_ptr, 0);
1052
	    image = 0;
1152
	    image = 0;
1053
	    return -1;
1153
	    return -1;
Lines 1074-1080 Link Here
1074
1174
1075
    if ( !png_ptr ) return 0;
1175
    if ( !png_ptr ) return 0;
1076
1176
1177
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
1178
    if (setjmp(png_jmpbuf(png_ptr))) {
1179
#else /* LIBPNG 1.5 */
1077
    if (setjmp(png_ptr->jmpbuf)) {
1180
    if (setjmp(png_ptr->jmpbuf)) {
1181
#endif /* LIBPNG 1.5 */
1078
	png_destroy_read_struct(&png_ptr, &info_ptr, 0);
1182
	png_destroy_read_struct(&png_ptr, &info_ptr, 0);
1079
	image = 0;
1183
	image = 0;
1080
	state = MovieStart;
1184
	state = MovieStart;
Lines 1134-1140 Link Here
1134
    consumer->frameDone(QPoint(offx,offy),r);
1238
    consumer->frameDone(QPoint(offx,offy),r);
1135
    consumer->end();
1239
    consumer->end();
1136
    state = FrameStart;
1240
    state = FrameStart;
1241
#if PNG_LIBPNG_VER_MAJOR>1 || ( PNG_LIBPNG_VER_MAJOR==1 && PNG_LIBPNG_VER_MINOR>=5 )
1242
    unused_data = png_process_data_pause(png, 0);
1243
#else /* LIBPNG 1.5 */
1137
    unused_data = (int)png->buffer_size; // Since libpng doesn't tell us
1244
    unused_data = (int)png->buffer_size; // Since libpng doesn't tell us
1245
#endif /* LIBPNG 1.5 */
1138
}
1246
}
1139
1247
1140
#ifdef PNG_USER_CHUNKS_SUPPORTED
1248
#ifdef PNG_USER_CHUNKS_SUPPORTED

Return to bug 683