Mark Ransom
Mark Ransom

Reputation: 308520

Quick/easy way to rotate a Windows bitmap by 90 degrees?

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

Answers (1)

David
David

Reputation: 13590

Either of these techniques should work:

  1. 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

  2. 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:

I'm not sure any of these count as quick or easy compared to using GDI+ :)

Upvotes: 1

Related Questions