Anonymous avatar Anonymous committed 3caaf9d

- ws + cs

Comments (0)

Files changed (1)

    ---------------------------------------------------------------------------
 
    Todo:
+
+   If we fail - cleanup
    
    (suggestions only)
    Implement 2 color black/white saving using group4 fax compression
  */
 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;
 	 * 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);
 			 * then set alpha fully transparent */
 			if(	transparentColourR == r &&
 				transparentColourG == g &&
-				transparentColourB==b
+				transparentColourB == b
 			) {
-				a=0x00;
+				a = 0x00;
 			}
 
 			if(bitDepth != 24) {
 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;
 		if(!(scan = gdMalloc(tileSize))) {
 			return 0;
 		}
-		tileX = 0;
-		tileY = 0;
+
+		tileX = tileY = 0;
+
 		for(tileNum = 0; tileNum < numberOfTiles; tileNum++) {
 			TIFFReadEncodedTile(tiff, tileNum, scan, tileSize); 
 
 	} 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++) {
 			}
 
 			y++;
-			x=0;
+			x = 0;
 		}
 
 		gdFree(scan);
 		if(!(scan = gdMalloc(tileSize))) {
 			return 0;
 		}
-		tileX=0;
-		tileY=0;
+
+		tileX = tileY = 0;
 
 		for(tileNum = 0; tileNum < numberOfTiles; tileNum++) {
 			TIFFReadEncodedTile(tiff, tileNum, scan, tileSize);
 		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++) {
 			}
 			
 			y++;
-			x=0;
+			x = 0;
 		}
 
 		gdFree(scan);
 			 * else use existing one */
 			rgba = scan[((y * width) + x)];
 			a = (0xff - TIFFGetA(rgba)) / 2;
+
 			b = TIFFGetB(rgba);
 			g = TIFFGetG(rgba);
 			r = TIFFGetR(rgba);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.