Link to home
Start Free TrialLog in
Avatar of imarshad
imarshadFlag for Pakistan

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of imarshad

ASKER

Not 90 degree but any angle.....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is speed an issue?
>>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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No more help?
The sample pointed to by ampapa dod not work in eVB?
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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>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
>>The question is does that sample run on CE?

Yes it does run......

Imran