Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to copy a picture into an image? [zoom]

3 views
Skip to first unread message

Algolash

unread,
Jan 7, 2009, 6:58:30 AM1/7/09
to
hello
i have a problem with vb5/6..
i have a picture on which i want to draw with picture.pset, and i want
to see it zoomed (we can say zoomed?)

i tried with StretchBlt, but i cant zoom as much as i want.
so i said to myself, what about copy my picture in an image, and just
strech it..
i dont know. :/
thanks!

Larry Serflaten

unread,
Jan 7, 2009, 8:46:37 AM1/7/09
to

"Algolash" <samuel....@gmail.com> wrote

See if this gives you some ideas:

Add a picturebox to a new form and paste in the code below.
Then start drawing on the picturebox, or the form....
(Left button = Black -- Right Button = White)

LFS


Option Explicit

' Initialize Form / Picturebox
Private Sub Form_Load()
Picture1.ScaleMode = vbPixels
Picture1.Move 90, 90, 330, 330
Picture1.AutoRedraw = True
Picture1.BackColor = vbWhite
Me.Show: Me.Refresh
PlotPic 0, 0, vbWhite
End Sub

' Draw on Form
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
PlotForm X, Y, vbWhite And (Button = vbRightButton)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then PlotForm X, Y, vbWhite And (Button = vbRightButton)
End Sub

' Draw on Picturebox
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
PlotPic X, Y, vbWhite And (Button = vbRightButton)
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then PlotPic X, Y, vbWhite And (Button = vbRightButton)
End Sub

Private Sub PlotForm(ByVal X&, ByVal Y&, ByVal K&)
Dim xx&, yy As Long
xx = (X - 480) \ 165
yy = (Y - 90) \ 165
PlotPic xx, yy, K
End Sub

Private Sub PlotPic(ByVal X&, ByVal Y&, ByVal K&)
Picture1.PSet (X, Y), K
Me.PaintPicture Picture1.Image, 480, 90, 3000, 3000
End Sub


Claus Centrino

unread,
Jan 27, 2009, 7:41:28 AM1/27/09
to
As Larry already shows in his code the method you need is
the PaintPicture method with which you can copy a rectangle
area of a source picture in a target rectangle of a target
picture, by the way with different rectangle sizes and even
different ratios of width to height.

Because of the VB online help for this method is as poor as
usally and took me some wasted time too, here a short
description:
picT.PaintPicture picS.Picture, xT, yT, wT, hT, xS, yS, wS,
hS
with S indicating source and T indicating target picture
box, and x,y,w,h indicating position and size of the
rectangles. As far as I remember both picture boxes **must**
have set AutoRedraw=True.
So, if you define the target region twice so big as the
source region you hav a zoom factor of 2, a very fine thing,
and you even can have different zoom factors for x- and
y-direction.

0 new messages