Works for non-binary factors.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@661 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
1c8b7c3515
commit
7d3e8aec58
|
@ -876,7 +876,7 @@ void Image::Scale( int factor )
|
||||||
}
|
}
|
||||||
width *= factor;
|
width *= factor;
|
||||||
height *= factor;
|
height *= factor;
|
||||||
size *= (factor*factor);
|
size = width*height*colours;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -884,10 +884,14 @@ void Image::Scale( int factor )
|
||||||
unsigned char *pd = scale_buffer;
|
unsigned char *pd = scale_buffer;
|
||||||
unsigned int wc = width*colours;
|
unsigned int wc = width*colours;
|
||||||
unsigned int cf = factor*colours;
|
unsigned int cf = factor*colours;
|
||||||
for ( int y = 0; y < height; y += factor )
|
unsigned int xrem = width%factor;
|
||||||
|
unsigned int yrem = height%factor;
|
||||||
|
unsigned int xstart = xrem/2;
|
||||||
|
unsigned int ystart = yrem/2;
|
||||||
|
for ( int y = xstart; y < height; y += factor )
|
||||||
{
|
{
|
||||||
unsigned char *ps = &buffer[y*wc];
|
unsigned char *ps = &buffer[y*wc];
|
||||||
for ( int x = 0; x < width; x += factor )
|
for ( int x = ystart; x < width; x += factor )
|
||||||
{
|
{
|
||||||
for ( int c = 0; c < colours; c++ )
|
for ( int c = 0; c < colours; c++ )
|
||||||
{
|
{
|
||||||
|
@ -896,9 +900,9 @@ void Image::Scale( int factor )
|
||||||
ps += cf;
|
ps += cf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
width /= factor;
|
width = 1+int((width-1)/factor);
|
||||||
height /= factor;
|
height = 1+int((height-1)/factor);
|
||||||
size /= (factor*factor);
|
size = width*height*colours;
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
buffer = new JSAMPLE[size];
|
buffer = new JSAMPLE[size];
|
||||||
|
|
Loading…
Reference in New Issue