Re: WM5 - Bitmap Rotation



On Dec 21, 8:54 am, KevinD <kdarl...@xxxxxxxxx> wrote:
On Dec 20, 8:58 am, rubo_diada <ruben...@xxxxxxxxxxx> wrote:

Does anyone of you know if it is possible to rotate bitmap using
DirectX for WM5?

Yes, you can.

Load the picture as a texture for two triangles making up a rectangle,
and use DirectX 3D to rotate and scale it.

Another trick is to snap the current application screen using core.dll
BitBlt, saved it to a file, then loaded it and rotated.

There are managed D3D examples from Microsoft. Perhaps even in the
SDK files, I've forgotten where. A good sample source is
"Matrices.cs" I wish I could help more, but am out of time for now.

Kevin! Thanks for your help! It finally worked and I got what I
wanted.

So I can summarize this topic as the following:

Rotating bitmaps in Windows Mobile is not as easy as it seems to be at
first, because it lacks all GDI transformation functions which are
present on the desktop pc, which means that it is up to you to
implement rotation by yourself. The task is relatively easy when
you're going to rotate the bitmap by 90, 180 or 270 degrees, because
you get 1:1 ration and simply copy-paste pixels to the new bitmap with
new dimensions. For archiving fast speed you need to use memory copy
operations, rather than GetPixel/SetPixel functions. But everything
changes, when you decide to rotate your bitmap by any angle, because
if you use the same algorithm, you will get empty dots on the final
bitmap, because cos and sin of that angle are doubles and when you
calculate your final position, which should be pixel, you round that
number so that it is integer and this may come up to situation when 2
pixels from the original bitmap point to the same pixel on the
destination bitmap and some dots will be left empty. In this case you
should implement some algorithm for filling up the empty dots and this
will take you much efforts. So the easiest and in the same time quite
fast solution is to use DirectX. You simply create 2 triangles on the
XY surface of the 3D space and then rotate the world matrix along the
Z axis by the angle you want.

Thanks all of you guys for you help!
Merry Christmas and Happy New Year!
.



Relevant Pages

  • Re: WM5 - Bitmap Rotation
    ... you could just turn the device round a bit :-) ... The bitmap size is 500x1000 pixels and it should be as fast as it is ... Do you have an example of BM that you're going to rotate? ...
    (microsoft.public.pocketpc.developer)
  • Re: STGAPIBuffer rotated to landscape? Possible? How?
    ... Take the bitmap that needs to be rotated and copy it to a DIBSection then use the pointer to the raw bytes create a WORD array and store all pixels as 16bit-565, rotating the picture -90 degrees as you go. ... What I'm trying to do is tweak STGapiBuffer to rotate the bitmap for me as STGAPI is converting it to "native" format. ... In other words what needs to be changed in CreateNativeBitmap and CreateNativeBitmapFromBGRBits in order to rotate my HBITMAP 90deg counterclockwise? ...
    (microsoft.public.pocketpc.developer)
  • Re: imrotate
    ... Matlab padding the corners of the rotated image with black pixels. ... Suppose L is a uint8 grayscale image that you want to rotate, ...
    (comp.soft-sys.matlab)
  • Re: This is how I rotate an bitmap
    ... One of the cardinal rules is that you never rotate one way and then rotate back the other. ... Matrix transformations add compound errors to the values so that over time, ... Nothing of the original image is lost, it is getting smaller or the new bitmap is a little bigger then need be. ... When you've made your rotation there is no easy way to tell what is your original bitmap and what is white space. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Replacing the system mouse cursor
    ... PlgBlt is a fast way to rotate a bitmap. ... mouse_eventto inject mouse movements and clicks into Windows. ...
    (microsoft.public.vc.mfc)

Quantcast