View unanswered posts | View active topics It is currently Wed Jun 19, 2013 1:59 am



Reply to topic  [ 4 posts ] 
Image::Overlay patch 
Author Message

Joined: Sun Aug 05, 2012 6:59 am
Posts: 2
Post Image::Overlay patch
here is patch for Image::Overlay() function :

Code:
Index: zm_image.cpp
===================================================================
--- zm_image.cpp   (revision 3688)
+++ zm_image.cpp   (working copy)
@@ -711,12 +711,12 @@
 
 void Image::Overlay( const Image &image, int x, int y )
 {
-   if ( !(width < image.width || height < image.height) )
+   if ( width < image.width || height < image.height )
     {
         Panic( "Attempt to overlay image too big for destination, %dx%d > %dx%d", image.width, image.height, width, height );
     }
 
-   if ( !(width < (x+image.width) || height < (y+image.height)) )
+   if ( width < (x+image.width) || height < (y+image.height) )
     {
         Panic( "Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", image.width, image.height, x, y, width, height );
     }


Sun Aug 05, 2012 7:06 am
Profile

Joined: Wed Feb 01, 2012 10:48 pm
Posts: 59
Post Re: Image::Overlay patch
Hello Arash,

I am curious about your post..

I am looking for a method to get an overlay on one of my camera images.

Could you please explain what update does and how to implement this!?

Kind regards and thanks in advance, Christo


Sun Aug 05, 2012 9:40 am
Profile

Joined: Sun Aug 05, 2012 6:59 am
Posts: 2
Post Re: Image::Overlay patch
hello Christo,

existing Overlay function doesn't work at all.
if you look closely at the two 'if' conditions you can see they're reverse.

the rest of the function is fine. I currently use it for image overlaying and it works without a problem.

generally you can use "patch" utility to apply diffs. but for this case you can simply remove the two not ('!') operation from first two "if" statements
here is the patched version of the function :

Code:
void Image::Overlay( const Image &image, int x, int y )
{
   if ( width < image.width || height < image.height )
    {
        Panic( "Attempt to overlay image too big for destination, %dx%d > %dx%d", image.width, image.height, width, height );
    }

   if ( width < (x+image.width) || height < (y+image.height) )
    {
        Panic( "Attempt to overlay image outside of destination bounds, %dx%d @ %dx%d > %dx%d", image.width, image.height, x, y, width, height );
    }

   if ( !(colours == image.colours) )
    {
        Panic( "Attempt to partial overlay differently coloured images, expected %d, got %d", colours, image.colours );
    }

   int lo_x = x;
   int lo_y = y;
   int hi_x = (x+image.width)-1;
   int hi_y = (y+image.height-1);
   if ( colours == 1 )
   {
       unsigned char *psrc = image.buffer;
      for ( int y = lo_y; y <= hi_y; y++ )
      {
         unsigned char *pdest = &buffer[(y*width)+lo_x];
         for ( int x = lo_x; x <= hi_x; x++ )
         {
            *pdest++ = *psrc++;
         }
      }
   }
   else if ( colours == 3 )
   {
       unsigned char *psrc = image.buffer;
      for ( int y = lo_y; y <= hi_y; y++ )
      {
         unsigned char *pdest = &buffer[colours*((y*width)+lo_x)];
         for ( int x = lo_x; x <= hi_x; x++ )
         {
            *pdest++ = *psrc++;
            *pdest++ = *psrc++;
            *pdest++ = *psrc++;
         }
      }
   }
}


Sun Aug 05, 2012 10:49 am
Profile

Joined: Wed Feb 01, 2012 10:48 pm
Posts: 59
Post Re: Image::Overlay patch
Hello Arash,

OK, Ill get your point now!!

I have been searching within the WIKI and this forum but found no additional information about how to apply such an overlay.

I asume you did figure this out by yourself? Or was I just looking at the wrong place?

Maybe you can point me out how?

Kind regards and Thanks, Christo


Mon Aug 06, 2012 3:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group