From: Wheeler, F. W (Research) <wh...@cr...> - 2004-01-13 20:51:29
|
Petr, I get this error with your patch. Building object file vil_png.obj... vil_png.cxx C:\cygwin\home\200006507\dev\vxl_src\core\vil\file_formats\vil_png.cxx(382) : error C2065: 'PNG_COLOR_TYPE_RGBA' : undeclared identifier All my builds use the png from vxl/v3p/png/. According to vxl/v3p/png.URL, that is derived from this version, ftp://ftp.uu.net/graphics/png/src/libpng-1.0.8.tar.gz I see PNG_COLOR_TYPE_RGB_ALPHA defined in there. I assume you are using some different version of png. Can you make your patch accommodate both? Perhaps a few ifdefs will do it. Fred Wheeler > -----Original Message----- > From: Petr Konecny [mailto:pe...@am...] > Sent: Tuesday, January 13, 2004 3:28 PM > To: vxl...@li... > Subject: [Vxl-users] [patch] add RGBA support for saving PNG files > > > Hi, > > the following adds support for saving alpha channel into RGB PNG > files. Tested both for 8 and 16 bits/channel. > > I use test nplanes()==4 as an indication of RGBA file. IMHO > this should > not break existing code, because the original version halts on assert > when nplanes()==4. > > PNG supports alpha also for grayscale images, however I did not > implement it. > > Thanks, Petr > > Index: core/vil/file_formats/vil_png.cxx > =================================================================== > RCS file: /cvsroot/vxl/vxl/core/vil/file_formats/vil_png.cxx,v > retrieving revision 1.16 > diff -u -r1.16 vil_png.cxx > --- core/vil/file_formats/vil_png.cxx 9 Dec 2003 14:58:16 > -0000 1.16 > +++ core/vil/file_formats/vil_png.cxx 13 Jan 2004 20:21:03 -0000 > @@ -378,7 +378,9 @@ > png_set_write_fn(p_->png_ptr, vs_, user_write_data, > user_flush_data); > > int color_type; > - if (components_ == 3) > + if (components_ == 4) > + color_type = PNG_COLOR_TYPE_RGBA; > + else if (components_ == 3) > color_type = PNG_COLOR_TYPE_RGB; > else > color_type = PNG_COLOR_TYPE_GRAY; > @@ -488,9 +490,8 @@ > for (unsigned x=0; x < view.ni(); ++x) > rows[y0+y][x0+x] = view2(x,y); > } > - else > + else if (nplanes()==3) > { > - assert(nplanes() == 3); > for (unsigned y = 0; y < view.nj(); ++y) > for (unsigned x=0; x < view.ni(); ++x) > { > @@ -499,6 +500,18 @@ > rows[y0+y][(x0+x)*3+2] = view2(x,y,2); > } > } > + else > + { > + assert(nplanes() == 4); > + for (unsigned y = 0; y < view.nj(); ++y) > + for (unsigned x=0; x < view.ni(); ++x) > + { > + rows[y0+y][(x0+x)*4] = view2(x,y,0); > + rows[y0+y][(x0+x)*4+1] = view2(x,y,1); > + rows[y0+y][(x0+x)*4+2] = view2(x,y,2); > + rows[y0+y][(x0+x)*4+3] = view2(x,y,3); > + } > + } > } > else if (bits_per_component_ == 16) > { > @@ -510,15 +523,26 @@ > for (unsigned x=0; x < view.ni(); ++x) > > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*2]) = view2(x,y); > } > - else > + else if (nplanes() == 3) > { > - assert(nplanes() == 3); > for (unsigned y = 0; y < view.nj(); ++y) > for (unsigned x=0; x < view.ni(); ++x) > { > > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*6]) = view2(x,y,0); > > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*6+2]) = > view2(x,y,1); > > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*6+4]) = > view2(x,y,2); > + } > + } > + else > + { > + assert(nplanes() == 4); > + for (unsigned y = 0; y < view.nj(); ++y) > + for (unsigned x=0; x < view.ni(); ++x) > + { > + > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*8]) = view2(x,y,0); > + > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*8+2]) = > view2(x,y,1); > + > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*8+4]) = > view2(x,y,2); > + > *reinterpret_cast<vxl_uint_16*>(&rows[y0+y][(x0+x)*8+6]) = > view2(x,y,3); > } > } > } > > > ------------------------------------------------------- > This SF.net email is sponsored by: Perforce Software. > Perforce is the Fast Software Configuration Management System offering > advanced branching capabilities and atomic changes on 50+ platforms. > Free Eval! http://www.perforce.com/perforce/loadprog.html > _______________________________________________ > Vxl-users mailing list > Vxl...@li... > https://lists.sourceforge.net/lists/listinfo/vxl-users > |