[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28577] branches/render25/source/blender/ imbuf/intern/tiff.c: Fix wrong pixels when reading small mipmap levels from .tx files.

Brecht Van Lommel brecht at blender.org
Tue May 4 18:54:01 CEST 2010


Revision: 28577
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28577
Author:   blendix
Date:     2010-05-04 18:54:00 +0200 (Tue, 04 May 2010)

Log Message:
-----------
Fix wrong pixels when reading small mipmap levels from .tx files.

Modified Paths:
--------------
    branches/render25/source/blender/imbuf/intern/tiff.c

Modified: branches/render25/source/blender/imbuf/intern/tiff.c
===================================================================
--- branches/render25/source/blender/imbuf/intern/tiff.c	2010-05-04 15:36:11 UTC (rev 28576)
+++ branches/render25/source/blender/imbuf/intern/tiff.c	2010-05-04 16:54:00 UTC (rev 28577)
@@ -464,11 +464,16 @@
 
 		if(width == ibuf->x && height == ibuf->y) {
 			if(rect) {
-				/* why flip y tile location, seems to contradict TIFFReadRGBATile man page? */
-				libtiff_TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect);
+				/* tiff pixels are bottom to top, tiles are top to bottom */
+				if(libtiff_TIFFReadRGBATile(image, tx*ibuf->tilex, (ibuf->ytiles - 1 - ty)*ibuf->tiley, rect) == 1) {
+					if(ibuf->tiley > ibuf->y)
+						memmove(rect, rect+ibuf->tilex*(ibuf->tiley - ibuf->y), sizeof(int)*ibuf->tilex*ibuf->y);
 
-				if(ibuf->flags & IB_premul)
-					IMB_premultiply_rect(rect, 32, ibuf->tilex, ibuf->tiley);
+					if(ibuf->flags & IB_premul)
+						IMB_premultiply_rect(rect, 32, ibuf->tilex, ibuf->tiley);
+				}
+				else
+					printf("imb_loadtiff: failed to read tiff tile at mipmap level %d\n", ibuf->miplevel);
 			}
 		}
 		else





More information about the Bf-blender-cvs mailing list