diff --git a/src/zm_config.h.z b/src/zm_config.h.z index 9c246f27e..06218675f 100644 --- a/src/zm_config.h.z +++ b/src/zm_config.h.z @@ -41,6 +41,7 @@ #define ZM_STRICT_VIDEO_CONFIG // Whether to allow errors in setting video config to be fatal #define ZM_LOCAL_BGR_INVERT // Invert BGR colours to RGB +#define ZM_COLOUR_JPEG_FILES // Colourise greyscale JPEG files #define ZM_JPEG_FILE_QUALITY // Set the JPEG quality setting for the saved event files #define ZM_JPEG_IMAGE_QUALITY // Set the JPEG quality setting for the streamed 'live' images diff --git a/src/zm_image.cpp b/src/zm_image.cpp index fe64a6345..86e7e3e15 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -98,6 +98,14 @@ void Image::ReadJpeg( const char *filename ) void Image::WriteJpeg( const char *filename ) const { + if ( ZM_COLOUR_JPEG_FILES && colours == 1 ) + { + Image *temp_image = new Image( *this ); + temp_image->Colourise(); + temp_image->WriteJpeg( filename ); + return; + } + struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); @@ -113,6 +121,7 @@ void Image::WriteJpeg( const char *filename ) const cinfo.image_width = width; /* image width and height, in pixels */ cinfo.image_height = height; + cinfo.input_components = colours; /* # of color components per pixel */ if ( colours == 1 ) {