25 #include <core/exception.h> 26 #include <core/exceptions/system.h> 27 #include <utils/system/console_colors.h> 29 #include <fvutils/writers/compressed.h> 30 #include <fvutils/compression/imagecompressor.h> 59 image_compressor = ic;
74 this->filename = strdup(filename);
76 if ( image_compressor != NULL ) {
87 if ( image_compressor != NULL ) {
98 if ( image_compressor != NULL ) {
107 if ( image_compressor != NULL ) {
114 unsigned char *comp_buffer = (
unsigned char *)malloc(comp_buffer_size);
118 if (fwrite(comp_buffer, image_compressor->
compressed_size(), 1, f) != 1) {
124 throw fawkes::Exception(
"Supplied ImageCompressor does neither support compressing " 125 " to file nor to a memory buffer. Cannot write.");
138 image_compressor = ic;
virtual void set_dimensions(unsigned int width, unsigned int height)
Set dimensions of image in pixels.
virtual ~CompressedImageWriter()
Destructor.
virtual void set_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer.
colorspace_t cspace
The colorspace of the image.
write compressed image to file
virtual void set_image_dimensions(unsigned int width, unsigned int height)=0
Set dimensions of image to compress.
virtual void set_destination_buffer(unsigned char *buf, unsigned int buf_size)=0
Set destination buffer (if compressing to memory).
CompressedImageWriter(ImageCompressor *ic=NULL)
Constructor.
virtual bool supports_compression_destination(CompressionDestination cd)=0
Check if compressor supports desired compression destination.
virtual void set_image_compressor(ImageCompressor *ic)
Set image compressor.
virtual void set_compression_destination(CompressionDestination cd)=0
Set compression destination.
virtual void set_filename(const char *filename)
Set filename.
Base class for exceptions in Fawkes.
virtual size_t recommended_compressed_buffer_size()=0
Get the recommended size for the compressed buffer.
virtual void set_filename(const char *filename)=0
Set file name.
write compressed image to buffer in memory
unsigned int width
The width of the image.
unsigned char * buffer
The image-buffer.
virtual void write()
Write to file.
Image compressor interface.
unsigned int height
The height of the image.
char * filename
The complete filename.
virtual size_t compressed_size()=0
Get compressed size.
virtual void compress()=0
Compress image.
virtual void set_image_buffer(colorspace_t cspace, unsigned char *buffer)=0
Set image buffer to compress.