-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSourceImage.cpp
More file actions
103 lines (84 loc) · 1.91 KB
/
Copy pathCSourceImage.cpp
File metadata and controls
103 lines (84 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <wx/wfstream.h>
#include <wx/filename.h>
#include "CSourceImage.h"
IMPLEMENT_CLASS(CSourceImage, wxObject)
bool CSourceImage::LoadImage(const wxString& path)
{
try
{
wxFileName fname;
fname.Assign(path);
this->name = fname.GetName();
wxFileInputStream inputStream(path);
this->sourceImage = new wxImage(inputStream);
this->left = -1;
this->top = -1;
this->width = this->sourceImage->GetWidth();
this->height = this->sourceImage->GetHeight();
}
catch(...)
{
return false;
}
return true;
}
CSourceImage::~CSourceImage()
{
}
CSourceImage::CSourceImage()
{
this->sourceImage = NULL;
}
wxString CSourceImage::GetName()
{
return this->name;
}
int CSourceImage::GetWidth()
{
return this->width;
}
int CSourceImage::GetHeight()
{
return this->height;
}
int CSourceImage::GetLeft()
{
return this->left;
}
int CSourceImage::GetTop()
{
return this->top;
}
void CSourceImage::SetLeft(int left)
{
this->left = left;
}
void CSourceImage::SetTop(int top)
{
this->top = top;
}
//Compare, based alphabetically on name
int CSourceImage::Compare(CSourceImage **first, CSourceImage **second)
{
return (*first)->GetName().CmpNoCase((*second)->GetName());
}
//Compare, based on image area
int CSourceImage::CompareArea(CSourceImage **first, CSourceImage **second)
{
int areaFirst = (*first)->GetWidth()*(*first)->GetHeight();
int areaSecond = (*second)->GetWidth()*(*second)->GetHeight();
if(areaFirst == areaSecond)
return 0;
if(areaFirst > areaSecond)
return -1;
return 1;
}
wxImage* CSourceImage::GetImage()
{
return this->sourceImage;
}
#include <wx/arrimpl.cpp>
WX_DEFINE_OBJARRAY(SourceImageList);