fixed a small scaling bug.

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Post Reply
gertjan
Posts: 14
Joined: Fri Aug 25, 2006 8:10 am
Location: netherlands

fixed a small scaling bug.

Post 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;
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post 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?
Phil
gertjan
Posts: 14
Joined: Fri Aug 25, 2006 8:10 am
Location: netherlands

test environment

Post 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.
Post Reply