Direct2D - flipping bitmaps

Started by
0 comments, last by Vertex333 12 years, 9 months ago
Hi,
Does anyone know how to flip a ID2D1Bitmap interface horizontally with Direct2D?
I found out that using transformation with Matrix3x2F(-1, 0, 0, 1, 0, 0) and then translate will work.
But I want to create a new ID2D1Bitmap that was flipped.
Any help will be appreciated.
Advertisement
You could do that in different ways.

You could create a bitmapbrush. The brush contains your already flipped bitmap. You can directly use that brush to draw anywhere with a brush (transformation should be a property on the createbitmapbrush call). Use that if you can use a brush for your further drawing. http://msdn.microsoft.com/en-us/library/dd371122(v=VS.85).aspx & http://msdn.microsoft.com/en-us/library/dd756677(v=VS.85).aspx & http://msdn.microsoft.com/en-us/library/dd742778(v=VS.85).aspx & http://msdn.microsoft.com/en-us/library/dd368077(v=VS.85).aspx

You could create a bitmaprendertarget (http://msdn.microsof...6(v=VS.85).aspx) Simply draw you bitmap flipped into this rendertarget. Afterwards you "get" the "Bitmap" (which is flipped) and can then use the bitmap (don't forget that there is a dependency of the bitmap to the bitmaprendertarget). Use that if you really need a bitmap.

Layer would be an additional option, but I think you would waste performance if you draw your image more than once. Maybe this is one of the faster solution to code, it may have bad performance for every drawing operation (depends).

You could create a WICBitmap and render into it, which I can't recommand (defaults automatically to software). In addition you could also create a normal direct3D 10.1 texture/dxgisurface, but I think you will go for D2D only so this would be overkill for you.

I think the first solution is the way to go, if you really need the bitmap interface itself use the second solution. If you know what you do you could try the layer stuff, forget the rest.

Please ask if you need more help with implementation for one of these solutions. Me or someone else will help you for sure.

Vertex

This topic is closed to new replies.

Advertisement