Image Effects

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Still images can be Stretched to any extent in Visual Basic using the Tools in it. One such is the paintpicture method of the picture box.

Painpicture takes ten Arguments for its operation. They are:

1)Picture Name
2)Destination X
3)Destination Y
4)Destination Width
5)Destination Height
6)Source X
7)Source Y
8)Source Width
9)Source Height
10)Operation code to operate upon the Data being Copied.

Given Below is the code for Strecthing the Images in XY-Axis.Befor using the code set the Scalemode of both the Picture box to Pixel.Scalemode is a property which Defines the Unit of Measurement on a picturebox.

' code developed by Manikantan
' 3rd Agenda
' Site: www.3rdagenda.com
' The Piece of code Explains how to Produce Effects
' on Still Images
' to Do ..Place Two picture boxes in the form
' name them as pct_src and pct_dest
' Place a picture in the pct_src
' Have Two Command Buttons
' Name them as cmd_horiz and cmd_vert
' cmd_horiz has the code to stretch the image in the
' X axis
' cmd_vert has the code to stretch the image in the
' Y axis

Private Sub cmd_horiz_Click()
For i = 1 To pct_src.ScaleWidth
    pct_dest.PaintPicture pct_src.Picture, 0, 0, _
    pct_dest.ScaleWidth, _
    pct_dest.ScaleHeight, 0, 0, i, _
    pct_src.ScaleHeight, vbSrcCopy
Next i
End Sub

Private Sub cmd_vert_Click()
For i = 1 To pct_src.ScaleHeight
    pct_dest.PaintPicture pct_src.Picture, 0, 0, _
    pct_dest.ScaleWidth, _
    pct_dest.ScaleHeight, 0, 0, _
    pct_src.ScaleWidth, i, vbSrcCopy
Next i
End Sub

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories