From: Per P. <per...@ma...> - 2004-07-05 10:28:35
|
Hi, in preparing a new image.m for Mac OS X (based on code from J. Koski) that uses bmpwrite(), and I think I've found a bug in bmpwrite.m. The color for {R,G,B}={1, 1, 1} is random on OS X and I think the problem is that the index into colormap in a .bmp file is zero-based (couldn't find a definitive authority). The help for bmpwrite doesn't state that a zero-based index is used, so I assume that the patch below is the right fix. /Per Index: main/image/bmpwrite.m =================================================================== RCS file: /cvsroot/octave/octave-forge/main/image/bmpwrite.m,v retrieving revision 1.2 diff -u -d -b -w -r1.2 bmpwrite.m --- main/image/bmpwrite.m 27 Nov 2002 08:40:10 -0000 1.2 +++ main/image/bmpwrite.m 5 Jul 2004 10:16:01 -0000 @@ -37,7 +37,7 @@ ## raster image, each line on a 32-bit boundary, padded with zeros ## lines written bottom to top. - fwrite(file,postpad(flipud(x)',ceil(columns(x)/4)*4),"uchar",0,arch); + fwrite(file,postpad(flipud(x-1)',ceil(columns(x)/4)*4),"uchar",0,arch); fclose(file); endfunction |