]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/scaled_bitmap.cpp
Qt: iconView delegate: encode PLModel::IsCurrent(QModelIndex) into cache key
[vlc] / modules / gui / skins2 / src / scaled_bitmap.cpp
index 5cd583bcc1181a03a6f4807ca6e87024f26e2b49..049139936f4390ef32dd21a84c6062e6d654f14c 100644 (file)
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * 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
@@ -19,7 +19,7 @@
  *
  * 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"
@@ -42,13 +42,13 @@ ScaledBitmap::ScaledBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
     // 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;
 
@@ -71,17 +71,21 @@ ScaledBitmap::ScaledBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
     // 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++);
 
@@ -100,9 +104,6 @@ ScaledBitmap::ScaledBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
 
 ScaledBitmap::~ScaledBitmap()
 {
-    if( m_pData )
-    {
-        delete[] m_pData;
-    }
+    delete[] m_pData;
 }