PDA

Click to See Complete Forum and Search --> : copy a bitmap an save it


Alex W
Nov 19th, 1999, 04:34 PM
hi

how can i copy a bitmap from a picturebox, which is not visible, to an other picturebox and save it to file then?

here ist the code i wrote:

Dim c, i, Erg_Img_Copy As Long
For c = 0 To (picturebox1.ScaleHeight *12) Step 100
For i = 0 To (picturebox1.ScaleHeight *12) Step 100
Erg_Img_Copy = BitBlt(picturebox2.hdc, i, c, 100, 100, picturebox1.hdc, 0, 0, vbSrcCopy)
SavePicture picturebox2.picture, "test.bmp"
Next i
Next c

Aaron Young
Nov 20th, 1999, 11:41 AM
I'm not sure why you want to do this, but..
To Copy the Picture from 1 Picturebox to Another just use: Picture2 = Picture1
If you've Modified Picture1, use: Picture2 = Picutre1.Image
Then the Question becomes, if you're saving the Contents of Picture2, which is just the Image of Picture1,
Why not just save the Image of Picture1?
SavePicture Picture1.Image, "C:\Saved.bmp"

------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

Alex W
Nov 20th, 1999, 10:53 PM
Thank you for your answer. I have a diffrent problem. I use 2 Pictureboxes a small one (100x100 pixel) and a big one (1200x1200). I want to copy the small pic into the big one at position 0/0 then copy it a second time at 0/100 and then at 0/200 and so on, till 1100/1100) and then I wonna save it to disk.

Aaron Young
Nov 23rd, 1999, 01:49 AM
Alrighty then, try this:

Add 2 Picturebox's to a Form and a Command Button, Select the Picture you want to tile into Picture1..

Private Sub Form_Load()
Picture2.Visible = False
Picture2.AutoRedraw = True
Picture1.AutoSize = True
Picture1.ScaleMode = vbPixels
Picture2.ScaleMode = vbPixels
Picture2.BorderStyle = vbBSNone
End Sub

Private Sub Command1_Click()
Dim X As Integer
Dim Y As Integer
Dim W As Integer
Dim H As Integer

W = ScaleX(Picture1.Picture.Width, vbHimetric, vbPixels)
H = ScaleY(Picture1.Picture.Height, vbHimetric, vbPixels)
Picture2.Move 0, 0, ScaleX(1200, vbPixels, vbTwips), ScaleY(1200, vbPixels, vbTwips)
For Y = 0 To (1200 / H)
For X = 0 To (1200 / W)
Picture2.PaintPicture Picture1, X * W, Y * H, W, H, 0, 0, W, H
Next
Next
SavePicture Picture2.Image, "C:\Saved.bmp"
MsgBox "Done"
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net