Matt: working on the Fl_Printer class to give FLTK print support,
I had to change function Fl_X::q_begin_image() from Fl_cocoa.mm
so it supports a graphics context with scaling and rotation.
After many complicated changes, I found that a very direct
implementation seems to work well, both for the present FLTK with
screen-only drawing, and for the future (I hope) one with
print, scaling and rotation support.
I believe to have thoroughly tested it (pixmaps, rgb, rgba, jpeg,
to screen and to paper) and to see that it produces, pixel to pixel,
the same screen output as the current implementation.
What do you think of it ? Do you see any condition where it would
not do the correct job ? You may test it readily starting from
the Fl_Printer development branch where it is committed.
P.S. I have seen that, without the 0.5 pixel magical offset, pixmaps
are displayed blurred. I slowly begin to understand, with the
explanations you gave before, the purpose of this 0.5 pixel quantity.
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;
}
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev