/*****************************************************************************
* scaled_bitmap.cpp
*****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: scaled_bitmap.cpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
- * Olivier Teulière <ipkiss@via.ecp.fr>
+ * Olivier Teulière <ipkiss@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "scaled_bitmap.hpp"
// Algorithm for horizontal enlargement
if( width > srcWidth )
{
- // Decision variables for Bresenham alogrithm
- int incX1 = 2 * srcWidth;
- int incX2 = incX1 - 2 * width;
- int dX = incX1 - width;
+ // Decision variables for Bresenham algorithm
+ int incX1 = 2 * (srcWidth-1);
+ int incX2 = incX1 - 2 * (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;
// Algorithm for horizontal reduction
else
{
- // Decision variables for Bresenham alogrithm
- int incX1 = 2 * width;
- int incX2 = incX1 - 2 * srcWidth;
- int dX = incX1 - srcWidth;
+ // Decision variables for Bresenham algorithm
+ int incX1 = 2 * (width-1);
+ int incX2 = incX1 - 2 * (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++ )
+ if (width == 1)
+ {
+ *(pDestData++) = *pSrcData;
+ }
+ else for( int x = 0; x < width; x++ )
{
*(pDestData++) = *(pSrcData++);
ScaledBitmap::~ScaledBitmap()
{
- if( m_pData )
- {
- delete[] m_pData;
- }
+ delete[] m_pData;
}