|
-
Sep 5th, 2005, 07:24 PM
#1
Thread Starter
Stuck in the 80s
[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.
-
Sep 5th, 2005, 07:35 PM
#2
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
-
Sep 5th, 2005, 08:39 PM
#3
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
-
Sep 5th, 2005, 09:27 PM
#4
Thread Starter
Stuck in the 80s
Re: Image Flipping with BitBlt?
 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?
-
Sep 5th, 2005, 09:29 PM
#5
Thread Starter
Stuck in the 80s
Re: Image Flipping with BitBlt?
 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.
-
Sep 5th, 2005, 10:50 PM
#6
Thread Starter
Stuck in the 80s
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?
Last edited by The Hobo; Sep 5th, 2005 at 10:54 PM.
-
Sep 6th, 2005, 09:51 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|