In there an api which will zoom and image in and out SMOOTHLY adn quickly?
Thanks:D
Printable View
In there an api which will zoom and image in and out SMOOTHLY adn quickly?
Thanks:D
Yes. StretchBlt.
Code:Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (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
Quote:
· hdcDest
Identifies the destination device context.
· nXOriginDest
Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
· nYOriginDest
Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
· nWidthDest
Specifies the width, in logical units, of the destination rectangle.
· nHeightDest
Specifies the height, in logical units, of the destination rectangle.
· hdcSrc
Identifies the source device context.
· nXOriginSrc
Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle.
· nYOriginSrc
Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle.
· nWidthSrc
Specifies the width, in logical units, of the source rectangle.
· nHeightSrc
Specifies the height, in logical units, of the source rectangle.
· dwRop
Specifies the raster operation to be performed. Raster operation codes define how Windows combines colors in output operations that involve a brush, a source bitmap, and a destination bitmap.
See the BitBlt function for a list of common raster operation codes.
If you're using it locally (within VB, e.g: a PictureBox), then you can use VB's PaintPicture function.
Note that PainPicture is considerbly slower than StrethBlt (important if the picture is large).
I used paintpicture before and it was slow, but StretchBlt looks a bit complicated!! Any source code available?
Code:Private Declare Function PaintDesktop Lib "user32" (ByVal hdc As Long) As Long
Private Sub Command1_Click()
'Set the width and height
Picture2.Width = 100: Picture2.Height = 100
Picture1.Width = 50: Picture1.Height = 50
'No pictures
Picture1.Picture = LoadPicture("")
DoEvents
Copy the desktop to our picturebox
PaintDesktop Picture1.hdc
'Stretch the picture
StretchBlt Picture2.hdc, 0, 0, 100, 100, Picture1.hdc, 0, 0, 50, 50, ScrCopy
End Sub
I, personally haven't tested it, but Kedaman did some tests on this, and PaintPicture proved to be faster. You could probably E-mail him for the exact numbers.