100#include <wx/bitmap.h>
101#include <wx/dcmemory.h>
102#include <wx/dcclient.h>
113 int width = src.GetWidth();
114 int height = src.GetHeight();
115 unsigned char *data = src.GetData();
116 unsigned char *ptr = data;
117 unsigned char magicRed = magicColor.Red();
118 unsigned char magicGreen = magicColor.Green();
119 unsigned char magicBlue = magicColor.Blue();
124 if (width<=0 || height<=0 || data==NULL)
129 for(i=0; i<width+1; i++) {
131 unsigned char *ptr2 = ptr;
133 for(j=0; j<height && cur; j++) {
134 if (!(ptr2[0] == magicRed &&
135 ptr2[1] == magicGreen &&
136 ptr2[2] == magicBlue))
144 if ((cur && !prev)) {
145 wxRect subRect(start, 0, i-start, height);
147 if (subRect.width > 0)
148 subImage = src.GetSubImage(subRect);
150 subImage =
wxImage(subRect.width, subRect.height);
151 result.push_back(subImage);
153 else if (!cur && prev) {
168 int width = src.GetWidth();
169 int height = src.GetHeight();
170 unsigned char *data = src.GetData();
171 unsigned char *ptr = data;
172 unsigned char magicRed = magicColor.Red();
173 unsigned char magicGreen = magicColor.Green();
174 unsigned char magicBlue = magicColor.Blue();
179 if (width<=0 || height<=0 || data==NULL)
184 for(i=0; i<height+1; i++) {
186 unsigned char *ptr2 = ptr;
188 for(j=0; j<width && cur; j++) {
189 if (!(ptr2[0] == magicRed &&
190 ptr2[1] == magicGreen &&
191 ptr2[2] == magicBlue))
199 if ((cur && !prev)) {
200 wxRect subRect(0, start, width, i-start);
202 if (subRect.width > 0)
203 subImage = src.GetSubImage(subRect);
205 subImage =
wxImage(subRect.width, subRect.height);
206 result.push_back(subImage);
208 else if (!cur && prev) {
228 images =
SplitH(src, magicColor);
235 for(i = 0; i < (int)images.size(); i++) {
236 if (images[i].
Ok()) {
237 mPieces.push_back(wxBitmap(images[i]));
246 images =
SplitV(src, magicColor);
253 for(i = 0; i < (int)images.size(); i++) {
254 if (images[i].
Ok()) {
255 mPieces.push_back(wxBitmap(images[i]));
264 mPieces.push_back(wxBitmap(src));
289 Init(type, src, magicColor);
303 int x,
int y,
int logicalFunc)
307 dc.DrawBitmap(bitmap, x, y);
310 memDC.SelectObject(bitmap);
311 dc.Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(),
318 Draw( dc, rect, wxCOPY );
324 int width = rect.width;
325 int height = rect.height;
334 for(i=0; i<num; i+=2)
337 int rollingSpace = width - fixedWidth;
338 int numRolling = num / 2;
341 for(i=0; i<num; i++) {
355 ((1+(i/2))*rollingSpace / numRolling) -
356 ((i/2)*rollingSpace / numRolling);
374 for(i=0; i<num; i+=2)
377 int rollingSpace = height - fixedHeight;
378 int numRolling = num / 2;
381 for(i=0; i<num; i++) {
395 ((1+(i/2))*rollingSpace / numRolling) -
396 ((i/2)*rollingSpace / numRolling);
#define wxRasterOperationMode
std::vector< wxImage > ImageArray
An ImageRoll is an image that can be expanded to an arbitrary size; it is made up of both fixed piece...
void Draw(wxDC &dc, wxRect rect, int logicalFunc)
void Init(RollType type, const wxImage &src, wxColour magicColor)
static ImageArray SplitV(const wxImage &src, wxColour magicColor)
ImageRoll & operator=(const ImageRoll &)
void DrawBitmap(wxDC &dc, wxBitmap &bitmap, int x, int y, int logicalFunc)
std::vector< wxBitmap > mPieces
static ImageArray SplitH(const wxImage &src, wxColour magicColor)