diff --git a/src/zm_image.cpp b/src/zm_image.cpp index d6a2d7022..5f76289c3 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -205,10 +205,15 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const { cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ } - jpeg_set_defaults(&cinfo); + jpeg_set_defaults( &cinfo ); cinfo.dct_method = JDCT_FASTEST; - jpeg_set_quality(&cinfo, quality_override?quality_override:config.jpeg_file_quality, false); - jpeg_start_compress(&cinfo, TRUE); + jpeg_set_quality( &cinfo, quality_override?quality_override:config.jpeg_file_quality, false ); + jpeg_start_compress( &cinfo, TRUE ); + + if ( true && text[0] ) + { + jpeg_write_marker( &cinfo, JPEG_COM, (const JOCTET *)text, strlen(text) ); + } JSAMPROW row_pointer; /* pointer to a single row */ int row_stride = cinfo.image_width * cinfo.input_components; /* physical row width in buffer */ @@ -594,8 +599,10 @@ Image *Image::Delta( const Image &image ) const return( result ); } -void Image::Annotate( const char *text, const Coord &coord, const Rgb colour ) +void Image::Annotate( const char *p_text, const Coord &coord, const Rgb colour ) { + strncpy( text, p_text, sizeof(text) ); + int text_len = strlen( text ); int text_width = text_len * CHAR_WIDTH; int text_height = CHAR_HEIGHT; @@ -647,8 +654,10 @@ void Image::Annotate( const char *text, const Coord &coord, const Rgb colour ) } } -void Image::Annotate( const char *text, const Coord &coord ) +void Image::Annotate( const char *p_text, const Coord &coord ) { + strncpy( text, p_text, sizeof(text) ); + int text_len = strlen( text ); int text_width = text_len * CHAR_WIDTH; int text_height = CHAR_HEIGHT; diff --git a/src/zm_image.h b/src/zm_image.h index 03f5c9ec7..525c2c2ea 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -63,6 +63,7 @@ protected: int size; JSAMPLE *buffer; bool our_buffer; + char text[256]; protected: mutable unsigned int *blend_buffer; @@ -83,6 +84,7 @@ public: our_buffer = true; buffer = 0; blend_buffer = 0; + text[0] = '\0'; } Image( const char *filename ) { @@ -92,6 +94,7 @@ public: ReadJpeg( filename ); our_buffer = true; blend_buffer = 0; + text[0] = '\0'; } Image( int p_width, int p_height, int p_colours, JSAMPLE *p_buffer=0 ) { @@ -113,6 +116,7 @@ public: memset( buffer, 0, size ); } blend_buffer = 0; + text[0] = '\0'; } Image( const Image &p_image ) { @@ -126,6 +130,7 @@ public: memcpy( buffer, p_image.buffer, size ); our_buffer = true; blend_buffer = 0; + strncpy( text, p_image.text, sizeof(text) ); } ~Image() { @@ -203,8 +208,8 @@ public: static Image *Highlight( int n_images, Image *images[], const Rgb threshold=RGB_BLACK, const Rgb ref_colour=RGB_RED ); Image *Delta( const Image &image ) const; - void Annotate( const char *text, const Coord &coord, const Rgb colour ); - void Annotate( const char *text, const Coord &coord ); + void Annotate( const char *p_text, const Coord &coord, const Rgb colour ); + void Annotate( const char *p_text, const Coord &coord ); Image *HighlightEdges( Rgb colour, const Box *limits=0 ); void Timestamp( const char *label, const time_t when, const Coord &coord ); void Colourise();