MCPcopy Create free account
hub / github.com/cinder/Cinder / ImageSourcePng

Method ImageSourcePng

src/cinder/ImageSourcePng.cpp:79–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79ImageSourcePng::ImageSourcePng( DataSourceRef dataSourceRef, ImageSource::Options /*options*/ )
80 : ImageSource(), mInfoPtr( 0 ), mPngPtr( 0 )
81{
82 mPngPtr = png_create_read_struct( PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL );
83 if( ! mPngPtr ) {
84 throw ImageSourcePngException( "Could not create png struct." );
85 }
86
87 mCiInfoPtr = shared_ptr<ci_png_info>( new ci_png_info );
88 mCiInfoPtr->srcStreamRef = dataSourceRef->createStream();
89
90 png_set_read_fn( mPngPtr, reinterpret_cast<void*>( mCiInfoPtr.get() ), ci_PNG_stream_reader );
91 mInfoPtr = png_create_info_struct( mPngPtr );
92
93 if( ! mInfoPtr ) {
94 png_destroy_read_struct( &mPngPtr, (png_infopp)NULL, (png_infopp)NULL );
95 mPngPtr = 0;
96 throw ImageSourcePngException( "Could not destroy png read struct." );
97 }
98
99 if( ! loadHeader() )
100 throw ImageSourcePngException( "Could not load png header." );
101}
102
103// part of this being separated allows for us to play nicely with the setjmp of libpng
104bool ImageSourcePng::loadHeader()

Callers

nothing calls this directly

Calls 3

createStreamMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected