]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
remove Motif MDI files not used any longer
[wxWidgets.git] / src / common / image.cpp
index b41fee58f655546f95f6a5d70e59b1cda7c3ab2c..6857a0d3da03e20edfee19523857523c5fe8d570 100644 (file)
@@ -123,7 +123,7 @@ wxImage wxNullImage;
 
 //-----------------------------------------------------------------------------
 
-#define M_IMGDATA wx_static_cast(wxImageRefData*, m_refData)
+#define M_IMGDATA static_cast<wxImageRefData*>(m_refData)
 
 IMPLEMENT_DYNAMIC_CLASS(wxImage, wxObject)
 
@@ -252,7 +252,7 @@ wxObjectRefData* wxImage::CreateRefData() const
 
 wxObjectRefData* wxImage::CloneRefData(const wxObjectRefData* that) const
 {
-    const wxImageRefData* refData = wx_static_cast(const wxImageRefData*, that);
+    const wxImageRefData* refData = static_cast<const wxImageRefData*>(that);
     wxCHECK_MSG(refData->m_ok, NULL, wxT("invalid image") );
 
     wxImageRefData* refData_new = new wxImageRefData;
@@ -1270,7 +1270,6 @@ void wxImage::Paste( const wxImage &image, int x, int y )
          (GetMaskGreen()==image.GetMaskGreen()) &&
          (GetMaskBlue()==image.GetMaskBlue()))))
     {
-        width *= 3;
         unsigned char* source_data = image.GetData() + xx*3 + yy*3*image.GetWidth();
         int source_step = image.GetWidth()*3;
 
@@ -1278,11 +1277,10 @@ void wxImage::Paste( const wxImage &image, int x, int y )
         int target_step = M_IMGDATA->m_width*3;
         for (int j = 0; j < height; j++)
         {
-            memcpy( target_data, source_data, width );
+            memcpy( target_data, source_data, width*3 );
             source_data += source_step;
             target_data += target_step;
         }
-        return;
     }
 
     // Copy over the alpha channel from the original image
@@ -1311,7 +1309,6 @@ void wxImage::Paste( const wxImage &image, int x, int y )
         unsigned char g = image.GetMaskGreen();
         unsigned char b = image.GetMaskBlue();
 
-        width *= 3;
         unsigned char* source_data = image.GetData() + xx*3 + yy*3*image.GetWidth();
         int source_step = image.GetWidth()*3;
 
@@ -1320,7 +1317,7 @@ void wxImage::Paste( const wxImage &image, int x, int y )
 
         for (int j = 0; j < height; j++)
         {
-            for (int i = 0; i < width; i+=3)
+            for (int i = 0; i < width*3; i+=3)
             {
                 if ((source_data[i]   != r) ||
                     (source_data[i+1] != g) ||
@@ -1393,7 +1390,7 @@ wxImage wxImage::ConvertToGreyscale( double lr, double lg, double lb ) const
         {
             // calculate the luma
             double luma = (src[0] * lr + src[1] * lg + src[2] * lb) + 0.5;
-            dest[0] = dest[1] = dest[2] = wx_static_cast(unsigned char, luma);
+            dest[0] = dest[1] = dest[2] = static_cast<unsigned char>(luma);
         }
     }
 
@@ -1468,6 +1465,16 @@ wxBitmapType wxImage::GetType() const
     return M_IMGDATA->m_type;
 }
 
+void wxImage::SetType(wxBitmapType type)
+{
+    wxCHECK_RET( IsOk(), "must create the image before setting its type");
+
+    // type can be wxBITMAP_TYPE_INVALID to reset the image type to default
+    wxASSERT_MSG( type != wxBITMAP_TYPE_MAX, "invalid bitmap type" );
+
+    M_IMGDATA->m_type = type;
+}
+
 long wxImage::XYToIndex(int x, int y) const
 {
     if ( Ok() &&
@@ -2281,7 +2288,7 @@ bool wxImage::LoadFile( wxInputStream& stream, const wxString& mimetype, int ind
 
 bool wxImage::DoSave(wxImageHandler& handler, wxOutputStream& stream) const
 {
-    wxImage * const self = wx_const_cast(wxImage *, this);
+    wxImage * const self = const_cast<wxImage *>(this);
     if ( !handler.SaveFile(self, stream) )
         return false;