This class is used for loading image icons.

svn path=/trunk/boinc/; revision=10437
This commit is contained in:
Milos Travar 2006-06-21 17:41:52 +00:00
parent 5861055795
commit c47eebf260
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
#include <wx/wx.h>
#include <wx/image.h>
#include "sg_ImageLoader.h"
BEGIN_EVENT_TABLE(ImageLoader, wxWindow)
EVT_PAINT(ImageLoader::OnPaint)
END_EVENT_TABLE()
ImageLoader::ImageLoader(wxWindow* parent) : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER)
{
}
void ImageLoader::LoadImage(const wxImage& image)
{
Bitmap = wxBitmap();//delete existing bitmap since we are loading newone
int width = image.GetWidth();
int height = image.GetHeight();
//double X_Ratio = (double) MaxWidth / (double) width;
//double Y_Ratio = (double) MaxHeight / (double) height;
//double Ratio = X_Ratio < Y_Ratio ? X_Ratio : Y_Ratio;
//wxImage Image = image.Scale((int)(Ratio * width), (int)(Ratio * height));
Bitmap = wxBitmap(image);
//width = imageGetWidth();
//height = image.GetHeight();
SetSize(width, height);
}
void ImageLoader::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
if(Bitmap.Ok())
{
dc.DrawBitmap(Bitmap, 0, 0);
}
}