How to rotate a graphic/image in .net cf?

J

juvi

Hello,

Is it possible to rotate a graphic/image in .net cf?

I want to rotate an image around a center point like a pointer of a clock.
Have no ideas where to start and if its possible or not!?

thanks for any help.
juvi
 
J

juvi

this is a good class...but this algorithm does invert the image and not
rotate it?? Which algorihm would do the following:

rotate the image by 6° everytime it is called around a point.

thx
 
P

Paul G. Tobey [eMVP]

The point is that, in order to do this relatively quickly, you're going to
need to have access to the raw bits. Calling GetPixel() and SetPixel() will
never work fast enough. You know the graphics answer to your question (or I
hope you do), new_pixel_x = cos( angle ) * ( old_pixel_x - center_x ) +
center_x, and something similar for the Y direction, etc. No doubt you'll
need to pre-calculate a table of cosine and sine values to make this fast,
too.

If the question is, how do I rotate a bitmap through a random angle in real
time on my little 400MHz RISC processor device, the answer is *very* likely
to be, "You don't".

Paul T.
 
J

juvi

thx for your reply.

Would you recommend to use 60 images for the clock hands that are drawn
every second? And if, how could I draw these images with transparent (alpha
info) image?? How could it be done to void memory leaks and what about GC?

thx
juvi

-----
Paul G. Tobey said:
The point is that, in order to do this relatively quickly, you're going to
need to have access to the raw bits. Calling GetPixel() and SetPixel() will
never work fast enough. You know the graphics answer to your question (or I
hope you do), new_pixel_x = cos( angle ) * ( old_pixel_x - center_x ) +
center_x, and something similar for the Y direction, etc. No doubt you'll
need to pre-calculate a table of cosine and sine values to make this fast,
too.

If the question is, how do I rotate a bitmap through a random angle in real
time on my little 400MHz RISC processor device, the answer is *very* likely
to be, "You don't".

Paul T.

juvi said:
this is a good class...but this algorithm does invert the image and not
rotate it?? Which algorihm would do the following:

rotate the image by 6° everytime it is called around a point.

thx

Arun said:
Take a look at this blog entry

http://blogs.msdn.com/windowsmobile/archive/2008/04/15/faster-c.aspx

Blogger Roshan khan explained very nicely, how to rotate a bitmap
image faster, so you might need to repeatedly call DoFilter() to
rotate the bitmap, which you can easily do when you read this article.

Hope this helps,
Cheers,
Arun


On Apr 23, 8:28 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
Anything is possible, but this is something that the .NET CF doesn't do
very
well with. Search the archives using the link below and see what
others
have come up with previously:

http://groups.google.com/group/microsoft.public.dotnet.framework.comp...

Paul T.





Hello,

Is it possible to rotate a graphic/image in .net cf?

I want to rotate an image around a center point like a pointer of a
clock.
Have no ideas where to start and if its possible or not!?

thanks for any help.
juvi- Hide quoted text -

- Show quoted text -
 
P

Paul G. Tobey [eMVP]

I would not use bitmaps for clock hands. It will be *MUCH* faster to simply
draw those using lines. I suppose that you might preallocate an array to
indicate the end points of the lines, to make this even faster. If you, for
some fairly inexplicable reason, need to have highly detailed hands, I'd
preallocate an array of bitmaps with the hands at each angle, and bitblt the
right one to the display at the correct position at the right time.

Paul T.

juvi said:
thx for your reply.

Would you recommend to use 60 images for the clock hands that are drawn
every second? And if, how could I draw these images with transparent
(alpha
info) image?? How could it be done to void memory leaks and what about GC?

thx
juvi

-----
Paul G. Tobey said:
The point is that, in order to do this relatively quickly, you're going
to
need to have access to the raw bits. Calling GetPixel() and SetPixel()
will
never work fast enough. You know the graphics answer to your question
(or I
hope you do), new_pixel_x = cos( angle ) * ( old_pixel_x - center_x ) +
center_x, and something similar for the Y direction, etc. No doubt
you'll
need to pre-calculate a table of cosine and sine values to make this
fast,
too.

If the question is, how do I rotate a bitmap through a random angle in
real
time on my little 400MHz RISC processor device, the answer is *very*
likely
to be, "You don't".

Paul T.

juvi said:
this is a good class...but this algorithm does invert the image and not
rotate it?? Which algorihm would do the following:

rotate the image by 6° everytime it is called around a point.

thx

:

Take a look at this blog entry

http://blogs.msdn.com/windowsmobile/archive/2008/04/15/faster-c.aspx

Blogger Roshan khan explained very nicely, how to rotate a bitmap
image faster, so you might need to repeatedly call DoFilter() to
rotate the bitmap, which you can easily do when you read this article.

Hope this helps,
Cheers,
Arun


On Apr 23, 8:28 am, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
Anything is possible, but this is something that the .NET CF doesn't
do
very
well with. Search the archives using the link below and see what
others
have come up with previously:

http://groups.google.com/group/microsoft.public.dotnet.framework.comp...

Paul T.





Hello,

Is it possible to rotate a graphic/image in .net cf?

I want to rotate an image around a center point like a pointer of
a
clock.
Have no ideas where to start and if its possible or not!?

thanks for any help.
juvi- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top