From 368d59f0d858da22d91bcf668a7ea0781256e2cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 24 Mar 2002 00:22:15 +0000 Subject: [PATCH] don't use deprecated wxImage methods inside wxWin git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14751 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/dnd/dnd.cpp | 2 +- samples/dragimag/dragimag.cpp | 4 ++-- samples/image/image.cpp | 10 +++++----- samples/rotate/rotate.cpp | 6 +++--- samples/toolbar/toolbar.cpp | 2 +- samples/treectrl/treetest.cpp | 6 ++---- src/common/fs_mem.cpp | 2 +- src/generic/dcpsg.cpp | 2 +- src/generic/dragimgg.cpp | 4 ++-- src/generic/filedlgg.cpp | 6 +++--- src/generic/imaglist.cpp | 4 ++-- src/gtk/bitmap.cpp | 7 ++++--- src/gtk/dataobj.cpp | 2 +- src/gtk/dcclient.cpp | 20 ++++++++++---------- src/gtk1/bitmap.cpp | 7 ++++--- src/gtk1/dataobj.cpp | 2 +- src/gtk1/dcclient.cpp | 20 ++++++++++---------- src/msw/bitmap.cpp | 4 ++-- src/msw/dragimag.cpp | 6 ++---- 19 files changed, 57 insertions(+), 59 deletions(-) diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 42e7ead527..9af14885d2 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -1217,7 +1217,7 @@ void DnDFrame::OnCopyBitmap(wxCommandEvent& WXUNUSED(event)) wxLogStatus( _T("Decoding image file...") ); wxYield(); - wxBitmap bitmap( image.ConvertToBitmap() ); + wxBitmap bitmap( image ); if ( !wxTheClipboard->Open() ) { diff --git a/samples/dragimag/dragimag.cpp b/samples/dragimag/dragimag.cpp index 13a4f50085..aa00bf12f3 100644 --- a/samples/dragimag/dragimag.cpp +++ b/samples/dragimag/dragimag.cpp @@ -382,7 +382,7 @@ bool MyApp::OnInit() wxImage image; if (image.LoadFile("backgrnd.png", wxBITMAP_TYPE_PNG)) { - m_background = image.ConvertToBitmap(); + m_background = wxBitmap(image); } MyFrame *frame = new MyFrame(); @@ -399,7 +399,7 @@ bool MyApp::OnInit() the first file over the second file. */ if (image.LoadFile(filename, wxBITMAP_TYPE_PNG)) { - DragShape* newShape = new DragShape(image.ConvertToBitmap()); + DragShape* newShape = new DragShape(wxBitmap(image)); newShape->SetPosition(wxPoint(i*50, i*50)); if (i == 2) diff --git a/samples/image/image.cpp b/samples/image/image.cpp index d08a07585d..262078f92c 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -138,7 +138,7 @@ public: void OnSave(wxCommandEvent& WXUNUSED(event)) { - wxImage image(m_bitmap); + wxImage image = m_bitmap.ConvertToImage(); int bppselection = wxGetSingleChoiceIndex("Set BMP BPP", "Set BMP BPP", @@ -512,7 +512,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) wxRED_PEN->GetColour().Red(), wxRED_PEN->GetColour().Green(), wxRED_PEN->GetColour().Blue() ); - dc.DrawBitmap( i.ConvertToBitmap(), 150, 2010, TRUE ); + dc.DrawBitmap( wxBitmap(i), 150, 2010, TRUE ); dc.SetTextForeground( wxT("BLACK") ); } @@ -549,7 +549,7 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) wxRED_PEN->GetColour().Red(), wxRED_PEN->GetColour().Green(), wxRED_PEN->GetColour().Blue() ); - dc.DrawBitmap( i.ConvertToBitmap(), 150, 2130, TRUE ); + dc.DrawBitmap( wxBitmap(i), 150, 2130, TRUE ); dc.SetTextForeground( wxT("BLACK") ); } @@ -633,7 +633,7 @@ void MyCanvas::CreateAntiAliasedBitmap() blue = blue/4; anti.SetRGB( x, y, red, green, blue ); } - my_anti = new wxBitmap( anti.ConvertToBitmap() ); + my_anti = new wxBitmap(anti); } // MyFrame @@ -702,7 +702,7 @@ void MyFrame::OnNewFrame( wxCommandEvent &WXUNUSED(event) ) return; } - (new MyImageFrame(this, image.ConvertToBitmap()))->Show(); + (new MyImageFrame(this, wxBitmap(image)))->Show(); } //----------------------------------------------------------------------------- diff --git a/samples/rotate/rotate.cpp b/samples/rotate/rotate.cpp index 2bdb6270e9..2f26cf2a7e 100644 --- a/samples/rotate/rotate.cpp +++ b/samples/rotate/rotate.cpp @@ -161,10 +161,10 @@ void MyCanvas::OnMouseLeftUp (wxMouseEvent & event) const wxImage& img = wxGetApp().GetImage(); wxImage img2 = img.Rotate(frame->m_angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), TRUE, &offset); - wxBitmap bmp = img2.ConvertToBitmap (); + wxBitmap bmp(img2); wxClientDC dc (this); - dc.DrawBitmap (img2.ConvertToBitmap(), event.m_x + offset.x, event.m_y + offset.y, TRUE); + dc.DrawBitmap (bmp, event.m_x + offset.x, event.m_y + offset.y, TRUE); } // without interpolation, and without offset correction @@ -175,7 +175,7 @@ void MyCanvas::OnMouseRightUp (wxMouseEvent & event) const wxImage& img = wxGetApp().GetImage(); wxImage img2 = img.Rotate(frame->m_angle, wxPoint(img.GetWidth()/2, img.GetHeight()/2), FALSE); - wxBitmap bmp = img2.ConvertToBitmap (); + wxBitmap bmp(img2); wxClientDC dc (this); dc.DrawBitmap (bmp, event.m_x, event.m_y, TRUE); diff --git a/samples/toolbar/toolbar.cpp b/samples/toolbar/toolbar.cpp index e115cb6be7..8adccafd3a 100644 --- a/samples/toolbar/toolbar.cpp +++ b/samples/toolbar/toolbar.cpp @@ -274,7 +274,7 @@ void MyFrame::RecreateToolbar() for ( size_t n = 0; n < WXSIZEOF(toolBarBitmaps); n++ ) { toolBarBitmaps[n] = - wxImage(toolBarBitmaps[n]).Scale(w, h).ConvertToBitmap(); + wxBitmap(toolBarBitmaps[n].ConvertToImage().Scale(w, h)); } toolBar->SetToolBitmapSize(wxSize(w, h)); diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 4a7a80ded0..2eed27fb7d 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -669,8 +669,7 @@ void MyTreeCtrl::CreateImageList(int size) } else { - images->Add(wxImage(icons[i]).Rescale(size, size). - ConvertToBitmap()); + images->Add(wxBitmap(icons[i].ConvertToImage().Rescale(size, size))); } } #endif // MSW/!MSW @@ -714,8 +713,7 @@ void MyTreeCtrl::CreateButtonsImageList(int size) } else { - images->Add(wxImage(icons[i]).Rescale(size, size). - ConvertToBitmap()); + images->Add(wxBitmap(icons[i].ConvertToImage().Rescale(size, size))); } } #endif // MSW/!MSW diff --git a/src/common/fs_mem.cpp b/src/common/fs_mem.cpp index 2bfcfd02be..93e51c7625 100644 --- a/src/common/fs_mem.cpp +++ b/src/common/fs_mem.cpp @@ -174,7 +174,7 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename) /*static*/ void wxMemoryFSHandler::AddFile(const wxString& filename, const wxBitmap& bitmap, long type) { - wxImage img(bitmap); + wxImage img = bitmap.ConvertToImage(); AddFile(filename, img, type); } diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index fd36a5b783..a81806e5ac 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -881,7 +881,7 @@ void wxPostScriptDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, if (!bitmap.Ok()) return; - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); if (!image.Ok()) return; diff --git a/src/generic/dragimgg.cpp b/src/generic/dragimgg.cpp index e7632a737c..c1e5edca9d 100644 --- a/src/generic/dragimgg.cpp +++ b/src/generic/dragimgg.cpp @@ -164,9 +164,9 @@ bool wxGenericDragImage::Create(const wxString& str, const wxCursor& cursor) #if wxUSE_IMAGE_IN_DRAGIMAGE // Make the bitmap masked - wxImage image(bitmap); + wxImage image = bitmap.ConvertToImage(); image.SetMaskColour(255, 255, 255); - bitmap = image.ConvertToBitmap(); + bitmap = wxBitmap(image); #endif return Create(bitmap, cursor); diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 4f2629a4fa..8245e15338 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -263,7 +263,7 @@ static wxBitmap CreateAntialiasedBitmap(const wxImage& img) p1 += 32 * 3, p2 += 32 * 3; } - return small.ConvertToBitmap(); + return wxBitmap(small); } // finds empty borders and return non-empty area of image: @@ -332,12 +332,12 @@ int wxFileIconsTable::GetIconID(const wxString& extension, const wxString& mime) m_HashTable.Put(extension, new wxFileIconEntry(newid)); return newid; } - wxImage img(ic); + wxImage img = ic.ConvertToImage(); delete ft; int id = m_ImageList.GetImageCount(); if (img.GetWidth() == 16 && img.GetHeight() == 16) - m_ImageList.Add(img.ConvertToBitmap()); + m_ImageList.Add(wxBitmap(img)); else { if (img.GetWidth() != 32 || img.GetHeight() != 32) diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index aa3a292208..64995176e2 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -75,9 +75,9 @@ int wxImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask ) int wxImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour ) { - wxImage img(bitmap); + wxImage img = bitmap.ConvertToImage(); img.SetMaskColour(maskColour.Red(), maskColour.Green(), maskColour.Blue()); - return Add(img.ConvertToBitmap()); + return Add(wxBitmap(img)); } const wxBitmap *wxImageList::GetBitmap( int index ) const diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 0a27495252..634273f99e 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -99,7 +99,7 @@ bool wxMask::Create( const wxBitmap& bitmap, m_bitmap = (GdkBitmap*) NULL; } - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); if (!image.Ok()) return FALSE; m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 ); @@ -954,7 +954,7 @@ bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(pal // Try to save the bitmap via wxImage handlers: { - wxImage image( *this ); + wxImage image = ConvertToImage(); if (image.Ok()) return image.SaveFile( name, type ); } @@ -991,7 +991,8 @@ bool wxBitmap::LoadFile( const wxString &name, int type ) { wxImage image; if (!image.LoadFile( name, type )) return FALSE; - if (image.Ok()) *this = image.ConvertToBitmap(); + if (image.Ok()) + *this = wxBitmap(image); else return FALSE; } diff --git a/src/gtk/dataobj.cpp b/src/gtk/dataobj.cpp index cae5a43dfb..cfbf0deb8a 100644 --- a/src/gtk/dataobj.cpp +++ b/src/gtk/dataobj.cpp @@ -358,7 +358,7 @@ void wxBitmapDataObject::DoConvertToPng() wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL, wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") ); - wxImage image(m_bitmap); + wxImage image = m_bitmap.ConvertToImage(); wxCountingOutputStream count; image.SaveFile(count, wxBITMAP_TYPE_PNG); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 5cb5431280..d7eee8e5de 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -416,7 +416,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); memdc.SelectObject(wxNullBitmap); - wxImage image(bitmap); + wxImage image = bitmap.ConvertToImage(); col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); return TRUE; } @@ -999,12 +999,12 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, wxBitmap use_bitmap; if ((w != ww) || (h != hh)) { - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); image.Rescale( ww, hh ); if (is_mono) - use_bitmap = image.ConvertToMonoBitmap(255,255,255); + use_bitmap = wxBitmap(image.ConvertToMono(255,255,255), 1); else - use_bitmap = image.ConvertToBitmap(); + use_bitmap = wxBitmap(image); } else { @@ -1199,13 +1199,13 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, if ((bm_width != bm_ww) || (bm_height != bm_hh)) { - wxImage image( memDC->m_selected ); + wxImage image = memDC->m_selected.ConvertToImage(); image = image.Scale( bm_ww, bm_hh ); if (is_mono) - use_bitmap = image.ConvertToMonoBitmap(255,255,255); + use_bitmap = wxBitmap(image.ConvertToMono(255,255,255), 1); else - use_bitmap = image.ConvertToBitmap(); + use_bitmap = wxBitmap(image); } else { @@ -1313,11 +1313,11 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); /* scale image */ - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); image = image.Scale( ww, hh ); /* convert to bitmap */ - bitmap = image.ConvertToBitmap(); + bitmap = wxBitmap(image); /* draw scaled bitmap */ gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); @@ -1456,7 +1456,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, minY = (wxCoord)(dmin(y2, dmin(y3, y4)) - 0.5); // prepare to blit-with-rotate the bitmap to the DC - wxImage image(src); + wxImage image = src.ConvertToImage(); GdkColor *colText = m_textForegroundColour.GetColor(), *colBack = m_textBackgroundColour.GetColor(); diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index 0a27495252..634273f99e 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -99,7 +99,7 @@ bool wxMask::Create( const wxBitmap& bitmap, m_bitmap = (GdkBitmap*) NULL; } - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); if (!image.Ok()) return FALSE; m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 ); @@ -954,7 +954,7 @@ bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(pal // Try to save the bitmap via wxImage handlers: { - wxImage image( *this ); + wxImage image = ConvertToImage(); if (image.Ok()) return image.SaveFile( name, type ); } @@ -991,7 +991,8 @@ bool wxBitmap::LoadFile( const wxString &name, int type ) { wxImage image; if (!image.LoadFile( name, type )) return FALSE; - if (image.Ok()) *this = image.ConvertToBitmap(); + if (image.Ok()) + *this = wxBitmap(image); else return FALSE; } diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp index cae5a43dfb..cfbf0deb8a 100644 --- a/src/gtk1/dataobj.cpp +++ b/src/gtk1/dataobj.cpp @@ -358,7 +358,7 @@ void wxBitmapDataObject::DoConvertToPng() wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL, wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") ); - wxImage image(m_bitmap); + wxImage image = m_bitmap.ConvertToImage(); wxCountingOutputStream count; image.SaveFile(count, wxBITMAP_TYPE_PNG); diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 5cb5431280..d7eee8e5de 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -416,7 +416,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); memdc.SelectObject(wxNullBitmap); - wxImage image(bitmap); + wxImage image = bitmap.ConvertToImage(); col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); return TRUE; } @@ -999,12 +999,12 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, wxBitmap use_bitmap; if ((w != ww) || (h != hh)) { - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); image.Rescale( ww, hh ); if (is_mono) - use_bitmap = image.ConvertToMonoBitmap(255,255,255); + use_bitmap = wxBitmap(image.ConvertToMono(255,255,255), 1); else - use_bitmap = image.ConvertToBitmap(); + use_bitmap = wxBitmap(image); } else { @@ -1199,13 +1199,13 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, if ((bm_width != bm_ww) || (bm_height != bm_hh)) { - wxImage image( memDC->m_selected ); + wxImage image = memDC->m_selected.ConvertToImage(); image = image.Scale( bm_ww, bm_hh ); if (is_mono) - use_bitmap = image.ConvertToMonoBitmap(255,255,255); + use_bitmap = wxBitmap(image.ConvertToMono(255,255,255), 1); else - use_bitmap = image.ConvertToBitmap(); + use_bitmap = wxBitmap(image); } else { @@ -1313,11 +1313,11 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); /* scale image */ - wxImage image( bitmap ); + wxImage image = bitmap.ConvertToImage(); image = image.Scale( ww, hh ); /* convert to bitmap */ - bitmap = image.ConvertToBitmap(); + bitmap = wxBitmap(image); /* draw scaled bitmap */ gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); @@ -1456,7 +1456,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, minY = (wxCoord)(dmin(y2, dmin(y3, y4)) - 0.5); // prepare to blit-with-rotate the bitmap to the DC - wxImage image(src); + wxImage image = src.ConvertToImage(); GdkColor *colText = m_textForegroundColour.GetColor(), *colBack = m_textBackgroundColour.GetColor(); diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 99e6867101..086d472183 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -948,7 +948,7 @@ bool wxBitmap::LoadFile(const wxString& filename, long type) wxImage image; if ( image.LoadFile( filename, type ) && image.Ok() ) { - *this = image.ConvertToBitmap(); + *this = wxBitmap(image); return TRUE; } @@ -990,7 +990,7 @@ bool wxBitmap::SaveFile(const wxString& filename, else { // FIXME what about palette? shouldn't we use it? - wxImage image( *this ); + wxImage image = ConvertToImage(); if ( image.Ok() ) { return image.SaveFile(filename, type); diff --git a/src/msw/dragimag.cpp b/src/msw/dragimag.cpp index ababd9e7cd..c94a7d33d9 100644 --- a/src/msw/dragimag.cpp +++ b/src/msw/dragimag.cpp @@ -222,11 +222,9 @@ bool wxDragImage::Create(const wxString& str, const wxCursor& cursor) dc2.SelectObject(wxNullBitmap); // Make the bitmap masked - wxImage image(bitmap); + wxImage image = bitmap.ConvertToImage(); image.SetMaskColour(255, 255, 255); - bitmap = image.ConvertToBitmap(); - - return Create(bitmap, cursor); + return Create(wxBitmap(image), cursor); } // Create a drag image for the given tree control item -- 2.45.2