Saving contents of an ink picture control?

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2009
Posts: 40
Reputation: lolwtf is an unknown quantity at this point 
Solved Threads: 0
lolwtf lolwtf is offline Offline
Light Poster

Saving contents of an ink picture control?

 
0
  #1
Jul 17th, 2009
I'm using the ink picture control and I'm having trouble getting my code to work. The inkpicture control is used for tablet pcs when the user draws inside the control. I just want to be able to save it to a jpeg. I've been stuck on this for days

  1. Dim inkBounds As Rectangle
  2.  
  3. With inkBounds
  4.  
  5. .X = 0
  6.  
  7. .Y = 0
  8.  
  9. .Width = InkPicture1.Width
  10.  
  11. .Height = InkPicture1.Height
  12.  
  13. End With
  14.  
  15. Dim img As Image
  16.  
  17.  
  18. img.Save(IO.Directory.GetCurrentDirectory() & "\test_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Saving contents of an ink picture control?

 
0
  #2
Jul 18th, 2009
I don't have a tablet PC to test with, but if things work in the same way as with WinForms, your code should be following
  1. InkPicture1.Image.Save(IO.Directory.GetCurrentDirectory() & "\test_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
The code saves the image from the InkPicture1 control, not from the rectangle. I wasn't sure which one you actually wanted to save.

HTH
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 40
Reputation: lolwtf is an unknown quantity at this point 
Solved Threads: 0
lolwtf lolwtf is offline Offline
Light Poster

Re: Saving contents of an ink picture control?

 
0
  #3
Jul 24th, 2009
For some reason that gives me an "object not set to an instance of an object" exception. Any ideas to why that is?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Saving contents of an ink picture control?

 
0
  #4
Jul 25th, 2009
Ok, here's a step-by-step test which control is not set
  1. If InkPicture1 IsNot Nothing Then
  2. If InkPicture1.Image IsNot Nothing Then
  3. InkPicture1.Image.Save(IO.Directory.GetCurrentDirectory() & "\test_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
  4. Else
  5. ' InkPicture1.Image is nothing
  6. End If
  7. Else
  8. ' InkPicture1 is nothing
  9. End If
Put a message box or breakpoint on both Else parts to see if the InkPicture1 or InkPicture1.Image is not set. Can't think that something else could cause that error. This is without seeing more of your code. My guess is that you haven't assigned any initial image to InkPicture1.Image or you've somehow "lost" InkPicture1.Image in your code. In WinForms the image can be assign, for example, in the following way InkPicture1.Image = Image.FromFile("D:\test.jpg") , but I don't know how you do it with Tablet PC.

HTH
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 40
Reputation: lolwtf is an unknown quantity at this point 
Solved Threads: 0
lolwtf lolwtf is offline Offline
Light Poster

Re: Saving contents of an ink picture control?

 
0
  #5
Jul 27th, 2009
Okay I put that code and breakpoints that you suggested in there and it looks like the InkPicture1.image is what its stopping at. I tried doing something like this

  1. If Inkpicture1.Ink.Strokes.Count > 0 Then
  2. Inkpicture1.Image.Save(IO.Directory.GetCurrentDirectory() & "\test_out.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
  3. End If

but that didnt seem to help. Thats all my code i don't have any more. I still keep getting that exception and I'm still new with vb and the inkpicture
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Saving contents of an ink picture control?

 
1
  #6
Jul 28th, 2009
I did some googling and found out that InkPicture control does not even have Image property

InkEdit control has SaveFile method (see Using InkEdit, InkPicture, and Enhancing the Appearance of Ink).

InkPicture doesn't seem to have any methods for loading and saving it's content, but I found the following article: Save InkPicture image with Ink in common image formats. The code snippet is written in C# but it's quite straight forward to convert it to VB. If you're not familiar with C#, use Convert C# to VB.NET for code conversion.

HTH
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 40
Reputation: lolwtf is an unknown quantity at this point 
Solved Threads: 0
lolwtf lolwtf is offline Offline
Light Poster

Re: Saving contents of an ink picture control?

 
0
  #7
Jul 28th, 2009
Thank you for your help teme64! I finally got it to work
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC