Images are now cached as wxBitmap, not wxImage. This should improve performance.

Fixed some more corner cases of rotation+zoom.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@630 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-08-25 21:24:28 +00:00
parent 741b987d54
commit 52ec7b38c0
38 changed files with 413 additions and 165 deletions
+4
View File
@@ -46,6 +46,10 @@ class RealSize {
inline explicit RealSize(const wxImage& img)
: width(img.GetWidth()), height(img.GetHeight())
{}
/// size of a bitmap
inline explicit RealSize(const wxBitmap& img)
: width(img.GetWidth()), height(img.GetHeight())
{}
/// Negation of a size, negates both components
inline RealSize operator - () const {
+9 -1
View File
@@ -160,9 +160,17 @@ void RotatedDC::DrawBitmap(const Bitmap& bitmap, const RealPoint& pos) {
}
void RotatedDC::DrawImage (const Image& image, const RealPoint& pos, ImageCombine combine, int angle) {
Image rotated = rotate_image(image, angle + this->angle);
wxRect r = trNoNegNoZoom(RealRect(pos, RealSize(image.GetWidth(), image.GetHeight())));
wxRect r = trNoNegNoZoom(RealRect(pos, RealSize(image)));
draw_combine_image(dc, r.x, r.y, rotated, combine);
}
void RotatedDC::DrawPreRotatedBitmap(const Bitmap& bitmap, const RealPoint& pos) {
RealPoint p_ext = tr(pos) - RealSize(revX()?bitmap.GetWidth():0, revY()?bitmap.GetHeight():0);
dc.DrawBitmap(bitmap, (int) p_ext.x, (int) p_ext.y, true);
}
void RotatedDC::DrawPreRotatedImage (const Image& image, const RealPoint& pos, ImageCombine combine) {
RealPoint p_ext = tr(pos) - RealSize(revX()?image.GetWidth():0, revY()?image.GetHeight():0);
draw_combine_image(dc, p_ext.x, p_ext.y, image, combine);
}
void RotatedDC::DrawLine (const RealPoint& p1, const RealPoint& p2) {
wxPoint p1_ext = tr(p1), p2_ext = tr(p2);
+9 -3
View File
@@ -51,6 +51,9 @@ class Rotation {
inline double trX(double s) const { return s * zoomX; }
inline double trY(double s) const { return s * zoomY; }
/// Translate an angle
inline int trAngle(int a) { return (angle + a) % 360; }
/// Translate a single point
RealPoint tr(const RealPoint& p) const;
/// Translate a single size, the result may be negative
@@ -94,8 +97,7 @@ class Rotation {
public:
/// Is the rotation sideways (90 or 270 degrees)?
// Note: angle & 2 == 0 for angle in {0, 180} and != 0 for angle in {90, 270)
inline bool sideways() const { return (angle & 2) != 0; }
inline bool sideways() const { return ::sideways(angle); }
protected:
/// Is the x axis 'reversed' (after turning sideways)?
@@ -153,7 +155,11 @@ class RotatedDC : public Rotation {
/// Draw abitmap, it must already be zoomed!
void DrawBitmap(const Bitmap& bitmap, const RealPoint& pos);
/// Draw an image using the given combining mode, the image must already be zoomed!
void DrawImage (const Image& image, const RealPoint& pos, ImageCombine combine = COMBINE_NORMAL, int angle = 0);
void DrawImage (const Image& image, const RealPoint& pos, ImageCombine combine = COMBINE_DEFAULT, int angle = 0);
/// Draw a bitmap that is already zoomed and rotated
void DrawPreRotatedBitmap(const Bitmap& bitmap, const RealPoint& pos);
/// Draw an image that is already zoomed and rotated
void DrawPreRotatedImage(const Image& image, const RealPoint& pos, ImageCombine combine = COMBINE_DEFAULT);
void DrawLine (const RealPoint& p1, const RealPoint& p2);
void DrawRectangle(const RealRect& r);
void DrawRoundedRectangle(const RealRect& r, double radius);