Commits

Anonymous committed c67b1b0

- missing ;
- add casting
- fix logic in malloc test

Comments (0)

Files changed (1)

    Todo:
 
    If we fail - cleanup
-   
+   Writer: Use gd error function, overflow check may not be necessary as
+	 we write our own data (check already done)
+
    (suggestions only)
    Implement 2 color black/white saving using group4 fax compression
    Implement function to specify encoding to use when writing tiff data
 
 tiff_handle *new_tiff_handle(tiff_handle *t, gdIOCtx *g)
 {
-	if(!t || !g || (t = gdMalloc(sizeof(tiff_handle)))) {
+	t = (tiff_handle *) gdMalloc(sizeof(tiff_handle));
+	if(!t || !g) {
 		return 0;
 	}
 
 	/* build the color map for 8 bit images */
 	if(bitDepth != 24) {
 		/*TODO: Add checking */
-		colorMapRed = gdMalloc(3 * pow(2, bitsPerSample));
-		colorMapGreen = gdMalloc(3 * pow(2, bitsPerSample));
-		colorMapBlue = gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapRed = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapGreen = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapBlue = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample));
 
 		for(i = 0; i < image->colorsTotal; i++) {
 			colorMapRed[i] = gdImageRed(image,i) + (gdImageRed(image,i) * 256);
 	TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, 1);
 
 	if(overflow2(width, samplesPerPixel)) {
-		return 0;
+		return;
 	}
 
-	if(!(scan = gdMalloc(width * samplesPerPixel))) {
-		return 0;
+	if(!(scan = (char *)gdMalloc(width * samplesPerPixel))) {
+		return;
 	}
 
 	/* loop through y-coords, and x-coords */
 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 colour;
 		TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileMaxY);
 
 		tileSize = TIFFTileSize(tiff);
-		if(!(scan = gdMalloc(tileSize))) {
+		if(!(scan = (char *) gdMalloc(tileSize))) {
 			return 0;
 		}
 
 		/* image is not tiled - assume stripped (scanline) format */
 		printf("is a 1bit scanline tiff!\n");
 
-		if(!(scan = gdMalloc(TIFFScanlineSize(tiff)))) {
+		if(!(scan = (char *) gdMalloc(TIFFScanlineSize(tiff)))) {
 			return 0;
 		}
 
 		TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileMaxY);
 
 		tileSize = TIFFTileSize(tiff);
-		if(!(scan = gdMalloc(tileSize))) {
+		if(!(scan = (char*) gdMalloc(tileSize))) {
 			return 0;
 		}
 
 		gdFree(scan);
 
 	} else {
-		if(!(scan = gdMalloc(TIFFScanlineSize(tiff)))) {
+		if(!(scan = (char *)gdMalloc(TIFFScanlineSize(tiff)))) {
 			return 0;
 		}