Reputation: 308520
This is a last-ditch effort to work around a buggy printer driver. I want to render to a compatible bitmap, then rotate it before or while copying to the printer DC.
I'm familiar with this previous question which recommended GDI+, but I'm curious to know if there's an answer using GDI only.
Upvotes: 1
Views: 2314
Reputation: 13590
Either of these techniques should work:
PlgBlt
, which "performs a bit-block transfer of the bits of color data from the specified rectangle in the source device context to the specified parallelogram in the destination device context", with the coordinates of a rotated parallelogram
A combination of SetWorldTransform
, passing in a rotation matrix, and normal BitBlt
.
Note with both these, there should be no rotation transformation in the source DC, only the destination.
I'm afraid I'm not able to give you a code example right now, but some googling did turn up some examples of how to use these functions to rotate an arbitrary number of degrees, which you could modify to hard-code to 90 degrees:
PlgBlt
(excuse the language here... it's VB)SetWorldTransform
and BitBlt
. Note that if your code modifies the transformation elsewhere (for example, any VCL's TGraphicControl
descendant will have this done in its Paint
method, and it's likely that MFC and other common WinAPI wrappers probably do too) you should use GetWorldTransform
to save the current transformation and apply yours with ModifyWorldTransform
rather than setting (overwriting) the current transformation.I'm not sure any of these count as quick or easy compared to using GDI+ :)
Upvotes: 1