Bug 198 - Added initial hooks for optional comment in jpeg headers.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1596 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-11-19 18:43:46 +00:00
parent b2a7183f12
commit 65532674e6
2 changed files with 21 additions and 7 deletions

View File

@ -210,6 +210,11 @@ bool Image::WriteJpeg( const char *filename, int quality_override ) const
jpeg_set_quality( &cinfo, quality_override?quality_override:config.jpeg_file_quality, false ); jpeg_set_quality( &cinfo, quality_override?quality_override:config.jpeg_file_quality, false );
jpeg_start_compress( &cinfo, TRUE ); 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 */ JSAMPROW row_pointer; /* pointer to a single row */
int row_stride = cinfo.image_width * cinfo.input_components; /* physical row width in buffer */ int row_stride = cinfo.image_width * cinfo.input_components; /* physical row width in buffer */
while (cinfo.next_scanline < cinfo.image_height) while (cinfo.next_scanline < cinfo.image_height)
@ -594,8 +599,10 @@ Image *Image::Delta( const Image &image ) const
return( result ); 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_len = strlen( text );
int text_width = text_len * CHAR_WIDTH; int text_width = text_len * CHAR_WIDTH;
int text_height = CHAR_HEIGHT; 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_len = strlen( text );
int text_width = text_len * CHAR_WIDTH; int text_width = text_len * CHAR_WIDTH;
int text_height = CHAR_HEIGHT; int text_height = CHAR_HEIGHT;

View File

@ -63,6 +63,7 @@ protected:
int size; int size;
JSAMPLE *buffer; JSAMPLE *buffer;
bool our_buffer; bool our_buffer;
char text[256];
protected: protected:
mutable unsigned int *blend_buffer; mutable unsigned int *blend_buffer;
@ -83,6 +84,7 @@ public:
our_buffer = true; our_buffer = true;
buffer = 0; buffer = 0;
blend_buffer = 0; blend_buffer = 0;
text[0] = '\0';
} }
Image( const char *filename ) Image( const char *filename )
{ {
@ -92,6 +94,7 @@ public:
ReadJpeg( filename ); ReadJpeg( filename );
our_buffer = true; our_buffer = true;
blend_buffer = 0; blend_buffer = 0;
text[0] = '\0';
} }
Image( int p_width, int p_height, int p_colours, JSAMPLE *p_buffer=0 ) Image( int p_width, int p_height, int p_colours, JSAMPLE *p_buffer=0 )
{ {
@ -113,6 +116,7 @@ public:
memset( buffer, 0, size ); memset( buffer, 0, size );
} }
blend_buffer = 0; blend_buffer = 0;
text[0] = '\0';
} }
Image( const Image &p_image ) Image( const Image &p_image )
{ {
@ -126,6 +130,7 @@ public:
memcpy( buffer, p_image.buffer, size ); memcpy( buffer, p_image.buffer, size );
our_buffer = true; our_buffer = true;
blend_buffer = 0; blend_buffer = 0;
strncpy( text, p_image.text, sizeof(text) );
} }
~Image() ~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 ); 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; Image *Delta( const Image &image ) const;
void Annotate( const char *text, const Coord &coord, const Rgb colour ); void Annotate( const char *p_text, const Coord &coord, const Rgb colour );
void Annotate( const char *text, const Coord &coord ); void Annotate( const char *p_text, const Coord &coord );
Image *HighlightEdges( Rgb colour, const Box *limits=0 ); Image *HighlightEdges( Rgb colour, const Box *limits=0 );
void Timestamp( const char *label, const time_t when, const Coord &coord ); void Timestamp( const char *label, const time_t when, const Coord &coord );
void Colourise(); void Colourise();