Solved

Rotating a picture.....

Posted on 2004-10-24
295 Views
Last Modified: 2012-06-27
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
0
Question by:imarshad
    14 Comments
     
    LVL 53

    Accepted Solution

    by:
    HOWTO: Rotate a Bitmap Image in 90-Degree Increments
    http://support.microsoft.com/default.aspx?scid=KB;en-us;q186260
    0
     
    LVL 13

    Author Comment

    by:imarshad
    Not 90 degree but any angle.....
    0
     
    LVL 8

    Assisted Solution

    by:ampapa
    0
     
    LVL 32

    Expert Comment

    by:Erick37
    Is speed an issue?
    0
     
    LVL 13

    Author Comment

    by:imarshad
    >>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
     
    LVL 53

    Assisted Solution

    by:Dhaest
    0
     
    LVL 13

    Author Comment

    by:imarshad
    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
     
    LVL 8

    Assisted Solution

    by:ampapa
    Here is another link that might help: http://www.devx.com/vb2themax/Tip/19359
    0
     
    LVL 13

    Author Comment

    by:imarshad
    No more help?
    0
     
    LVL 32

    Expert Comment

    by:Erick37
    The sample pointed to by ampapa dod not work in eVB?
    0
     
    LVL 13

    Author Comment

    by:imarshad
    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
     
    LVL 32

    Assisted Solution

    by:Erick37
    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
     
    LVL 13

    Author Comment

    by:imarshad
    >>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
     
    LVL 13

    Author Comment

    by:imarshad
    >>The question is does that sample run on CE?

    Yes it does run......

    Imran
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now