943,929 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 2313
  • VB.NET RSS
Jul 17th, 2009
0

Saving contents of an ink picture control?

Expand Post »
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

VB.NET Syntax (Toggle Plain Text)
  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)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
lolwtf is offline Offline
41 posts
since May 2009
Jul 18th, 2009
0

Re: Saving contents of an ink picture control?

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
VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Jul 24th, 2009
0

Re: Saving contents of an ink picture control?

For some reason that gives me an "object not set to an instance of an object" exception. Any ideas to why that is?
Reputation Points: 10
Solved Threads: 0
Light Poster
lolwtf is offline Offline
41 posts
since May 2009
Jul 25th, 2009
0

Re: Saving contents of an ink picture control?

Ok, here's a step-by-step test which control is not set
VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Jul 27th, 2009
0

Re: Saving contents of an ink picture control?

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

VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Light Poster
lolwtf is offline Offline
41 posts
since May 2009
Jul 28th, 2009
1

Re: Saving contents of an ink picture control?

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
Reputation Points: 218
Solved Threads: 201
Veteran Poster
Teme64 is offline Offline
1,024 posts
since Aug 2008
Jul 28th, 2009
0

Re: Saving contents of an ink picture control?

Thank you for your help teme64! I finally got it to work
Reputation Points: 10
Solved Threads: 0
Light Poster
lolwtf is offline Offline
41 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: HttpWebRequest in Windows Service
Next Thread in VB.NET Forum Timeline: Problems Connecting To a SQL Database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC