Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37576265
en ru br
Репозитории ALT
S:4.4.0-alt4
5.1: 3.9.5-alt1.M50P.1
4.1: 3.8.2-alt2.M41.4
4.0: 3.8.2-alt2
+updates:3.8.2-alt2
3.0: 3.7.2-alt5
www.altlinux.org/Changes

Группа :: Система/Библиотеки
Пакет: libtiff

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: libtiff-3.7.2-cvs-tiff2pdf.patch
Скачать


Index: tools/tiff2pdf.c
===================================================================
RCS file: /cvs/maptools/cvsroot/libtiff/tools/tiff2pdf.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -p -r1.19 -r1.20
--- tools/tiff2pdf.c	28 Oct 2004 13:32:28 -0000	1.19
+++ tools/tiff2pdf.c	18 Mar 2005 09:47:34 -0000	1.20
@@ -1,8 +1,12 @@
-/* $Id: tiff2pdf.c,v 1.19 2004/10/28 13:32:28 fwarmerdam Exp $
+/* $Id: tiff2pdf.c,v 1.20 2005/03/18 09:47:34 dron Exp $
  *
  * tiff2pdf - converts a TIFF image to a PDF document
  *
  * $Log: tiff2pdf.c,v $
+ * Revision 1.20  2005/03/18 09:47:34  dron
+ * Fixed problem with alpha channel handling as per bug
+ * http://bugzilla.remotesensing.org/show_bug.cgi?id=794
+ *
  * Revision 1.19  2004/10/28 13:32:28  fwarmerdam
  * provide explicit unsigned char casts for a few values to avoid warnings
  *
@@ -1387,23 +1391,25 @@ void t2p_read_tiff_data(T2P* t2p, TIFF* 
 			break;
 		case PHOTOMETRIC_RGB: 
 			t2p->pdf_colorspace=T2P_CS_RGB;
-			if(t2p->tiff_samplesperpixel==3){
+			if(t2p->tiff_samplesperpixel == 3){
 				break;
 			}
 			if(TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)){
-				if(xuint16==1){
-						goto photometric_palette;
-				}
+				if(xuint16==1)
+					goto photometric_palette;
 			}
-			if(t2p->tiff_samplesperpixel>3){
-				if(t2p->tiff_samplesperpixel==4){
-					t2p->pdf_colorspace=T2P_CS_RGB;
-					if(TIFFGetField(input, TIFFTAG_EXTRASAMPLES, &xuint16, &xuint16p)){
-						if(xuint16==EXTRASAMPLE_ASSOCALPHA){
+			if(t2p->tiff_samplesperpixel > 3) {
+				if(t2p->tiff_samplesperpixel == 4) {
+					t2p->pdf_colorspace = T2P_CS_RGB;
+					if(TIFFGetField(input,
+							TIFFTAG_EXTRASAMPLES,
+							&xuint16, &xuint16p)
+					   && xuint16 == 1) {
+						if(xuint16p[0] == EXTRASAMPLE_ASSOCALPHA){
 							t2p->pdf_sample=T2P_SAMPLE_RGBAA_TO_RGB;
 							break;
 						}
-						if(xuint16==EXTRASAMPLE_UNASSALPHA){
+						if(xuint16p[0] == EXTRASAMPLE_UNASSALPHA){
 							t2p->pdf_sample=T2P_SAMPLE_RGBA_TO_RGB;
 							break;
 						}
@@ -3507,12 +3513,10 @@ tsize_t t2p_sample_realize_palette(T2P* 
 tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32 samplecount){
 
 	uint32 i=0;
-	uint32 itimes3=0;
 	uint32 sample=0;
 	
 	for(i=0;i<samplecount;i++){
 		sample=((uint32*)data)[i];
-		itimes3=i*3;
 		((char*)data)[i*3]= (char) (sample & 0xff);
 		((char*)data)[i*3+1]= (char) ((sample>>8) & 0xff);
 		((char*)data)[i*3+2]= (char) ((sample>>16) & 0xff);
@@ -3522,42 +3526,34 @@ tsize_t t2p_sample_abgr_to_rgb(tdata_t d
 }
 
 /*
-	This functions converts in place a buffer of RGBA interleaved data
-	into RGB interleaved data, discarding A.
-*/
-
-tsize_t t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount){
+ * This functions converts in place a buffer of RGBA interleaved data
+ * into RGB interleaved data, discarding A.
+ */
 
-	uint32 i=0;
-	uint32 itimes3=0;
-	uint32 sample=0;
+tsize_t
+t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount)
+{
+	uint32 i, sample;
 	
-	for(i=0;i<samplecount;i++){
-		sample=((uint32*)data)[i];
-		itimes3=i*3;
-		((char*)data)[i*3]= (char) ((sample>>24) & 0xff);
-		((char*)data)[i*3+1]= (char) ((sample>>16) & 0xff);
-		((char*)data)[i*3+2]= (char) ((sample>>8) & 0xff);
-	}
+	for(i = 0; i < samplecount; i++)
+		memcpy((uint8*)data + i * 3, (uint8*)data + i * 4, 3);
 
-	return(i*3);
+	return(i * 3);
 }
 
 /*
-	This functions converts in place a buffer of RGBA interleaved data into RGB interleaved 
-	data, adding 255-A to each component sample.
+	This functions converts in place a buffer of RGBA interleaved data
+	into RGB interleaved data, adding 255-A to each component sample.
 */
 
 tsize_t t2p_sample_rgbaa_to_rgb(tdata_t data, uint32 samplecount){
 
 	uint32 i=0;
-	uint32 itimes3=0;
 	uint32 sample=0;
 	unsigned char alpha=0;
 	
 	for(i=0;i<samplecount;i++){
 		sample=((uint32*)data)[i];
-		itimes3=i*3;
 		alpha=(unsigned char)((255-(sample & 0xff)));
 		((unsigned char*)data)[i*3] =
 			(unsigned char) ((sample>>24) & 0xff);
@@ -3575,7 +3571,8 @@ tsize_t t2p_sample_rgbaa_to_rgb(tdata_t 
 }
 
 /*
-	This function converts the a and b samples of Lab data from signed to unsigned.
+	This function converts the a and b samples of Lab data from signed
+	to unsigned.
 */
 
 tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t buffer, uint32 samplecount){
@@ -3584,12 +3581,14 @@ tsize_t t2p_sample_lab_signed_to_unsigne
 
 	for(i=0;i<samplecount;i++){
 		if( (((unsigned char*)buffer)[(i*3)+1] & 0x80) !=0){
-			((unsigned char*)buffer)[(i*3)+1] = (unsigned char)(0x80 + ((char*)buffer)[(i*3)+1]);
+			((unsigned char*)buffer)[(i*3)+1] =
+				(unsigned char)(0x80 + ((char*)buffer)[(i*3)+1]);
 		} else {
 			((unsigned char*)buffer)[(i*3)+1] |= 0x80;
 		}
 		if( (((unsigned char*)buffer)[(i*3)+2] & 0x80) !=0){
-			((unsigned char*)buffer)[(i*3)+2] = (unsigned char)(0x80 + ((char*)buffer)[(i*3)+2]);
+			((unsigned char*)buffer)[(i*3)+2] =
+				(unsigned char)(0x80 + ((char*)buffer)[(i*3)+2]);
 		} else {
 			((unsigned char*)buffer)[(i*3)+2] |= 0x80;
 		}
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin