TheVampire
Programmer
Good Day all,
I have a small problem getting the PaintPicture method to work for me, and looking for some help.
What I am doing, is pasting a Metafile from the clipboard into a picturebox like this:
Dim frmt As Variant
For Each frmt In Array(vbCFBitmap, vbCFMetafile, vbCFDIB, vbCFPalette)
If Clipboard.GetFormat(frmt) Then
Set Picture2.Picture = Clipboard.GetData(frmt)
Exit For
End If
Next
So far so good. This works fine and I can see the picture in the picturebox on the screen. Next, I want to use Paintpicture to adjust this image to a specific size. I use the following code to transfer the data from one picturebox to another.
SRCPic.PaintPicture Picture2.Picture, 0, 0, 33600, 24000, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight
SRCPic.Refresh
OK, we are still working fine to this point. I have the original ( small ) image in one picturebox, and the same image ( enlarged ) in a second picturebox.
Now here is where my problem begins. I want to display a specific section of the enlarged image in a third picturebox. I use Paintpicture to cut out the portion I want.
Picture1.PaintPicture SRCPic.Picture, 0, 0, 9600, 6000, PosX, PosY, 9600, 6000
And I get an error, "Invalid Picture".
If I use debug to look at the value of Picture2.Picture, I see the single value that is the pointer to the picture. if I look at the value for SRCPic.Picture, I see 0.
All of the pictureboxes have AutoRedraw set to True.
What gives? I'm "seeing" the picture in SRCPic when I run the program, but it says that there is no picture for that control. Does Paintpicture create a new picture for the control, or does it just point at the picture that was in the original picturebox?
Thanks for any help I can get,
Robert
I have a small problem getting the PaintPicture method to work for me, and looking for some help.
What I am doing, is pasting a Metafile from the clipboard into a picturebox like this:
Dim frmt As Variant
For Each frmt In Array(vbCFBitmap, vbCFMetafile, vbCFDIB, vbCFPalette)
If Clipboard.GetFormat(frmt) Then
Set Picture2.Picture = Clipboard.GetData(frmt)
Exit For
End If
Next
So far so good. This works fine and I can see the picture in the picturebox on the screen. Next, I want to use Paintpicture to adjust this image to a specific size. I use the following code to transfer the data from one picturebox to another.
SRCPic.PaintPicture Picture2.Picture, 0, 0, 33600, 24000, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight
SRCPic.Refresh
OK, we are still working fine to this point. I have the original ( small ) image in one picturebox, and the same image ( enlarged ) in a second picturebox.
Now here is where my problem begins. I want to display a specific section of the enlarged image in a third picturebox. I use Paintpicture to cut out the portion I want.
Picture1.PaintPicture SRCPic.Picture, 0, 0, 9600, 6000, PosX, PosY, 9600, 6000
And I get an error, "Invalid Picture".
If I use debug to look at the value of Picture2.Picture, I see the single value that is the pointer to the picture. if I look at the value for SRCPic.Picture, I see 0.
All of the pictureboxes have AutoRedraw set to True.
What gives? I'm "seeing" the picture in SRCPic when I run the program, but it says that there is no picture for that control. Does Paintpicture create a new picture for the control, or does it just point at the picture that was in the original picturebox?
Thanks for any help I can get,
Robert