Merged in changes for enhanced showtext.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2062 e3e1d417-86f3-4887-817a-d78f3d33393fpull/27/merge
parent
fd0a44e816
commit
1b8269f233
226
src/zm_image.cpp
226
src/zm_image.cpp
|
@ -781,142 +781,122 @@ Image *Image::Delta( const Image &image ) const
|
|||
return( result );
|
||||
}
|
||||
|
||||
void Image::Annotate( const char *p_text, const Coord &coord, const Rgb colour )
|
||||
void Image::Annotate( const char *p_text, const Coord &coord, const Rgb fg_colour, const Rgb bg_colour )
|
||||
{
|
||||
strncpy( text, p_text, sizeof(text) );
|
||||
|
||||
int index = 0;
|
||||
int line_no = 0;
|
||||
int text_len = strlen( text );
|
||||
int text_width = text_len * CHAR_WIDTH;
|
||||
int text_height = CHAR_HEIGHT;
|
||||
int line_len = 0;
|
||||
const char *line = text;
|
||||
int line_height = CHAR_HEIGHT;
|
||||
|
||||
int lo_text_x = coord.X();
|
||||
int lo_text_y = coord.Y();
|
||||
char fg_r_col = RGB_RED_VAL(fg_colour);
|
||||
char fg_g_col = RGB_GREEN_VAL(fg_colour);
|
||||
char fg_b_col = RGB_BLUE_VAL(fg_colour);
|
||||
char fg_bw_col = (fg_r_col+fg_g_col+fg_b_col)/3;
|
||||
bool fg_trans = (fg_colour == RGB_TRANSPARENT);
|
||||
char bg_r_col = RGB_RED_VAL(bg_colour);
|
||||
char bg_g_col = RGB_GREEN_VAL(bg_colour);
|
||||
char bg_b_col = RGB_BLUE_VAL(bg_colour);
|
||||
char bg_bw_col = (bg_r_col+bg_g_col+bg_b_col)/3;
|
||||
bool bg_trans = (bg_colour == RGB_TRANSPARENT);
|
||||
|
||||
int min_text_x = 0;
|
||||
int max_text_x = width - text_width;
|
||||
int min_text_y = 0;
|
||||
int max_text_y = height - text_height;
|
||||
while ( (index < text_len) && (line_len = strcspn( line, "\n" )) )
|
||||
{
|
||||
int line_width = line_len * CHAR_WIDTH;
|
||||
|
||||
if ( lo_text_x > max_text_x )
|
||||
lo_text_x = max_text_x;
|
||||
if ( lo_text_x < min_text_x )
|
||||
lo_text_x = min_text_x;
|
||||
if ( lo_text_y > max_text_y )
|
||||
lo_text_y = max_text_y;
|
||||
if ( lo_text_y < min_text_y )
|
||||
lo_text_y = min_text_y;
|
||||
int lo_line_x = coord.X();
|
||||
int lo_line_y = coord.Y() + (line_no * LINE_HEIGHT);
|
||||
|
||||
int hi_text_x = lo_text_x + text_width;
|
||||
int hi_text_y = lo_text_y + text_height;
|
||||
int min_line_x = 0;
|
||||
int max_line_x = width - line_width;
|
||||
int min_line_y = 0;
|
||||
int max_line_y = height - line_height;
|
||||
|
||||
if ( hi_text_x > width )
|
||||
hi_text_x = width;
|
||||
if ( hi_text_y > height )
|
||||
hi_text_y = height;
|
||||
if ( lo_line_x > max_line_x )
|
||||
lo_line_x = max_line_x;
|
||||
if ( lo_line_x < min_line_x )
|
||||
lo_line_x = min_line_x;
|
||||
if ( lo_line_y > max_line_y )
|
||||
lo_line_y = max_line_y;
|
||||
if ( lo_line_y < min_line_y )
|
||||
lo_line_y = min_line_y;
|
||||
|
||||
int wc = width * colours;
|
||||
int hi_line_x = lo_line_x + line_width;
|
||||
int hi_line_y = lo_line_y + line_height;
|
||||
|
||||
unsigned char *ptr = &buffer[((lo_text_y*width)+lo_text_x)*colours];
|
||||
for ( int y = lo_text_y, r = 0; y < hi_text_y && r < CHAR_HEIGHT; y++, r++, ptr += wc )
|
||||
{
|
||||
unsigned char *temp_ptr = ptr;
|
||||
for ( int x = lo_text_x, c = 0; x < hi_text_x && c < text_len; c++ )
|
||||
{
|
||||
int f = fontdata[(text[c] * CHAR_HEIGHT) + r];
|
||||
for ( int i = 0; i < CHAR_WIDTH && x < hi_text_x; i++, x++, temp_ptr += colours )
|
||||
{
|
||||
if ( f & (0x80 >> i) )
|
||||
{
|
||||
RED(temp_ptr) = RGB_VAL(colour,0);
|
||||
GREEN(temp_ptr) = RGB_VAL(colour,1);
|
||||
BLUE(temp_ptr) = RGB_VAL(colour,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Clip anything that runs off the right of the screen
|
||||
if ( hi_line_x > width )
|
||||
hi_line_x = width;
|
||||
if ( hi_line_y > height )
|
||||
hi_line_y = height;
|
||||
|
||||
void Image::Annotate( const char *p_text, const Coord &coord )
|
||||
{
|
||||
strncpy( text, p_text, sizeof(text) );
|
||||
if ( colours == 1 )
|
||||
{
|
||||
unsigned char *ptr = &buffer[(lo_line_y*width)+lo_line_x];
|
||||
for ( int y = lo_line_y, r = 0; y < hi_line_y && r < CHAR_HEIGHT; y++, r++, ptr += width )
|
||||
{
|
||||
unsigned char *temp_ptr = ptr;
|
||||
for ( int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ )
|
||||
{
|
||||
int f = fontdata[(line[c] * CHAR_HEIGHT) + r];
|
||||
for ( int i = 0; i < CHAR_WIDTH && x < hi_line_x; i++, x++, temp_ptr++ )
|
||||
{
|
||||
if ( f & (0x80 >> i) )
|
||||
{
|
||||
if ( !fg_trans )
|
||||
*temp_ptr = fg_bw_col;
|
||||
}
|
||||
else if ( !bg_trans )
|
||||
{
|
||||
*temp_ptr = bg_bw_col;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int wc = width * colours;
|
||||
|
||||
int text_len = strlen( text );
|
||||
int text_width = text_len * CHAR_WIDTH;
|
||||
int text_height = CHAR_HEIGHT;
|
||||
|
||||
int lo_text_x = coord.X();
|
||||
int lo_text_y = coord.Y();
|
||||
|
||||
int min_text_x = 0;
|
||||
int max_text_x = width - text_width;
|
||||
int min_text_y = 0;
|
||||
int max_text_y = height - text_height;
|
||||
|
||||
if ( lo_text_x > max_text_x )
|
||||
lo_text_x = max_text_x;
|
||||
if ( lo_text_x < min_text_x )
|
||||
lo_text_x = min_text_x;
|
||||
if ( lo_text_y > max_text_y )
|
||||
lo_text_y = max_text_y;
|
||||
if ( lo_text_y < min_text_y )
|
||||
lo_text_y = min_text_y;
|
||||
|
||||
int hi_text_x = lo_text_x + text_width;
|
||||
int hi_text_y = lo_text_y + text_height;
|
||||
|
||||
if ( hi_text_x > width )
|
||||
hi_text_x = width;
|
||||
if ( hi_text_y > height )
|
||||
hi_text_y = height;
|
||||
|
||||
if ( colours == 1 )
|
||||
{
|
||||
unsigned char *ptr = &buffer[(lo_text_y*width)+lo_text_x];
|
||||
for ( int y = lo_text_y, r = 0; y < hi_text_y && r < CHAR_HEIGHT; y++, r++, ptr += width )
|
||||
{
|
||||
unsigned char *temp_ptr = ptr;
|
||||
for ( int x = lo_text_x, c = 0; x < hi_text_x && c < text_len; c++ )
|
||||
{
|
||||
int f = fontdata[(text[c] * CHAR_HEIGHT) + r];
|
||||
for ( int i = 0; i < CHAR_WIDTH && x < hi_text_x; i++, x++, temp_ptr++ )
|
||||
{
|
||||
if ( f & (0x80 >> i) )
|
||||
{
|
||||
*temp_ptr = WHITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*temp_ptr = BLACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int wc = width * colours;
|
||||
|
||||
unsigned char *ptr = &buffer[((lo_text_y*width)+lo_text_x)*colours];
|
||||
for ( int y = lo_text_y, r = 0; y < hi_text_y && r < CHAR_HEIGHT; y++, r++, ptr += wc )
|
||||
{
|
||||
unsigned char *temp_ptr = ptr;
|
||||
for ( int x = lo_text_x, c = 0; x < hi_text_x && c < text_len; c++ )
|
||||
{
|
||||
int f = fontdata[(text[c] * CHAR_HEIGHT) + r];
|
||||
for ( int i = 0; i < CHAR_WIDTH && x < hi_text_x; i++, x++, temp_ptr += colours )
|
||||
{
|
||||
if ( f & (0x80 >> i) )
|
||||
{
|
||||
RED(temp_ptr) = GREEN(temp_ptr) = BLUE(temp_ptr) = WHITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
RED(temp_ptr) = GREEN(temp_ptr) = BLUE(temp_ptr) = BLACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unsigned char *ptr = &buffer[((lo_line_y*width)+lo_line_x)*colours];
|
||||
for ( int y = lo_line_y, r = 0; y < hi_line_y && r < CHAR_HEIGHT; y++, r++, ptr += wc )
|
||||
{
|
||||
unsigned char *temp_ptr = ptr;
|
||||
for ( int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ )
|
||||
{
|
||||
int f = fontdata[(line[c] * CHAR_HEIGHT) + r];
|
||||
for ( int i = 0; i < CHAR_WIDTH && x < hi_line_x; i++, x++, temp_ptr += colours )
|
||||
{
|
||||
if ( f & (0x80 >> i) )
|
||||
{
|
||||
if ( !fg_trans )
|
||||
{
|
||||
RED(temp_ptr) = fg_r_col;
|
||||
GREEN(temp_ptr) = fg_g_col;
|
||||
BLUE(temp_ptr) = fg_b_col;
|
||||
}
|
||||
}
|
||||
else if ( !bg_trans )
|
||||
{
|
||||
RED(temp_ptr) = bg_r_col;
|
||||
GREEN(temp_ptr) = bg_g_col;
|
||||
BLUE(temp_ptr) = bg_b_col;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
index += line_len;
|
||||
while ( text[index] == '\n' )
|
||||
{
|
||||
index++;
|
||||
}
|
||||
line = text+index;
|
||||
line_no++;
|
||||
}
|
||||
}
|
||||
|
||||
void Image::Timestamp( const char *label, const time_t when, const Coord &coord )
|
||||
|
|
|
@ -46,6 +46,7 @@ class Image
|
|||
{
|
||||
protected:
|
||||
enum { CHAR_HEIGHT=11, CHAR_WIDTH=6 };
|
||||
enum { LINE_HEIGHT=CHAR_HEIGHT+0 };
|
||||
typedef unsigned char BlendTable[256][256];
|
||||
typedef BlendTable *BlendTablePtr;
|
||||
|
||||
|
@ -90,7 +91,7 @@ protected:
|
|||
int size;
|
||||
JSAMPLE *buffer;
|
||||
bool our_buffer;
|
||||
char text[256];
|
||||
char text[1024];
|
||||
|
||||
protected:
|
||||
mutable unsigned int *blend_buffer;
|
||||
|
@ -257,8 +258,7 @@ 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 *p_text, const Coord &coord, const Rgb colour );
|
||||
void Annotate( const char *p_text, const Coord &coord );
|
||||
void Annotate( const char *p_text, const Coord &coord, const Rgb fg_colour=RGB_WHITE, const Rgb bg_colour=RGB_BLACK );
|
||||
Image *HighlightEdges( Rgb colour, const Box *limits=0 );
|
||||
//Image *HighlightEdges( Rgb colour, const Polygon &polygon );
|
||||
void Timestamp( const char *label, const time_t when, const Coord &coord );
|
||||
|
|
|
@ -217,6 +217,24 @@ Monitor::Monitor(
|
|||
strncpy( event_prefix, p_event_prefix, sizeof(event_prefix) );
|
||||
strncpy( label_format, p_label_format, sizeof(label_format) );
|
||||
|
||||
// Change \n to actual line feeds
|
||||
char *token_ptr = label_format;
|
||||
const char *token_string = "\n";
|
||||
while( token_ptr = strstr( token_ptr, token_string ) )
|
||||
{
|
||||
if ( *(token_ptr+1) )
|
||||
{
|
||||
*token_ptr = '\n';
|
||||
token_ptr++;
|
||||
strcpy( token_ptr, token_ptr+1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
*token_ptr = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fps = 0.0;
|
||||
event_count = 0;
|
||||
image_count = 0;
|
||||
|
@ -1279,6 +1297,16 @@ bool Monitor::Analyse()
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( event )
|
||||
{
|
||||
Info(( "Closed event" ));
|
||||
closeEvent();
|
||||
}
|
||||
shared_data->state = state = IDLE;
|
||||
last_section_mod = 0;
|
||||
}
|
||||
if ( !signal_change && (function == MODECT || function == MOCORD) && (config.blend_alarmed_images || state != ALARM) )
|
||||
{
|
||||
ref_image.Blend( *snap_image, ref_blend_perc );
|
||||
|
|
|
@ -104,7 +104,7 @@ protected:
|
|||
int trigger_score;
|
||||
char trigger_cause[32];
|
||||
char trigger_text[256];
|
||||
char trigger_showtext[32];
|
||||
char trigger_showtext[256];
|
||||
} TriggerData;
|
||||
|
||||
typedef struct Snapshot
|
||||
|
|
33
src/zm_rgb.h
33
src/zm_rgb.h
|
@ -26,25 +26,26 @@ typedef unsigned int Rgb; // RGB colour type
|
|||
#define GREEN(ptr) (*(ptr+1))
|
||||
#define BLUE(ptr) (*(ptr+2))
|
||||
|
||||
#define WHITE 0xff
|
||||
#define WHITE_R 0xff
|
||||
#define WHITE_G 0xff
|
||||
#define WHITE_B 0xff
|
||||
#define WHITE 0xff
|
||||
#define WHITE_R 0xff
|
||||
#define WHITE_G 0xff
|
||||
#define WHITE_B 0xff
|
||||
|
||||
#define BLACK 0x00
|
||||
#define BLACK_R 0x00
|
||||
#define BLACK_G 0x00
|
||||
#define BLACK_B 0x00
|
||||
#define BLACK 0x00
|
||||
#define BLACK_R 0x00
|
||||
#define BLACK_G 0x00
|
||||
#define BLACK_B 0x00
|
||||
|
||||
#define RGB_WHITE (0x00ffffff)
|
||||
#define RGB_BLACK (0x00000000)
|
||||
#define RGB_RED (0x00ff0000)
|
||||
#define RGB_GREEN (0x0000ff00)
|
||||
#define RGB_BLUE (0x000000ff)
|
||||
#define RGB_ORANGE (0x00ffa500)
|
||||
#define RGB_PURPLE (0x00800080)
|
||||
#define RGB_WHITE (0x00ffffff)
|
||||
#define RGB_BLACK (0x00000000)
|
||||
#define RGB_RED (0x00ff0000)
|
||||
#define RGB_GREEN (0x0000ff00)
|
||||
#define RGB_BLUE (0x000000ff)
|
||||
#define RGB_ORANGE (0x00ffa500)
|
||||
#define RGB_PURPLE (0x00800080)
|
||||
#define RGB_TRANSPARENT (0x01000000)
|
||||
|
||||
#define RGB_VAL(v,c) (((v)>>(16-((c)*8)))&0xff)
|
||||
#define RGB_VAL(v,c) (((v)>>(16-((c)*8)))&0xff)
|
||||
#define RGB_RED_VAL(v) (((v)>>16)&0xff)
|
||||
#define RGB_GREEN_VAL(v) (((v)>>8)&0xff)
|
||||
#define RGB_BLUE_VAL(v) ((v)&0xff)
|
||||
|
|
Loading…
Reference in New Issue