[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?
Re: Image Flipping with BitBlt?
Easy with PainPicture:
Quote:
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
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
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?
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.
Re: Image Flipping with BitBlt?
Here's the code with StretchBlt:
VB Code:
StretchBlt picScreen.hdc, picSource.ScaleWidth, 0, -picSource.ScaleWidth, picSource.ScaleHeight, _
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?
Re: Image Flipping with BitBlt?
BitBlt does a direct bit copy, so there is no way to flip it, unlike with StretchBlt.