/************************************************************************ Raster image support. $Id: raster.cxx 427 2004-09-27 04:45:31Z garland $ ************************************************************************/ #include #include #include #include #include namespace gfx { ByteRaster::ByteRaster(const ByteRaster &img) : Raster(img.width(), img.height(), img.channels()) { memcpy(head(), img.head(), img.length()*sizeof(unsigned char)); } ByteRaster::ByteRaster(const FloatRaster &img) : Raster(img.width(), img.height(), img.channels()) { for(int i=0; i(img.width(), img.height(), img.channels()) { for(int i=0; i(img.width(), img.height(), img.channels()) { memcpy(head(), img.head(), img.length()*sizeof(float)); } //////////////////////////////////////////////////////////////////////// // // Table of supported formats // static char *img_names[] = {"PPM", "PNG", "TIFF", "JPEG"}; static char *img_ext[] = {"ppm", "png", "tif", "jpg"}; const char *image_type_name(int type) { return type>=IMG_LIMIT ? NULL : img_names[type]; } const char *image_type_ext(int type) { return type>=IMG_LIMIT ? NULL : img_ext[type]; } int infer_image_type(const char *filename) { const char *ext = strrchr(filename, '.'); if( !ext ) return -1; // Make sure extension is lower case std::string lo(ext+1); for(int i=0; i