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
This commit is contained in:
parent
0650daaaac
commit
cdfefaed88
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user