Is there a way to flip an image upside down using BitBlt or StretchBlt. I know it says you can do it with strech blit, but the result is horible,Scrambled lines, etc.
Printable View
Is there a way to flip an image upside down using BitBlt or StretchBlt. I know it says you can do it with strech blit, but the result is horible,Scrambled lines, etc.
mine come out fine, what are you using?
(I do this)
Code:Option Explicit
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Private Sub Command1_Click()
Call StretchBlt( _
Picture2.hdc, _
0, 0, _
Picture1.ScaleX(Picture1.ScaleWidth, Picture1.ScaleMode, vbPixels), Picture1.ScaleY(Picture1.ScaleHeight, Picture1.ScaleMode, vbPixels), _
Picture1.hdc, _
0, ScaleY(Picture1.ScaleHeight, Picture1.ScaleMode, vbPixels), _
Picture1.ScaleX(Picture1.ScaleWidth, Picture1.ScaleMode, vbPixels), -Picture1.ScaleY(Picture1.ScaleHeight, Picture1.ScaleMode, vbPixels), _
vbSrcCopy _
)
End Sub
I see what i did wrong! Thank you Sam! I didn't set the top of the Dest to the top of the form!!!
You can use PaintPicture as well.
Code:Me.PaintPicture Picture1.Picture, 0, Picture1.Height, Picture1.Width, -1 * Picture1.Height
As long as we don't get into another holy war on the relative speed of BitBlt/PaintPicture.
after i finished reading "How does VB strech a Image" thread, and saw StretchBlt and PaintPicture in this thread, i got a little nervious!
AFAICS, there isn't much difference, so to sum up on about 3 different threads, use whichever one you prefer.
I created a small algorithm that would enable me to do it with the GetPixel and SetPixel APIs. It was very slow though.
rino_2: I wouldn't recommend using SetPixel and GetPixel to flip images. StretchBlt and PaintPicture are both noticably faster.
If you need an algorithm to manipulate a bitmap use Get/Set Bitmap bits (or Get/Set DIBits but I've never got the hang of them) it's a lot faster as you only have to refresh the DC once, rather than once for each pixel as with Get/Set Pixel