Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Chris
Posted

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)

Chris
Posted

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?

Chris
Posted

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

Chris

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...