Results 1 to 3 of 3

Thread: [RESOLVED] Flip image in SetDIBitsToDevice

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [RESOLVED] Flip image in SetDIBitsToDevice

    In the SetDIBitsToDevice API function,

    Declare Function SetDIBitsToDevice Lib "gdi32" (ByVal hdc As Long, ByVal XDest As Long, ByVal yDest As Long, ByVal dx As Long, ByVal dy As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal Scan As Long, ByVal NumScans As Long, Bits As Any, BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long

    xDest, yDest are the coordinates of the upper left corner of the destination rectangle whereas
    xSrc, ySrc are the coordinates of the lower left corner of the source DIB.

    Therefore the original image comes out with the Y axis flipped.

    In order to restore the Y orientation, can I give different function parameters or do I have to switch the source rows? I'm using a 2 dimensional souce array.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Flip image in SetDIBitsToDevice

    Does changing the bitmapinfo .biHeight to -.biHeight work?
    See your other thread here
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Flip image in SetDIBitsToDevice

    Quote Originally Posted by LaVolpe View Post
    Does changing the bitmapinfo .biHeight to -.biHeight work?
    See your other thread here
    So I had that same trouble a few years ago... Thanks for reminding me.

    But setting the negative sign to .biHeight didn't work.

    However this worked for me: right after SetDIBitsToDevice I included this statement and the final image was ok:

    StretchBlt pic1.hdc, 0, 0, pic1.Width, pic1.Height, pic1.hdc, 0, pic1.Height, pic1.Width, -pic1.Height, vbSrcCopy
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

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