Results 1 to 6 of 6

Thread: Rotate Image (without control)

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    3

    Question Rotate Image (without control)

    I'm in a bit of a tight spot. I have to write a function (module) that takes two filenames and rotates one to the right 90 degrees. The problem is, I can't use a Picture Box to convert the image bits to a DIB, it all has to be done in the API.

    I have all day to do it, but I'm a bit lost. I have code to rotate the image, but then it's in a pointer to a DC with no header information (to my knowledge.) Does anybody have experience with this?

  2. #2
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: Rotate Image (without control)

    i believe the stretchblt api has a rotate function. Not 100% on that though.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    3

    Re: Rotate Image (without control)

    Quote Originally Posted by Lord Orwell
    i believe the stretchblt api has a rotate function. Not 100% on that though.
    Only problem is I have to translate between a device-dependent bitmap and device-independent bitmap.

  4. #4
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Rotate Image (without control)

    Quote Originally Posted by Ryuichi
    Only problem is I have to translate between a device-dependent bitmap and device-independent bitmap.
    That should not be a problem. You could do it with two memory DC's, one with the DDB selected and one with the DIB selected. You can copy between the two with BitBlt. I guess you could even do what you want to do with just one memory DC with the DDB selected, you could capture the DDB in DIB form using GetDibBits, rotate the bits, and put them back with SetDibBitstoDevice.

    Edit: I don't think StretchBlt can rotate, but it can mirror a bitmap along the x and y axis
    Last edited by Milk; Dec 21st, 2007 at 07:48 AM.

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2007
    Posts
    3

    Re: Rotate Image (without control)

    Quote Originally Posted by Milk
    That should not be a problem. You could do it with two memory DC's, one with the DDB selected and one with the DIB selected. You can copy between the two with BitBlt. I guess you could even do what you want to do with just one memory DC with the DDB selected, you could capture the DDB in DIB form using GetDibBits, rotate the bits, and put them back with SetDibBitstoDevice.

    Edit: I don't think StretchBlt can rotate, but it can mirror a bitmap along the x and y axis
    That is a good start, thank you. Now how do I save the DIB to a file?

  6. #6
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Rotate Image (without control)

    It's not something I've ever had to do but I think a Bitmap file is pretty much the same as a DIB with a slightly different header. I know that there is some code for this amongst the DIBSection classes at vbaccelerator

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width