white and google style

This commit is contained in:
Isaac Connor 2017-04-28 10:34:48 -04:00
parent d498e30e37
commit 6827e0412c
1 changed files with 1096 additions and 1102 deletions

View File

@ -74,8 +74,7 @@ static deinterlace_4field_fptr_t fptr_deinterlace_4field_gray8;
/* Pointer to image buffer memory copy function */ /* Pointer to image buffer memory copy function */
imgbufcpy_fptr_t fptr_imgbufcpy; imgbufcpy_fptr_t fptr_imgbufcpy;
Image::Image() Image::Image() {
{
if ( !initialised ) if ( !initialised )
Initialise(); Initialise();
width = 0; width = 0;
@ -91,8 +90,7 @@ Image::Image()
text[0] = '\0'; text[0] = '\0';
} }
Image::Image( const char *filename ) Image::Image( const char *filename ) {
{
if ( !initialised ) if ( !initialised )
Initialise(); Initialise();
width = 0; width = 0;
@ -798,13 +796,13 @@ bool Image::ReadJpeg( const char *filename, unsigned int p_colours, unsigned int
#endif #endif
} else { } else {
/* Assume RGB */ /* Assume RGB */
/* /*
#ifdef JCS_EXTENSIONS #ifdef JCS_EXTENSIONS
cinfo->out_color_space = JCS_EXT_RGB; cinfo->out_color_space = JCS_EXT_RGB;
#else #else
cinfo->out_color_space = JCS_RGB; cinfo->out_color_space = JCS_RGB;
#endif #endif
*/ */
cinfo->out_color_space = JCS_RGB; cinfo->out_color_space = JCS_RGB;
new_subpixelorder = ZM_SUBPIX_ORDER_RGB; new_subpixelorder = ZM_SUBPIX_ORDER_RGB;
} }
@ -928,13 +926,13 @@ bool Image::WriteJpeg( const char *filename, int quality_override, struct timeva
#endif #endif
} else { } else {
/* Assume RGB */ /* Assume RGB */
/* /*
#ifdef JCS_EXTENSIONS #ifdef JCS_EXTENSIONS
cinfo->out_color_space = JCS_EXT_RGB; cinfo->out_color_space = JCS_EXT_RGB;
#else #else
cinfo->out_color_space = JCS_RGB; cinfo->out_color_space = JCS_RGB;
#endif #endif
*/ */
cinfo->in_color_space = JCS_RGB; cinfo->in_color_space = JCS_RGB;
} }
break; break;
@ -946,20 +944,20 @@ bool Image::WriteJpeg( const char *filename, int quality_override, struct timeva
cinfo->dct_method = JDCT_FASTEST; cinfo->dct_method = JDCT_FASTEST;
jpeg_start_compress( cinfo, TRUE ); jpeg_start_compress( cinfo, TRUE );
if ( config.add_jpeg_comments && text[0] ) if ( config.add_jpeg_comments && text[0] ) {
{
jpeg_write_marker( cinfo, JPEG_COM, (const JOCTET *)text, strlen(text) ); jpeg_write_marker( cinfo, JPEG_COM, (const JOCTET *)text, strlen(text) );
} }
// If we have a non-zero time (meaning a parameter was passed in), then form a simple exif segment with that time as DateTimeOriginal and SubsecTimeOriginal // If we have a non-zero time (meaning a parameter was passed in), then form a simple exif segment with that time as DateTimeOriginal and SubsecTimeOriginal
// No timestamp just leave off the exif section. // No timestamp just leave off the exif section.
if(timestamp.tv_sec) if(timestamp.tv_sec)
{ {
#define EXIFTIMES_MS_OFFSET 0x36 // three decimal digits for milliseconds #define EXIFTIMES_MS_OFFSET 0x36 // three decimal digits for milliseconds
#define EXIFTIMES_MS_LEN 0x03 #define EXIFTIMES_MS_LEN 0x03
#define EXIFTIMES_OFFSET 0x3E // 19 characters format '2015:07:21 13:14:45' not including quotes #define EXIFTIMES_OFFSET 0x3E // 19 characters format '2015:07:21 13:14:45' not including quotes
#define EXIFTIMES_LEN 0x13 // = 19 #define EXIFTIMES_LEN 0x13 // = 19
#define EXIF_CODE 0xE1 #define EXIF_CODE 0xE1
// This is a lot of stuff to allocate on the stack. Recommend char *timebuf[64];
char timebuf[64], msbuf[64]; char timebuf[64], msbuf[64];
strftime(timebuf, sizeof timebuf, "%Y:%m:%d %H:%M:%S", localtime(&(timestamp.tv_sec))); strftime(timebuf, sizeof timebuf, "%Y:%m:%d %H:%M:%S", localtime(&(timestamp.tv_sec)));
snprintf(msbuf, sizeof msbuf, "%06d",(int)(timestamp.tv_usec)); // we only use milliseconds because that's all defined in exif, but this is the whole microseconds because we have it snprintf(msbuf, sizeof msbuf, "%06d",(int)(timestamp.tv_usec)); // we only use milliseconds because that's all defined in exif, but this is the whole microseconds because we have it
@ -971,8 +969,8 @@ bool Image::WriteJpeg( const char *filename, int quality_override, struct timeva
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00 }; 0xff, 0x00 };
memcpy(&exiftimes[EXIFTIMES_OFFSET], timebuf,EXIFTIMES_LEN); memcpy(&exiftimes[EXIFTIMES_OFFSET], timebuf,EXIFTIMES_LEN);
memcpy(&exiftimes[EXIFTIMES_MS_OFFSET], msbuf ,EXIFTIMES_MS_LEN); memcpy(&exiftimes[EXIFTIMES_MS_OFFSET], msbuf, EXIFTIMES_MS_LEN);
jpeg_write_marker (cinfo, EXIF_CODE, (const JOCTET *)exiftimes, sizeof(exiftimes) ); jpeg_write_marker( cinfo, EXIF_CODE, (const JOCTET *)exiftimes, sizeof(exiftimes) );
} }
JSAMPROW row_pointer; /* pointer to a single row */ JSAMPROW row_pointer; /* pointer to a single row */
@ -1081,13 +1079,13 @@ bool Image::DecodeJpeg( const JOCTET *inbuffer, int inbuffer_size, unsigned int
#endif #endif
} else { } else {
/* Assume RGB */ /* Assume RGB */
/* /*
#ifdef JCS_EXTENSIONS #ifdef JCS_EXTENSIONS
cinfo->out_color_space = JCS_EXT_RGB; cinfo->out_color_space = JCS_EXT_RGB;
#else #else
cinfo->out_color_space = JCS_RGB; cinfo->out_color_space = JCS_RGB;
#endif #endif
*/ */
cinfo->out_color_space = JCS_RGB; cinfo->out_color_space = JCS_RGB;
new_subpixelorder = ZM_SUBPIX_ORDER_RGB; new_subpixelorder = ZM_SUBPIX_ORDER_RGB;
} }
@ -1185,13 +1183,13 @@ bool Image::EncodeJpeg( JOCTET *outbuffer, int *outbuffer_size, int quality_over
#endif #endif
} else { } else {
/* Assume RGB */ /* Assume RGB */
/* /*
#ifdef JCS_EXTENSIONS #ifdef JCS_EXTENSIONS
cinfo->out_color_space = JCS_EXT_RGB; cinfo->out_color_space = JCS_EXT_RGB;
#else #else
cinfo->out_color_space = JCS_RGB; cinfo->out_color_space = JCS_RGB;
#endif #endif
*/ */
cinfo->in_color_space = JCS_RGB; cinfo->in_color_space = JCS_RGB;
} }
break; break;
@ -2007,18 +2005,14 @@ void Image::Annotate( const char *p_text, const Coord &coord, const unsigned int
} }
} }
void Image::Timestamp( const char *label, const time_t when, const Coord &coord, const int size ) void Image::Timestamp( const char *label, const time_t when, const Coord &coord, const int size ) {
{
char time_text[64]; char time_text[64];
strftime( time_text, sizeof(time_text), "%y/%m/%d %H:%M:%S", localtime( &when ) ); strftime( time_text, sizeof(time_text), "%y/%m/%d %H:%M:%S", localtime( &when ) );
char text[64]; char text[64];
if ( label ) if ( label ) {
{
snprintf( text, sizeof(text), "%s - %s", label, time_text ); snprintf( text, sizeof(text), "%s - %s", label, time_text );
Annotate( text, coord, size ); Annotate( text, coord, size );
} } else {
else
{
Annotate( time_text, coord, size ); Annotate( time_text, coord, size );
} }
} }