diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 243c1b055..763ce94a1 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -194,7 +194,7 @@ bool Event::SendFrameImage( const Image *image, bool alarm_frame ) static int jpg_buffer_size = 0; static unsigned char jpg_buffer[ZM_MAX_IMAGE_SIZE]; - image->EncodeJpeg( jpg_buffer, &jpg_buffer_size ); + image->EncodeJpeg( jpg_buffer, &jpg_buffer_size, config.jpeg_file_quality ); static FrameHeader frame_header; diff --git a/src/zm_image.cpp b/src/zm_image.cpp index aeaf1845d..76cbd6100 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -168,7 +168,7 @@ bool Image::ReadJpeg( const char *filename ) return( true ); } -bool Image::WriteJpeg( const char *filename ) const +bool Image::WriteJpeg( const char *filename, int quality_override ) const { if ( config.colour_jpeg_files && colours == 1 ) { @@ -204,7 +204,7 @@ bool Image::WriteJpeg( const char *filename ) const } jpeg_set_defaults(&cinfo); cinfo.dct_method = JDCT_FASTEST; - jpeg_set_quality(&cinfo, config.jpeg_file_quality, false); + jpeg_set_quality(&cinfo, quality_override?quality_override:config.jpeg_file_quality, false); jpeg_start_compress(&cinfo, TRUE); JSAMPROW row_pointer; /* pointer to a single row */ @@ -269,7 +269,7 @@ bool Image::DecodeJpeg( JOCTET *inbuffer, int inbuffer_size ) return( true ); } -bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size ) const +bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override ) const { if ( config.colour_jpeg_files && colours == 1 ) { @@ -298,7 +298,7 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size ) const } jpeg_set_defaults(&cinfo); cinfo.dct_method = JDCT_FASTEST; - jpeg_set_quality(&cinfo, config.jpeg_image_quality, false); + jpeg_set_quality(&cinfo, quality_override?quality_override:config.jpeg_image_quality, false); jpeg_start_compress(&cinfo, TRUE); JSAMPROW row_pointer; /* pointer to a single row */ diff --git a/src/zm_image.h b/src/zm_image.h index 23df63bef..03f5c9ec7 100644 --- a/src/zm_image.h +++ b/src/zm_image.h @@ -192,9 +192,9 @@ public: } bool ReadJpeg( const char *filename ); - bool WriteJpeg( const char *filename ) const; + bool WriteJpeg( const char *filename, int quality_override=0 ) const; bool DecodeJpeg( JOCTET *inbuffer, int inbuffer_size ); - bool EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size ) const; + bool EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_override=0 ) const; void Overlay( const Image &image ); void Blend( const Image &image, int transparency=10 ) const;