wildfire1982 Posted December 10, 2003 Posted December 10, 2003 Hello folks. I have made a small function which uses an image type. Im assuming that the exception is that the object is not instatiated but thats me attempting to translate from a german operating system. If my translation is right i understand what the problem is, i just cant see it. Here is the code. Dim cmdlg1 As New SaveFileDialog Dim filename As String Dim Images As Image cmdlg1.ShowDialog() filename = cmdlg1.FileName Clipboard.SetDataObject(AxMSChart1) 'AxMSChart1.EditCopy() Dim piccy As New PictureBox Images.Save(filename) The error occurs on the very last line. Any pointers would be great, cheers Quote Chris
Administrators PlausiblyDamp Posted December 10, 2003 Administrators Posted December 10, 2003 You don't appear to be setting the variable Images to anything. Dim Images As Image What should it contain? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
wildfire1982 Posted December 10, 2003 Author Posted December 10, 2003 Sorry i new i had missed a line when i cut and pasted it. this is the line which gets the image from the clipboard it comes directly before the saving to file line. Images = Clipboard.GetDataObject.GetData(DataFormats.EnhancedMetafile, True) Quote Chris
wildfire1982 Posted December 11, 2003 Author Posted December 11, 2003 Right, i managed it. If anyone is interested it was because i needed to use an IDataObject to cast into. One minor problem now. I can save to a bmp file only but the bitmap doesnt appear to be writing in format acceptable to windows. I have no idea why. Any ideas? Quote Chris
wildfire1982 Posted December 11, 2003 Author Posted December 11, 2003 Ok sorted it. Just for future reference, or if anyone is interested. The problem was that i was using the default parameters for the image.save so i needed to include the format again in the save method as bmp otherwise it wrote rubbish to the .bmp file. so: If filename.EndsWith(".bmp".ToLower) Then PictureBox1.Image.Save(filename, PictureBox1.Image.RawFormat.Bmp) End If Quote Chris
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.