I'm playing with some graphical functions, where I copy a bitmap from a picturebox' hDC to a hDC of a Form.
I have already used the BitBlt, StretchBlt which allows resizing and AlphaBlend which allows resizing AND transparency. Great.
Now I'd have to flip or mirror the bitmap when transfering. Is there an API call which does it?
Or is there an option in the ROp parameter which specifies mirroring? They are only raster operations as I presume...
I found this posted on another forum maybe it will help?
You can do it, just specify negative values for you Width and/or Height (you'll have to use StrechBlt instead of BitBlt). For example:
'Assumes the picture is named deer.bmp in the current directory
Picture1.Picture = LoadPicture(App.Path & "\deer.bmp")
'Draw the picture normally (left-facing deer)
BitBlt Me.hdc, 0, 0, Picture1.Width, Picture1.Height, Picture1.hdc, 0, 0, SRCCOPY
'Draw the left/right mirror (right-facing deer)
StretchBlt Me.hdc, Picture1.Width, 0, Picture1.Width, Picture1.Height, Picture1.hdc, Picture1.Width, 0, -Picture1.Width, Picture1.Height, SRCCOPY
The first param is the DC of the form
The next 4 params are the coords on your picture box that you're drawing to (41, 0, 41, 34 for your deer picture). The first 41 is to draw the picture 41 pixels to the right, so as to be next to the first picture (drawn with BitBlt)
Then comes the source picture (Picture1's DC, a picturebox)
The next two normally specify the upper-left corner of the source picture, as an offset (most commonly 0,0). Because we'll be specifying a negative width, we'll have to offset the X value by the same amount (the width of the picture). We're not flipping the picture up/down, so the Y is left at 0.
The next two specify the width and height. The width is negative - this gives the mirrored image. The height is left at the original value (Picture1.Height).
That looks promising. Thank you, DataMiser.
However I tried negative sizes with Alphablend, but this didn't work, although I did not offset the X origin by the width, as described here
I will try it tomorrow if AlphaBlend accepts the negative values, too. If not I will have to use StretchBlt to mirror to a buffer PictureBox and then AlphaBlend it from there.
Ok, thanks again for bringing me on the way.
StretchBlt works as you described. Unfortunately AlphaBlend does not share this feature, so I would have to mirror to a buffer and then Blend, but no matter the mirroring works fine.