| 120 | } |
| 121 | |
| 122 | void ImageTargetFileQoi::finalize() |
| 123 | { |
| 124 | qoi_desc desc; |
| 125 | desc.width = (unsigned int)mWidth; |
| 126 | desc.height = (unsigned int)mHeight; |
| 127 | desc.channels = mNumComponents; |
| 128 | desc.colorspace = QOI_SRGB; |
| 129 | |
| 130 | if( ! mFilePath.empty() ) { |
| 131 | if( ! qoiWritePath( mFilePath, mData.get(), &desc ) ) |
| 132 | throw ImageIoExceptionFailedWrite( "Failed to write QOI image" ); |
| 133 | } |
| 134 | else { |
| 135 | // Encode to memory |
| 136 | int encodedSize = 0; |
| 137 | void *encoded = qoi_encode( mData.get(), &desc, &encodedSize ); |
| 138 | if( ! encoded ) |
| 139 | throw ImageIoExceptionFailedWrite( "Failed to encode QOI image" ); |
| 140 | |
| 141 | // Write to stream |
| 142 | OStream *stream = mDataTarget->getStream().get(); |
| 143 | stream->writeData( encoded, static_cast<size_t>( encodedSize ) ); |
| 144 | |
| 145 | // Free the encoded buffer |
| 146 | free( encoded ); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | } // namespace cinder |
nothing calls this directly
no test coverage detected