| 1 |
/* |
| 2 |
libheif example application. |
| 3 |
|
| 4 |
MIT License |
| 5 |
|
| 6 |
Copyright (c) 2024 Brad Hards <[email protected]> |
| 7 |
|
| 8 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 |
of this software and associated documentation files (the "Software"), to deal |
| 10 |
in the Software without restriction, including without limitation the rights |
| 11 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 |
copies of the Software, and to permit persons to whom the Software is |
| 13 |
furnished to do so, subject to the following conditions: |
| 14 |
|
| 15 |
The above copyright notice and this permission notice shall be included in all |
| 16 |
copies or substantial portions of the Software. |
| 17 |
|
| 18 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 |
SOFTWARE. |
| 25 |
*/ |
| 26 |
#ifndef EXAMPLE_ENCODER_TIFF_H |
| 27 |
#define EXAMPLE_ENCODER_TIFF_H |
| 28 |
|
| 29 |
#include <string> |
| 30 |
|
| 31 |
#include "encoder.h" |
| 32 |
|
| 33 |
class TiffEncoder : public Encoder |
| 34 |
{ |
| 35 |
public: |
| 36 |
TiffEncoder(); |
| 37 |
|
| 38 |
|
| 39 |
heif_colorspace colorspace(bool has_alpha) const override |
| 40 |
{ |
| 41 |
return heif_colorspace_RGB; |
| 42 |
} |
| 43 |
|
| 44 |
heif_chroma chroma(bool has_alpha, int bit_depth) const override |
| 45 |
{ |
| 46 |
if (bit_depth == 8) { |
| 47 |
if (has_alpha) |
| 48 |
return heif_chroma_interleaved_RGBA; |
| 49 |
else |
| 50 |
return heif_chroma_interleaved_RGB; |
| 51 |
} |
| 52 |
else { |
| 53 |
if (has_alpha) |
| 54 |
return heif_chroma_interleaved_RRGGBBAA_BE; |
| 55 |
else |
| 56 |
return heif_chroma_interleaved_RRGGBB_BE; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
bool supports_alpha() const override { return true; } |
| 61 |
|
| 62 |
bool Encode(const heif_image_handle* handle, |
| 63 |
const heif_image* image, const std::string& filename) override; |
| 64 |
}; |
| 65 |
|
| 66 |
#endif // EXAMPLE_ENCODER_TIFF_H |