X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=src%2Fviews.cpp;h=72b79738d44dc361ee7ee25d92a70651793b6b08;hp=758390aef76217b731328588ae6bba1daf97fc26;hb=87ab55294bcd767d86786ad1caae8b1b36b49de0;hpb=98f57d3adc542bb7753434ce31c92a6680bd6244 diff --git a/src/views.cpp b/src/views.cpp index 758390a..72b7973 100644 --- a/src/views.cpp +++ b/src/views.cpp @@ -9,7 +9,7 @@ ** This is part of the CTSim program ** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: views.cpp,v 1.163 2003/01/22 22:15:10 kevin Exp $ +** $Id: views.cpp,v 1.164 2003/01/24 05:24:19 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -268,9 +268,9 @@ EVT_MENU(IFMENU_PLOT_HISTOGRAM, ImageFileView::OnPlotHistogram) END_EVENT_TABLE() ImageFileView::ImageFileView() -: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0), m_pFilterMenu(0), - m_bMinSpecified(false), m_bMaxSpecified(false), - m_iDefaultExportFormatID(ImageFile::EXPORT_FORMAT_PNG) + : wxView(), m_pBitmap(0), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0), + m_pFilterMenu(0), m_bMinSpecified(false), m_bMaxSpecified(false), + m_iDefaultExportFormatID(ImageFile::EXPORT_FORMAT_PNG) {} ImageFileView::~ImageFileView() @@ -1060,8 +1060,8 @@ ImageFileView::setInitialClientSize () void ImageFileView::OnDraw (wxDC* dc) { - if (m_bitmap.Ok()) - dc->DrawBitmap(m_bitmap, 0, 0, false); + if (m_pBitmap && m_pBitmap->Ok()) + dc->DrawBitmap(*m_pBitmap, 0, 0, false); int xCursor, yCursor; if (m_pCanvas->GetCurrentCursor (xCursor, yCursor)) @@ -1111,7 +1111,9 @@ ImageFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) ) } } wxImage image (nx, ny, imageData, true); - m_bitmap = image.ConvertToBitmap(); + if (m_pBitmap) + delete m_pBitmap; + m_pBitmap = new wxBitmap (image); delete imageData; m_pCanvas->SetScrollbars(20, 20, nx/20, ny/20); m_pCanvas->SetBackgroundColour(*wxWHITE); @@ -1152,8 +1154,9 @@ void ImageFileView::OnEditCopy (wxCommandEvent& event) { wxBitmapDataObject *pBitmapObject = new wxBitmapDataObject; - - pBitmapObject->SetBitmap (m_bitmap); + + if (m_pBitmap) + pBitmapObject->SetBitmap (*m_pBitmap); if (wxTheClipboard->Open()) { wxTheClipboard->SetData (pBitmapObject); @@ -1196,7 +1199,7 @@ ImageFileView::OnEditPaste (wxCommandEvent& event) bool bMonochrome = false; if (bitmap.Ok() == true && bitmap.GetWidth() == nx && bitmap.GetHeight() == ny) { - wxImage image (bitmap); + wxImage image (bitmap.ConvertToImage()); double dScale3 = 3 * 255; unsigned char* pixels = image.GetData(); ImageFileArray v = rIF.getArray(); @@ -2461,7 +2464,7 @@ END_EVENT_TABLE() ProjectionFileView::ProjectionFileView() -: wxView(), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0) + : wxView(), m_pBitmap(0), m_pFrame(0), m_pCanvas(0), m_pFileMenu(0) { #ifdef DEBUG m_iDefaultNX = 115; @@ -3094,8 +3097,8 @@ ProjectionFileView::OnCreate(wxDocument *doc, long WXUNUSED(flags) ) void ProjectionFileView::OnDraw (wxDC* dc) { - if (m_bitmap.Ok()) - dc->DrawBitmap (m_bitmap, 0, 0, false); + if (m_pBitmap && m_pBitmap->Ok()) + dc->DrawBitmap (*m_pBitmap, 0, 0, false); } @@ -3150,7 +3153,9 @@ ProjectionFileView::OnUpdate (wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) } } wxImage image (nDet, nView, imageData, true); - m_bitmap = image.ConvertToBitmap(); + if (m_pBitmap) + delete m_pBitmap; + m_pBitmap = new wxBitmap (image); delete imageData; }