Go to the documentation of this file.
34 bool ImageConverter::initializeSFImage( )
38 image->numComponents = 0;
39 image->pixels.clear();
60 SFImage* ImageConverter::convert(
string url )
63 string ext = url.substr( url.rfind(
'.' ) );
66 transform( ext.begin(), ext.end(), ext.begin(), (
int(*)(
int))tolower );
69 if( !ext.compare(
".png" ) )
74 else if( !ext.compare(
".jpg" ) )
86 image->numComponents = 0;
87 image->pixels.resize(0);
105 ImageConverter::loadPNG(
109 initializeSFImage( );
116 fp = fopen( filePath.c_str(),
"rb" );
117 if( !
fp )
throw "File open error.";
125 fread( header, 1, number,
fp );
127 if( !is_png )
throw "File is not png.";
134 if( !pPng )
throw "Failed to create png_struct";
144 throw "Failed to create png_info";
169 #if PNG_LIBPNG_VER_MINOR >= 4
218 image->numComponents = numComponents;
229 cout <<
"PNG read error: " << str <<
'\n';
230 if(
fp ) fclose(
fp );
251 ImageConverter::loadJPEG(
254 initializeSFImage( );
261 fp = fopen( filePath.c_str(),
"rb" );
262 if( !
fp )
throw "File open error.";
284 (
void)jpeg_start_decompress( &cinfo );
295 for (
int i = 0;
i <
image->height;
i++ )
320 cout <<
"JPEG read error: " << str <<
'\n';
321 if(
fp ) fclose(
fp );
Header file of Image Converter class.
png_uint_32 PNGAPI png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
void PNGAPI png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)
png_byte PNGAPI png_get_color_type(png_structp png_ptr, png_infop info_ptr)
png_infop png_uint_32 * width
JDIMENSION output_scanline
jpeg_std_error(struct jpeg_error_mgr *err)
png_uint_32 PNGAPI png_get_image_width(png_structp png_ptr, png_infop info_ptr)
jpeg_finish_decompress(j_decompress_ptr cinfo)
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
#define jpeg_create_decompress(cinfo)
void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
#define PNG_COLOR_TYPE_RGB_ALPHA
png_infop PNGAPI png_create_info_struct(png_structp png_ptr)
void PNGAPI png_set_tRNS_to_alpha(png_structp png_ptr)
png_infop png_bytepp row_pointers
png_byte FAR *FAR * png_bytepp
#define PNG_COLOR_TYPE_RGB
void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes)
int PNGAPI png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
void PNGAPI png_set_strip_16(png_structp png_ptr)
#define PNG_COLOR_TYPE_GRAY
void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr)
png_struct FAR * png_structp
png_uint_32 PNGAPI png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp)
void PNGAPI png_set_palette_to_rgb(png_structp png_ptr)
png_uint_32 PNGAPI png_get_image_height(png_structp png_ptr, png_infop info_ptr)
png_structp PNGAPI png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
#define PNG_LIBPNG_VER_STRING
png_byte PNGAPI png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
jpeg_destroy_decompress(j_decompress_ptr cinfo)
typedef void(PNGAPI *png_error_ptr) PNGARG((png_structp
unsigned long png_uint_32
png_infop png_uint_32 png_uint_32 * height
void PNGAPI png_set_packing(png_structp png_ptr)
jpeg_stdio_src(j_decompress_ptr cinfo, FILE *infile)
png_infop png_uint_32 png_uint_32 int int * color_type
#define PNG_COLOR_TYPE_GRAY_ALPHA
void PNGAPI png_set_gray_1_2_4_to_8(png_structp png_ptr)
void PNGAPI png_read_image(png_structp png_ptr, png_bytepp image)
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
#define PNG_COLOR_TYPE_PALETTE
void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr)
openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:03