From cd16c91ccd753101d4104f9be18ddeaac0dc9b51 Mon Sep 17 00:00:00 2001 From: stan Date: Thu, 27 May 2010 12:18:43 +0000 Subject: [PATCH] Tweaked zone image dumping. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3066 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm_monitor.cpp | 45 ++++++++++++++++++++++++++------------------- src/zm_zone.cpp | 13 ++++++++----- src/zmu.cpp | 6 +++--- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 0bccc4e43..cbec8dd26 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -597,7 +597,7 @@ int Monitor::GetImage( int index, int scale ) const } static char filename[PATH_MAX]; - snprintf( filename, sizeof(filename), "%s.jpg", name ); + snprintf( filename, sizeof(filename), "Monitor%d.jpg", id ); if ( !config.timestamp_on_capture ) { TimestampImage( &snap_image, snap->timestamp ); @@ -933,29 +933,36 @@ void Monitor::DumpZoneImage( const char *zone_string ) zone_image.Colourise(); for( int i = 0; i < n_zones; i++ ) { - if ( exclude_id && zones[i]->Id() == exclude_id ) + if ( exclude_id && (!extra_colour || extra_zone.getNumCoords()) && zones[i]->Id() == exclude_id ) continue; Rgb colour; - if ( zones[i]->IsActive() ) + if ( exclude_id && !extra_zone.getNumCoords() && zones[i]->Id() == exclude_id ) { - colour = RGB_RED; - } - else if ( zones[i]->IsInclusive() ) - { - colour = RGB_ORANGE; - } - else if ( zones[i]->IsExclusive() ) - { - colour = RGB_PURPLE; - } - else if ( zones[i]->IsPreclusive() ) - { - colour = RGB_BLUE; + colour = extra_colour; } else { - colour = RGB_WHITE; + if ( zones[i]->IsActive() ) + { + colour = RGB_RED; + } + else if ( zones[i]->IsInclusive() ) + { + colour = RGB_ORANGE; + } + else if ( zones[i]->IsExclusive() ) + { + colour = RGB_PURPLE; + } + else if ( zones[i]->IsPreclusive() ) + { + colour = RGB_BLUE; + } + else + { + colour = RGB_WHITE; + } } zone_image.Fill( colour, 2, zones[i]->GetPolygon() ); zone_image.Outline( colour, zones[i]->GetPolygon() ); @@ -978,8 +985,8 @@ void Monitor::DumpImage( Image *dump_image ) const { static char filename[PATH_MAX]; static char new_filename[PATH_MAX]; - snprintf( filename, sizeof(filename), "%s.jpg", name ); - snprintf( new_filename, sizeof(new_filename), "%s-new.jpg", name ); + snprintf( filename, sizeof(filename), "Monitor%d.jpg", id ); + snprintf( new_filename, sizeof(new_filename), "Monitor%d-new.jpg", id ); dump_image->WriteJpeg( new_filename ); rename( new_filename, filename ); } diff --git a/src/zm_zone.cpp b/src/zm_zone.cpp index 3359054e8..8222ec1ee 100644 --- a/src/zm_zone.cpp +++ b/src/zm_zone.cpp @@ -834,7 +834,7 @@ bool Zone::ParseZoneString( const char *zone_string, int &zone_id, int &colour, char *ws = strchr( str, ' ' ); if ( !ws ) { - Debug( 3, "No whitespace found in zone string '%s', finishing", zone_string ); + Debug( 3, "No initial whitespace found in zone string '%s', finishing", str ); } zone_id = strtol( str, 0, 10 ); Debug( 3, "Got zone %d from zone string", zone_id ); @@ -850,13 +850,16 @@ bool Zone::ParseZoneString( const char *zone_string, int &zone_id, int &colour, ws = strchr( str, ' ' ); if ( !ws ) { - Error( "No whitespace found in zone string '%s'", zone_string ); - delete[] str_ptr; - return( false ); + Debug( 3, "No secondary whitespace found in zone string '%s', finishing", zone_string ); } - *ws = '\0'; colour = strtol( str, 0, 16 ); Debug( 3, "Got colour %06x from zone string", colour ); + if ( !ws ) + { + delete str_ptr; + return( true ); + } + *ws = '\0'; str = ws+1; bool result = ParsePolygonString( str, polygon ); diff --git a/src/zmu.cpp b/src/zmu.cpp index c51c1c3ed..93d1143d5 100644 --- a/src/zmu.cpp +++ b/src/zmu.cpp @@ -493,9 +493,9 @@ int main( int argc, char *argv[] ) if ( verbose ) { if ( image_idx == -1 ) - printf( "Dumping last image captured to %s.jpg", monitor->Name() ); + printf( "Dumping last image captured to Monitor%d.jpg", monitor->Id() ); else - printf( "Dumping buffer image %d to %s.jpg", image_idx, monitor->Name() ); + printf( "Dumping buffer image %d to Monitor%d.jpg", image_idx, monitor->Id() ); if ( scale != -1 ) printf( ", scaling by %d%%", scale ); printf( "\n" ); @@ -505,7 +505,7 @@ int main( int argc, char *argv[] ) if ( function & ZMU_ZONES ) { if ( verbose ) - printf( "Dumping zone image to %s-Zones.jpg\n", monitor->Name() ); + printf( "Dumping zone image to Zones%d.jpg\n", monitor->Id() ); monitor->DumpZoneImage( zoneString ); } if ( function & ZMU_ALARM )