From 6fc4525784cb1b4012fb04fe8ede00a9632bd251 Mon Sep 17 00:00:00 2001 From: Robin Daermann Date: Thu, 20 Aug 2015 15:01:07 +0200 Subject: [PATCH] Blacken Zones are now correctly displayed --- src/zm_image.cpp | 44 ++++++++++++-------------------------------- src/zm_monitor.cpp | 12 ++++++------ src/zm_monitor.h | 2 +- 3 files changed, 19 insertions(+), 39 deletions(-) diff --git a/src/zm_image.cpp b/src/zm_image.cpp index 907dc0255..e223ea9d2 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -1737,45 +1737,25 @@ const Coord Image::centreCoord( const char *text ) const void Image::Blacken( const unsigned char *p_bitmask, const Rgb pixel_colour ) { - unsigned int s_width = 200; - unsigned int s_height = 100; - - const uint8_t pixel_r_col = RED_VAL_RGBA(pixel_colour); - const uint8_t pixel_g_col = GREEN_VAL_RGBA(pixel_colour); - const uint8_t pixel_b_col = BLUE_VAL_RGBA(pixel_colour); + //const uint8_t pixel_r_col = RED_VAL_RGBA(pixel_colour); + //const uint8_t pixel_g_col = GREEN_VAL_RGBA(pixel_colour); + //const uint8_t pixel_b_col = BLUE_VAL_RGBA(pixel_colour); const uint8_t pixel_bw_col = pixel_colour & 0xff; - const Rgb pixel_rgb_col = rgb_convert(pixel_colour,subpixelorder); + //const Rgb pixel_rgb_col = rgb_convert(pixel_colour,subpixelorder); - for ( unsigned int y = 0; y < s_height; y++ ) + unsigned char *ptr = &buffer[0]; + unsigned int i = 0; + + for ( unsigned int y = 0; y < height; y++ ) { if ( colours == ZM_COLOUR_GRAY8 ) { - //unsigned char *ptr = &buffer[(lo_line_y*width)+lo_line_x]; - unsigned char *ptr = &buffer[(y*width)+0]; - for ( unsigned int x = 0; x < s_width; x++, ptr++ ) + for ( unsigned int x = 0; x < width; x++, ptr++ ) { unsigned char *temp_ptr = ptr; - *temp_ptr = pixel_bw_col; -// for ( unsigned int x = lo_line_x, c = 0; x < hi_line_x && c < line_len; c++ ) -// -// int f; -// if (size == 2) -// f = bigfontdata[(line[c] * CHAR_HEIGHT * size) + r]; -// else -// f = fontdata[(line[c] * CHAR_HEIGHT) + r]; -// for ( unsigned int i = 0; i < (CHAR_WIDTH * size) && x < hi_line_x; i++, x++, temp_ptr++ ) -// { -// if ( f & (zm_text_bitmask >> i) ) -// { -// if ( !fg_trans ) -// *temp_ptr = fg_bw_col; -// } -// else if ( !bg_trans ) -// { -// *temp_ptr = bg_bw_col; -// } -// } -// } + if ( *ptr & p_bitmask[i] ) + *temp_ptr = pixel_bw_col; + i++; } } // else if ( colours == ZM_COLOUR_RGB24 ) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 25ad1e74f..ba7707f66 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -691,7 +691,7 @@ void Monitor::AddZones( int p_n_zones, Zone *p_zones[] ) zones = p_zones; } -void Monitor::AddBlackenBitmap( Zone *p_zones[] ) +void Monitor::AddBlackenBitmask( Zone *p_zones[] ) { delete[] blacken_bitmask; blacken_bitmask = NULL; @@ -2205,7 +2205,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); Zone **zones = 0; int n_zones = Zone::Load( monitors[i], zones ); monitors[i]->AddZones( n_zones, zones ); - monitors[i]->AddBlackenBitmap( zones ); + monitors[i]->AddBlackenBitmask( zones ); Debug( 1, "Loaded monitor %d(%s), %d zones", id, name, n_zones ); } if ( mysql_errno( &dbconn ) ) @@ -2387,7 +2387,7 @@ int Monitor::LoadRemoteMonitors( const char *protocol, const char *host, const c Zone **zones = 0; int n_zones = Zone::Load( monitors[i], zones ); monitors[i]->AddZones( n_zones, zones ); - monitors[i]->AddBlackenBitmap( zones ); + monitors[i]->AddBlackenBitmask( zones ); Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); } if ( mysql_errno( &dbconn ) ) @@ -2532,7 +2532,7 @@ int Monitor::LoadFileMonitors( const char *file, Monitor **&monitors, Purpose pu Zone **zones = 0; int n_zones = Zone::Load( monitors[i], zones ); monitors[i]->AddZones( n_zones, zones ); - monitors[i]->AddBlackenBitmap( zones ); + monitors[i]->AddBlackenBitmask( zones ); Debug( 1, "Loaded monitor %d(%s), %d zones", id, name, n_zones ); } if ( mysql_errno( &dbconn ) ) @@ -2682,7 +2682,7 @@ int Monitor::LoadFfmpegMonitors( const char *file, Monitor **&monitors, Purpose Zone **zones = 0; int n_zones = Zone::Load( monitors[i], zones ); monitors[i]->AddZones( n_zones, zones ); - monitors[i]->AddBlackenBitmap( zones ); + monitors[i]->AddBlackenBitmask( zones ); Debug( 1, "Loaded monitor %d(%s), %d zones", id, name, n_zones ); } if ( mysql_errno( &dbconn ) ) @@ -3010,7 +3010,7 @@ Debug( 1, "Got %d for v4l_captures_per_frame", v4l_captures_per_frame ); Zone **zones = 0; n_zones = Zone::Load( monitor, zones ); monitor->AddZones( n_zones, zones ); - monitor->AddBlackenBitmap( zones ); + monitor->AddBlackenBitmask( zones ); } Debug( 1, "Loaded monitor %d(%s), %d zones", id, name.c_str(), n_zones ); } diff --git a/src/zm_monitor.h b/src/zm_monitor.h index 239b371d6..0c204a80a 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -311,7 +311,7 @@ public: ~Monitor(); void AddZones( int p_n_zones, Zone *p_zones[] ); - void AddBlackenBitmap( Zone *p_zones[] ); + void AddBlackenBitmask( Zone *p_zones[] ); bool connect(); inline int ShmValid() const