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

Method finalize

src/cinder/ImageTargetFileStbImage.cpp:107–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void ImageTargetFileStbImage::finalize()
108{
109 if( ! mFilePath.empty() ) {
110 if( mExtension == "png" ) {
111 if( ! stbi_write_png( mFilePath.string().c_str(), (int)mWidth, (int)mHeight, mNumComponents, mData.get(), (int)mRowBytes ) )
112 throw ImageIoExceptionFailedWrite();
113 }
114 else if( mExtension == "bmp" ) {
115 if( ! stbi_write_bmp( mFilePath.string().c_str(), (int)mWidth, (int)mHeight, mNumComponents, mData.get() ) )
116 throw ImageIoExceptionFailedWrite();
117 }
118 else if( mExtension == "tga" ) {
119 if( ! stbi_write_tga( mFilePath.string().c_str(), (int)mWidth, (int)mHeight, mNumComponents, mData.get() ) )
120 throw ImageIoExceptionFailedWrite();
121 }
122 else if( mExtension == "hdr" ) {
123 if( ! stbi_write_hdr( mFilePath.string().c_str(), (int)mWidth, (int)mHeight, mNumComponents, (const float*)mData.get() ) )
124 throw ImageIoExceptionFailedWrite();
125 }
126 }
127 else {
128 OStream *stream = mDataTarget->getStream().get();
129 if( mExtension == "png" ) {
130 if( ! stbi_write_png_to_func( stbWriteToStream, stream, (int)mWidth, (int)mHeight, mNumComponents, mData.get(), (int)mRowBytes ) )
131 throw ImageIoExceptionFailedWrite();
132 }
133 else if( mExtension == "bmp" ) {
134 if( ! stbi_write_bmp_to_func( stbWriteToStream, stream, (int)mWidth, (int)mHeight, mNumComponents, mData.get() ) )
135 throw ImageIoExceptionFailedWrite();
136 }
137 else if( mExtension == "tga" ) {
138 if( ! stbi_write_tga_to_func( stbWriteToStream, stream, (int)mWidth, (int)mHeight, mNumComponents, mData.get() ) )
139 throw ImageIoExceptionFailedWrite();
140 }
141 else if( mExtension == "hdr" ) {
142 if( ! stbi_write_hdr_to_func( stbWriteToStream, stream, (int)mWidth, (int)mHeight, mNumComponents, (const float*)mData.get() ) )
143 throw ImageIoExceptionFailedWrite();
144 }
145 }
146}
147
148} // namespace cinder

Callers

nothing calls this directly

Calls 13

getStreamMethod · 0.80
stbi_write_pngFunction · 0.50
stbi_write_bmpFunction · 0.50
stbi_write_tgaFunction · 0.50
stbi_write_hdrFunction · 0.50
stbi_write_png_to_funcFunction · 0.50
stbi_write_bmp_to_funcFunction · 0.50
stbi_write_tga_to_funcFunction · 0.50
stbi_write_hdr_to_funcFunction · 0.50
emptyMethod · 0.45
c_strMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected