Rotating a picture.....

Hi all,
        I am developing a system for embedded systems(pocket PC and Windows CE)...... I have written a function ImageLoad that loads the Image(Map in BMP) from File into memory (using SHLoadDIBitmap) The max size for the Map is 4000x4000 pixels....This function returns the hDC of the image.......Then I draw the image (only 640x480 i.e. the current position) pixels from the Memory hDC to destination hDC using Bitblt......

My problem is that I want to rotate the 640 x 480 pixels at any angle before bliting them into the destination DC........
i.e I want to have something like this

Rotate(srchDC as long, angle as long) as RothDC..... i.e a function that rotates the image(only 640x480) in memory and returns the device context of the rotated image.....This is one possibility.....Any other will be greatly appreciated...........like using an array to rotate the 640x480 image and then displaying the reult into a picture box......

I hope I have made my question clear.....If something is not clear do post and do help me.........

Note::: I am developing in EVB but any code in VB might also be helpful to me(If it is not using any API not supported by EVB)

Imran
LVL 13
imarshadAsked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
HOWTO: Rotate a Bitmap Image in 90-Degree Increments
http://support.microsoft.com/default.aspx?scid=KB;en-us;q186260
0
 
imarshadAuthor Commented:
Not 90 degree but any angle.....
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Erick37Commented:
Is speed an issue?
0
 
imarshadAuthor Commented:
>>Is speed an issue?
No not that much.......
If I can rotate these pixels in about 1.5 to 2 sec. I will be happy.......

Imran
0
 
imarshadAuthor Commented:
Dhaest,
         Your first comment (Microsoft code) is almost exactly what I want.......Only that I want to improve it to support any angle.......

The other links mostly use SetPixel and GetPixel which is unfortunatily not supported by EVB.......

Imran
0
 
ampapaConnect With a Mentor Commented:
Here is another link that might help: http://www.devx.com/vb2themax/Tip/19359
0
 
imarshadAuthor Commented:
No more help?
0
 
Erick37Commented:
The sample pointed to by ampapa dod not work in eVB?
0
 
imarshadAuthor Commented:
It might work...... But I am looking for something like what DHAEST has suggested.....I mean the first link(from Microsoft)
that will take my hdc as input and will return the DC of rotated picture..... Only that it is only rotating in increments of 90 degrees.....

Imran
0
 
Erick37Connect With a Mentor Commented:
Looking briefly at the MS sample, it seems that they are using BitBlt to perform the pixel operations instead of GetPixel/SetPixel.  So then it will be quite easy to use any of the above samples which rotate an image by any angle and just replace the bit of code using GetyPixel/SetPixel with a call to BitBlt.  

The article says: "With a little work, the code can be modified to rotate to any angle, but that is beyond the scope of this article."  I will take a closer look tonight if I get the chance.

The question is does that sample run on CE?
0
 
imarshadAuthor Commented:
>>just replace the bit of code using GetyPixel/SetPixel with a call to BitBlt.
Yes and I never thought about this earlier..... But I think speed can be an issue now......as calling Bitblt for 640x480 times might be very very slow........ (As far as I have understood from this is that I will need to individually Bitblt each pixel to a new position(on basis of rotation) in the memory and then bitblt the resultant image into the displaying area).......

Imran
0
 
imarshadAuthor Commented:
>>The question is does that sample run on CE?

Yes it does run......

Imran
0
All Courses

From novice to tech pro — start learning today.