Commit 357973f8 authored by Cyril Deguet's avatar Cyril Deguet
Browse files

* scaled_bitmap.cpp: - fixed an infinite loop when width=1

   + fixed a huge bug in horizontal scaling (btw, TODO: use bresenham for
   vertical scaling too)
parent fa2bb4e2
......@@ -45,10 +45,10 @@ ScaledBitmap::ScaledBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
// Decision variables for Bresenham algorithm
int incX1 = 2 * (srcWidth-1);
int incX2 = incX1 - 2 * (width-1);
int dX = incX1 - (width-1);
for( int y = 0; y < height; y++ )
{
int dX = incX1 - (width-1);
uint32_t yOffset = ((y * srcHeight) / height) * srcWidth;
pSrcData = ((uint32_t*)rBitmap.getData()) + yOffset;
......@@ -74,14 +74,16 @@ ScaledBitmap::ScaledBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
// Decision variables for Bresenham algorithm
int incX1 = 2 * (width-1);
int incX2 = incX1 - 2 * (srcWidth-1);
int dX = incX1 - (srcWidth-1);
for( int y = 0; y < height; y++ )
{
int dX = incX1 - (srcWidth-1);
uint32_t yOffset = ((y * srcHeight) / height) * srcWidth;
pSrcData = ((uint32_t*)rBitmap.getData()) + yOffset;
for( int x = 0; x < width; x++ )
*(pDestData++) = *(pSrcData++);
// Don't start with x=0 to avoid an infinite loop if width==1
for( int x = 1; x < width; x++ )
{
*(pDestData++) = *(pSrcData++);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment