cvs: gd /libgd/src gd_tiff.c
[email protected] ("Mattias Bengtsson") Thu, 04 Oct 2007 22:01:16 -0000
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvsmattias1191535276@cvsserver> |
mattias Thu Oct 4 22:01:16 2007 UTC
Modified files:
/gd/libgd/src gd_tiff.c
Log:
- ws + cs
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_tiff.c?r1=1.5&r2=1.6&diff_format=u
Index: gd/libgd/src/gd_tiff.c
diff -u gd/libgd/src/gd_tiff.c:1.5 gd/libgd/src/gd_tiff.c:1.6
--- gd/libgd/src/gd_tiff.c:1.5 Thu Oct 4 21:49:51 2007
+++ gd/libgd/src/gd_tiff.c Thu Oct 4 22:01:15 2007
@@ -18,6 +18,8 @@
---------------------------------------------------------------------------
Todo:
+
+ If we fail - cleanup
(suggestions only)
Implement 2 color black/white saving using group4 fax compression
@@ -25,7 +27,7 @@
----------------------------------------------------------------------------
*/
-/* $Id: gd_tiff.c,v 1.5 2007/10/04 21:49:51 mattias Exp $ */
+/* $Id: gd_tiff.c,v 1.6 2007/10/04 22:01:15 mattias Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -182,9 +184,9 @@
*/
BGD_DECLARE(void) tiffWriter(gdImagePtr image, gdIOCtx *out, int bitDepth)
{
- int x,y;
+ int x, y;
int i;
- int r,g,b,a;
+ int r, g, b, a;
TIFF *tiff;
int width;
int height;
@@ -224,17 +226,20 @@
* functions so that tiff lib writes correct bits of tiff content to
* correct areas of file opened and modifieable by the gdIOCtx functions
*/
- tiff = TIFFClientOpen("", "w", th, tiff_readproc, tiff_writeproc,
- tiff_seekproc, tiff_closeproc, tiff_sizeproc,
- tiff_mapproc, tiff_unmapproc);
+ tiff = TIFFClientOpen("", "w", th, tiff_readproc,
+ tiff_writeproc,
+ tiff_seekproc,
+ tiff_closeproc,
+ tiff_sizeproc,
+ tiff_mapproc,
+ tiff_unmapproc);
TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, width);
TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, height);
TIFFSetField(tiff, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE);
TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, (bitDepth == 24) ?
- PHOTOMETRIC_RGB
- : PHOTOMETRIC_PALETTE);
+ TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC,
+ (bitDepth == 24) ? PHOTOMETRIC_RGB : PHOTOMETRIC_PALETTE);
bitsPerSample = (bitDepth ==24) ? 8 : ((bitDepth == 8) ? 8 : 1);
TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, bitsPerSample);
@@ -295,9 +300,9 @@
* then set alpha fully transparent */
if( transparentColourR == r &&
transparentColourG == g &&
- transparentColourB==b
+ transparentColourB == b
) {
- a=0x00;
+ a = 0x00;
}
if(bitDepth != 24) {
@@ -430,9 +435,9 @@
BGD_DECLARE(gdImagePtr) createFromTiffCtx1bit(TIFF *tiff, int width, int height)
{
gdImagePtr im = NULL;
- int x,y,
+ int x, y,
int tileX, tileY, tileMaxX, tileMaxY;
- int i,j,k;
+ int i, j, k;
int colour;
char *scan;
int compression;
@@ -469,8 +474,9 @@
if(!(scan = gdMalloc(tileSize))) {
return 0;
}
- tileX = 0;
- tileY = 0;
+
+ tileX = tileY = 0;
+
for(tileNum = 0; tileNum < numberOfTiles; tileNum++) {
TIFFReadEncodedTile(tiff, tileNum, scan, tileSize);
@@ -527,9 +533,11 @@
} else {
/* image is not tiled - assume stripped (scanline) format */
printf("is a 1bit scanline tiff!\n");
+
if(!(scan = gdMalloc(TIFFScanlineSize(tiff)))) {
return 0;
}
+
y = x = 0;
for(i = 0; i < height; i++) {
@@ -561,7 +569,7 @@
}
y++;
- x=0;
+ x = 0;
}
gdFree(scan);
@@ -615,8 +623,8 @@
if(!(scan = gdMalloc(tileSize))) {
return 0;
}
- tileX=0;
- tileY=0;
+
+ tileX = tileY = 0;
for(tileNum = 0; tileNum < numberOfTiles; tileNum++) {
TIFFReadEncodedTile(tiff, tileNum, scan, tileSize);
@@ -667,8 +675,8 @@
if(!(scan = gdMalloc(TIFFScanlineSize(tiff)))) {
return 0;
}
- y=0;
- x=0;
+
+ y = x = 0;
/* image is not tiled - assume scanline based images */
for(i = 0; i < height; i++) {
@@ -688,7 +696,7 @@
}
y++;
- x=0;
+ x = 0;
}
gdFree(scan);
@@ -737,6 +745,7 @@
* else use existing one */
rgba = scan[((y * width) + x)];
a = (0xff - TIFFGetA(rgba)) / 2;
+
b = TIFFGetB(rgba);
g = TIFFGetG(rgba);
r = TIFFGetR(rgba);