| 85 | } |
| 86 | |
| 87 | ImageTargetFileQoi::ImageTargetFileQoi( DataTargetRef dataTarget, ImageSourceRef imageSource, ImageTarget::Options options, const std::string &extensionData ) |
| 88 | : mDataTarget( dataTarget ) |
| 89 | { |
| 90 | if( ! ( mDataTarget->providesFilePath() || mDataTarget->getStream() ) ) { |
| 91 | throw ImageIoExceptionFailedWrite( "No file path or stream provided" ); |
| 92 | } |
| 93 | |
| 94 | setSize( imageSource->getWidth(), imageSource->getHeight() ); |
| 95 | ImageIo::ColorModel cm = options.isColorModelDefault() ? imageSource->getColorModel() : options.getColorModel(); |
| 96 | |
| 97 | switch( cm ) { |
| 98 | case ImageIo::ColorModel::CM_RGB: |
| 99 | mNumComponents = ( imageSource->hasAlpha() ) ? 4 : 3; |
| 100 | setColorModel( ImageIo::ColorModel::CM_RGB ); |
| 101 | setChannelOrder( ( mNumComponents == 4 ) ? ImageIo::ChannelOrder::RGBA : ImageIo::ChannelOrder::RGB ); |
| 102 | break; |
| 103 | default: |
| 104 | throw ImageIoExceptionIllegalColorModel( "QOI only supports RGB/RGBA color models" ); |
| 105 | } |
| 106 | |
| 107 | setDataType( ImageIo::DataType::UINT8 ); |
| 108 | mRowBytes = mNumComponents * imageSource->getWidth(); |
| 109 | |
| 110 | if( mDataTarget->providesFilePath() ) { |
| 111 | mFilePath = dataTarget->getFilePath(); |
| 112 | } |
| 113 | |
| 114 | mData = std::unique_ptr<uint8_t[]>( new uint8_t[mHeight * mRowBytes] ); |
| 115 | } |
| 116 | |
| 117 | void* ImageTargetFileQoi::getRowPointer( int32_t row ) |
| 118 | { |
nothing calls this directly
no test coverage detected