]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
Fix from wxAUI forum (http://www.kirix.com/forums/viewtopic.php?f=16&t=564) for displ...
[wxWidgets.git] / src / common / image.cpp
index d91c445e04a4a1cbdeb4283d5330a3de067ae627..30c9f8994c2643d262ae83a89f77e5379a07a2bc 100644 (file)
 #define HAS_FILE_STREAMS (wxUSE_STREAMS && (wxUSE_FILE || wxUSE_FFILE))
 
 #if HAS_FILE_STREAMS
-    #if wxUSE_FILE
-        typedef wxFileInputStream wxImageFileInputStream;
-        typedef wxFileOutputStream wxImageFileOutputStream;
-    #elif wxUSE_FFILE
+    #if wxUSE_FFILE
         typedef wxFFileInputStream wxImageFileInputStream;
         typedef wxFFileOutputStream wxImageFileOutputStream;
+    #elif wxUSE_FILE
+        typedef wxFileInputStream wxImageFileInputStream;
+        typedef wxFileOutputStream wxImageFileOutputStream;
     #endif // wxUSE_FILE/wxUSE_FFILE
 #endif // HAS_FILE_STREAMS
 
@@ -675,13 +675,13 @@ wxImage wxImage::ResampleBicubic(int width, int height) const
     for ( int dsty = 0; dsty < height; dsty++ )
     {
         // We need to calculate the source pixel to interpolate from - Y-axis
-        double srcpixy = dsty * M_IMGDATA->m_height / height;
+        double srcpixy = double(dsty * M_IMGDATA->m_height) / height;
         double dy = srcpixy - (int)srcpixy;
 
         for ( int dstx = 0; dstx < width; dstx++ )
         {
             // X-axis of pixel to interpolate from
-            double srcpixx = dstx * M_IMGDATA->m_width / width;
+            double srcpixx = double(dstx * M_IMGDATA->m_width) / width;
             double dx = srcpixx - (int)srcpixx;
 
             // Sums for each color channel
@@ -743,7 +743,7 @@ wxImage wxImage::ResampleBicubic(int width, int height) const
 }
 
 // Blur in the horizontal direction
-wxImage wxImage::BlurHorizontal(int blurRadius)
+wxImage wxImage::BlurHorizontal(int blurRadius) const
 {
     wxImage ret_image;
     ret_image.Create(M_IMGDATA->m_width, M_IMGDATA->m_height, false);
@@ -858,7 +858,7 @@ wxImage wxImage::BlurHorizontal(int blurRadius)
 }
 
 // Blur in the vertical direction
-wxImage wxImage::BlurVertical(int blurRadius)
+wxImage wxImage::BlurVertical(int blurRadius) const
 {
     wxImage ret_image;
     ret_image.Create(M_IMGDATA->m_width, M_IMGDATA->m_height, false);
@@ -973,7 +973,7 @@ wxImage wxImage::BlurVertical(int blurRadius)
 }
 
 // The new blur function
-wxImage wxImage::Blur(int blurRadius)
+wxImage wxImage::Blur(int blurRadius) const
 {
     wxImage ret_image;
     ret_image.Create(M_IMGDATA->m_width, M_IMGDATA->m_height, false);
@@ -1665,7 +1665,9 @@ void wxImage::SetAlpha( unsigned char *alpha, bool static_data )
         alpha = (unsigned char *)malloc(M_IMGDATA->m_width*M_IMGDATA->m_height);
     }
 
-    free(M_IMGDATA->m_alpha);
+    if( !M_IMGDATA->m_staticAlpha )
+        free(M_IMGDATA->m_alpha);
+
     M_IMGDATA->m_alpha = alpha;
     M_IMGDATA->m_staticAlpha = static_data;
 }
@@ -1898,8 +1900,11 @@ bool wxImage::ConvertAlphaToMask(unsigned char threshold)
         }
     }
 
-    free(M_IMGDATA->m_alpha);
+    if( !M_IMGDATA->m_staticAlpha )
+        free(M_IMGDATA->m_alpha);
+
     M_IMGDATA->m_alpha = NULL;
+    M_IMGDATA->m_staticAlpha = false;
 
     return true;
 }
@@ -2231,7 +2236,7 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int ind
 
     if (stream.IsSeekable() && !handler->CanRead(stream))
     {
-        wxLogError(_("Image file is not of type %s."), (const wxChar*) mimetype);
+        wxLogError(_("Image file is not of type %s."), mimetype);
         return false;
     }
     else