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