Hi,
pngread.cc does not check for the presence of alpha chanel, the
program assumes it always there.
Also gray images treated the same way as RGB ones ( 3 channel per
pixel are asumed
even though dimensions of the output were set to have only one channel).
I am attaching the patch fixing this issue.
--
Eugeniy
--- image/src/pngread.cc 2008-02-04 08:47:45.000000000 -0500
+++ image.new/src/pngread.cc 2009-03-12 20:54:30.000000000 -0400
@@ -87,6 +87,10 @@
if (pic->bit_depth > 1 && pic->bit_depth < 8)
pic->bit_depth = 8;
+ int isAlfaChannelPresent = 0;
+ if ( pic->color_type & PNG_COLOR_MASK_ALPHA)
+ isAlfaChannelPresent=1;
+
NDArray out(dim);
dim.resize(2);
@@ -94,6 +98,7 @@
Array<int> coord = Array<int> (3);
+ int ElementsPerPixel=out.dims()(2)+isAlfaChannelPresent;
for (unsigned long j=0; j < pic->height; j++) {
coord(0) = j;
for (unsigned long i=0; i < pic->width; i++) {
@@ -101,9 +106,12 @@
for (int c = 0; c < out.dims()(2); c++) {
coord(2) = c;
- out(coord) = pic->row_pointers[j][i*4+c];
+ out(coord) = pic->row_pointers[j][i*ElementsPerPixel+c];
}
- alpha(j,i) = pic->row_pointers[j][i*4+3];
+ if (isAlfaChannelPresent)
+ alpha(j,i) = pic->row_pointers[j][i*ElementsPerPixel+(ElementsPerPixel-1)];
+ else
+ alpha(j,i) = 1;
}
}
out = out.squeeze();
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev