diff options
| author | Manolo Gouy <Manolo> | 2010-02-21 18:40:15 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2010-02-21 18:40:15 +0000 |
| commit | cdfefaed888f722b7546460bee2df14ebdeff8ed (patch) | |
| tree | 2c9d1fe6d561b8ace8068debd977e0d7e81165cb /src | |
| parent | 0650daaaac9c310117b8962647ad6e7b494edebe (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 15 |
1 files changed, 15 insertions, 0 deletions
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); |
