Page 1 of 1

fixed a small scaling bug.

Posted: Fri Aug 25, 2006 8:20 am
by gertjan
Hi i just fixed a smal bug in the scaling code. As fas as I can see it is in al versions from 1.21.0 up to current version.

( original image size 358x288, scale factor 86, gives an shift every line of 1 pixel ).


--- zm_image.cpp 2006-05-08 14:46:53.000000000 +0200
+++ zm_image_new.cpp 2006-08-25 10:20:38.000000000 +0200
@@ -1490,7 +1490,8 @@
else
{
unsigned int inv_factor = (ZM_SCALE_SCALE*ZM_SCALE_SCALE)/factor;
- unsigned char *pd = scale_buffer;
+ unsigned char *mpd = scale_buffer;
+ unsigned int nwc = new_width*colours;
unsigned int wc = width*colours;
unsigned int xstart = factor/2;
unsigned int ystart = factor/2;
@@ -1508,6 +1509,9 @@
unsigned int w_index;

unsigned char *ps = &buffer[y*wc];
+ mpd+=nwc;
+ unsigned char *pd=mpd;
for ( unsigned int x = 0; x < width; x++ )
{
w_count += factor;

Posted: Tue Aug 29, 2006 3:51 pm
by zoneminder
Thanks, I will apply this to the code. Can you elaborate a little on what effect the bug produces so I know how to test it?

test environment

Posted: Wed Aug 30, 2006 7:06 am
by gertjan
It is quite easy. Put a cam to record at 358x288 / 360x288. Use the cgi script to test:
cgi-bin/zms?mode=single&monitor=2&scale=86&.......< al the other vars >

I have tested at different scale factors, it is not always visible. But the above numbers showed it for me.