Results 1 to 7 of 7

Thread: [Resolved] Image Flipping with BitBlt?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Resolved [Resolved] Image Flipping with BitBlt?

    How can I use BitBlt to flip an image horizontally? I'm figuring I just have to mess with the x, y, width, height, but I can't seem to figure it out. I tried searching, but just saw some examples using PaintPicture. I tried to replicate it using BitBlt but just got a blank image.

    Any ideas?
    Last edited by The Hobo; Oct 9th, 2005 at 02:06 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Image Flipping with BitBlt?

    Easy with PainPicture:

    Flipping graphics vertically and/or horizontally

    You can flip graphics very simply, by using the PaintPicture method of picture boxes and forms. You use a negative height and/or width to make the picture flip.

    Normal, straight copy:

    Picture2.PaintPicture Picture1.Picture, 0, 0, _
    Picture1.Width, Picture1.Height, 0, 0, _
    Picture1.Width, Picture1.Height, vbSrcCopy

    Horizontal flip:

    Picture2.PaintPicture Picture1.Picture, 0, 0, _
    Picture1.Width, Picture1.Height, Picture1.Width, _
    0, -Picture1.Width, Picture1.Height, vbSrcCopy

    Vertical flip:

    Picture2.PaintPicture Picture1.Picture, 0, 0, _
    Picture1.Width, Picture1.Height, 0, Picture1.Height, _
    Picture1.Width, -Picture1.Height, vbSrcCopy

    Horizontal and Vertical flip:

    Picture2.PaintPicture Picture1.Picture, 0, 0, _
    Picture1.Width, Picture1.Height, Picture1.Width, _
    Picture1.Height, -Picture1.Width, -Picture1.Height, vbSrcCopy
    http://www.mentalis.org/tips/tip103.shtml

  3. #3
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Image Flipping with BitBlt?

    I don't think the BitBlt function works the same way as the PaintPicture function, hence why you end up with a blank image. You can either use the easy PaintPicture method, or possibly use Set/GetBitmapBits to reverse it (which would be a bit faster, but alot harder).

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Image Flipping with BitBlt?

    Quote Originally Posted by The Hobo
    I tried searching, but just saw some examples using PaintPicture. I tried to replicate it using BitBlt but just got a blank image.
    I'm looking for a way to do it with BitBlt?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Image Flipping with BitBlt?

    Quote Originally Posted by chemicalNova
    I don't think the BitBlt function works the same way as the PaintPicture function, hence why you end up with a blank image. You can either use the easy PaintPicture method, or possibly use Set/GetBitmapBits to reverse it (which would be a bit faster, but alot harder).

    chem
    I found an example somewhere here on VBForums doing it with StretchBlt, and I thought StretchBlt was just an extension of BitBlt, so I figured there'd be a way to do it with BitBlt.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Image Flipping with BitBlt?

    Here's the code with StretchBlt:

    VB Code:
    1. StretchBlt picScreen.hdc, picSource.ScaleWidth, 0, -picSource.ScaleWidth, picSource.ScaleHeight, _
    2.     picSource.hdc, 0, 0, picSource.ScaleWidth, picSource.ScaleHeight, vbSrcCopy

    I have no problem using StretchBlt, but I'm still wondering if it's possible with BitBlt?
    Last edited by The Hobo; Sep 5th, 2005 at 10:54 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Image Flipping with BitBlt?

    BitBlt does a direct bit copy, so there is no way to flip it, unlike with StretchBlt.

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