| 105 | } |
| 106 | |
| 107 | void 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 |
nothing calls this directly
no test coverage detected