Fresco/Berlin/src PNG.cc,1.6,1.7 RasterImpl.cc,1.5,1.6
Nick Lewycky <[email protected]>
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Berlin/src
In directory purcel:/tmp/cvs-serv24544/Berlin/src
Modified Files:
PNG.cc RasterImpl.cc
Log Message:
Implement RasterImpl::load_pixels()
Index: PNG.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/src/PNG.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- PNG.cc 9 Feb 2003 19:03:54 -0000 1.6
+++ PNG.cc 17 Feb 2003 02:05:33 -0000 1.7
@@ -341,10 +341,39 @@
return colors;
}
-void PNG::pixels(unsigned long xlower, unsigned long ylower, unsigned long xupper, unsigned long yupper,
- const Raster::ColorSeq &pixels, unsigned char **rows)
+unsigned char **PNG::pixels(unsigned long xlower, unsigned long ylower,
+ unsigned long xupper, unsigned long yupper,
+ const Raster::ColorSeq &pixels)
{
- std::cerr << "sorry, PNG::pixels not yet implemented" << std::endl;
+ png_uint_32 width = xupper - xlower;
+ png_uint_32 height = yupper - ylower;
+
+ clear();
+
+ _rinfo->color_type = rgbalpha;
+ _rinfo->bit_depth = 8;
+ _rinfo->width = width;
+ _rinfo->height = height;
+ _rinfo->rowbytes = width*4;
+ //_rinfo->compression_type = 0;
+ //_rinfo->filter =
+ //_rinfo->interlace
+
+ unsigned char **rows = new unsigned char *[height];
+ for (png_uint_32 y = ylower, i = 0; y != yupper; y++, i++)
+ {
+ rows[y] = new unsigned char[_rinfo->rowbytes];
+ for (png_uint_32 x = xlower, j = 0; x != xupper; x++, j++)
+ {
+ Color color = pixels[i*width + j];
+ rows[y][4*x] = static_cast<unsigned char>(color.red * 255);
+ rows[y][4*x+1] = static_cast<unsigned char>(color.green * 255);
+ rows[y][4*x+2] = static_cast<unsigned char>(color.blue * 255);
+ rows[y][4*x+3] = static_cast<unsigned char>(color.alpha * 255);
+ }
+ }
+
+ return rows;
}
unsigned char **PNG::read(const std::string &file)
Index: RasterImpl.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/src/RasterImpl.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- RasterImpl.cc 9 Feb 2003 19:03:54 -0000 1.5
+++ RasterImpl.cc 17 Feb 2003 02:05:33 -0000 1.6
@@ -103,7 +103,7 @@
void RasterImpl::load_pixels(const Fresco::Raster::Index &lower, const Fresco::Raster::Index &upper, const Fresco::Raster::ColorSeq &pixels)
{
Trace trace("RasterImpl::load_pixels");
- _png.pixels(lower.x, lower.y, upper.x, upper.y, pixels, _rows);
+ _rows = _png.pixels(lower.x, lower.y, upper.x, upper.y, pixels);
}
void RasterImpl::write(const char *file)