From cdfefaed888f722b7546460bee2df14ebdeff8ed Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sun, 21 Feb 2010 18:40:15 +0000 Subject: Simpler Fl_X::q_begin_image() function without matrix inversion that accepts scaling and rotation. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7130 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index ac139005f..ce6580a89 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2464,6 +2464,7 @@ void Fl_X::q_release_context(Fl_X *x) { #endif } +/* the former implementation void Fl_X::q_begin_image(CGRect &rect, int cx, int cy, int w, int h) { CGContextSaveGState(fl_gc); CGAffineTransform mx = CGContextGetCTM(fl_gc); @@ -2478,6 +2479,20 @@ void Fl_X::q_begin_image(CGRect &rect, int cx, int cy, int w, int h) { rect.size.width = w; rect.size.height = h; } +*/ +void Fl_X::q_begin_image(CGRect &rect, int cx, int cy, int w, int h) { + CGContextSaveGState(fl_gc); + CGRect r2 = rect; + r2.origin.x -= 0.5f; + r2.origin.y -= 0.5f; + CGContextClipToRect(fl_gc, r2); + // move graphics context to origin of vertically reversed image + CGContextTranslateCTM(fl_gc, rect.origin.x - cx - 0.5, rect.origin.y - cy + h - 0.5); + CGContextScaleCTM(fl_gc, 1, -1); + rect.origin.x = rect.origin.y = 0; + rect.size.width = w; + rect.size.height = h; +} void Fl_X::q_end_image() { CGContextRestoreGState(fl_gc); -- cgit v1.2.3