|
-
Mar 16th, 2000, 04:46 AM
#1
Thread Starter
New Member
What is the best way of saving an (bitmap) image in an OLE control to a bitmap (.bmp) file. This is the method I'm using but I get a "No object" error at the line,
"olePicture.SaveToFile (FileNumber)".
Dim FileNumber As Integer
Dim LocationAndFileName As String
FileNumber = FreeFile()
LocationAndFileName = App.Path & "\Logo.bmp"
Open LocationAndFileName For Binary As #FileNumber
olePicture.SaveToFile (FileNumber)
Close #FileNumber
-
Mar 16th, 2000, 04:51 AM
#2
Fanatic Member
Use
Image1.picture = loadpicture("whatever")
SavePicture Image1.picture, "C:\Test.bmp"
Good luck
-
Mar 16th, 2000, 05:05 AM
#3
Thread Starter
New Member
I thought about using the image control with SavePicture but the picture is actually loaded into the OLE control from an access database field that is itself an OLE field. I then want to dump the picture from the OLE control to a bitmap file.
One option might be to load an image control with the picture from the OLE control. (I've already tried loading the picture into an image or picture control directly from the OLE field in the database but this didn't work). Then using the SavePicture routine to save the image to a bitmap from that image control. I don't know how set an image/picture control to display the image in the OLE control though. Any ideas?
-
Mar 16th, 2000, 05:28 AM
#4
Fanatic Member
I have never used the OLE control. I have made a test database in access with image file.
How did you bind the field to the OLE control?
-
Mar 16th, 2000, 05:33 AM
#5
Thread Starter
New Member
I just used a simple data control.
I got that code working that I previously posted but found that the file content saved was not actually a bitmap. So after the routine saved the file from the OLE control the file was not editable in Paint. What a bummer. I think I'm barking up the wrong tree here.
How did you store an image into an MS Access field and retreive it to a image/picturebox control in VB?
-
Mar 16th, 2000, 05:35 AM
#6
Fanatic Member
Never mind, I found out. I have to connect using an DAO control rather than an ADO control.
Now I will try to transfer the picture to the Image box.
Chemically Formulated As:
Dr. Nitro
-
Mar 16th, 2000, 05:43 AM
#7
Thread Starter
New Member
What data type did you use for the field in the MS Access database to store the image? (Eg: Text, Number, OLE etc.)
-
Mar 16th, 2000, 05:44 AM
#8
Fanatic Member
Binary Ole
I am still working on this!
-
Mar 17th, 2000, 02:12 AM
#9
I got something working, but it doesn't really look nice. The olecontrol must be running, in order to access the picture. This pops up a menubar, which shifts the form a bit down. I used an invisible picturebox to copy the picture to, and then used the savepicture method.
Code:
Private Sub Command1_Click()
OLE1.DoVerb
Picture1.AutoRedraw = True
Picture1.PaintPicture OLE1.Picture, 0, 0, Picture1.Width, Picture1.Height, 0, 0, ScaleX(OLE1.Picture.Width, vbHimetric, vbTwips), ScaleY(OLE1.Picture.Height, vbHimetric, vbTwips)
Set Picture1.Picture = Picture1.Image
SavePicture Picture1.Picture, "c:\temp\test1234.bmp"
OLE1.Close
End Sub
Private Sub OLE1_Resize(HeightNew As Single, WidthNew As Single)
Picture1.BorderStyle = 0
Picture1.Height = HeightNew
Picture1.Width = WidthNew
End Sub
-
Mar 17th, 2000, 03:56 AM
#10
Fanatic Member
Try this one Pactor1!
I used Fransc's code but add on additional part.
Private Sub Command1_Click()
'PURPOSE:Resize the controls
OLE1.SizeMode = 2
DoEvents
Picture1.Width = OLE1.Width
Picture1.Height = OLE1.Height
OLE1.DoVerb
Picture1.AutoRedraw = True
Picture1.PaintPicture OLE1.Picture, 0, 0, Picture1.Width, Picture1.Height, 0, 0, ScaleX(OLE1.Picture.Width, vbHimetric, vbTwips), ScaleY(OLE1.Picture.Height, vbHimetric, vbTwips)
Set Picture1.Picture = Picture1.Image
SavePicture Picture1.Picture, "c:\Temp\Test.bmp"
OLE1.Close
End Sub
Private Sub OLE1_Resize(HeightNew As Single, WidthNew As Single)
Picture1.BorderStyle = 0
Picture1.Height = HeightNew
Picture1.Width = WidthNew
End Sub
Chemically Formulated As:
Dr. Nitro
-
Mar 19th, 2000, 04:17 AM
#11
Thread Starter
New Member
Thanks, guys. I've implemented the code and it's working well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|