Saving image from Picturebox...

Saving image from Picturebox...

tech
Enthusiast Enthusiast
1,727 Views
6 Replies
Message 1 of 7

Saving image from Picturebox...

tech
Enthusiast
Enthusiast

Hi guys I am stuck on a strange one. I get an image from the camera object using apprentice and puting it into a Picturebox. But when I try and save the image using the standard Picturebox.image.save method I get an error. Can anyone shed some light on this for me?

 

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click

        Dim oApprentice As New Inventor.ApprenticeServerComponent

        Dim Doc As Inventor.ApprenticeServerDocument
        Doc = oApprentice.Open(oApp.ActiveDocument.FullFileName) 'oApp is defined elsewhere.

        ' Create a client view for the document, passing in the hWnd for a picture box.  
        Dim clientView As Inventor.ClientView = Doc.ClientViews.Add(PictureBox1.Handle)

        ' Get the camera that’s associated with the client view.  
        Dim cam As Inventor.Camera = clientView.Camera

        ' Define the camera.  
        cam.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
        cam.Perspective = False

        cam.Fit()
        cam.Apply()

        clientView.Documen()

        ' Drawing the current view.  
        clientView.Update(False)

        Dim oImage As Drawing.Image
        oImage = PictureBox1.Image

        oImage.Save("c:\temp\imagefile.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

    End Sub

0 Likes
1,728 Views
6 Replies
Replies (6)
Message 2 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

could you take a look if this blog helps you?

 http://modthemachine.typepad.com/my_weblog/2010/06/accessing-thumbnail-images.html

0 Likes
Message 3 of 7

Raider_71
Collaborator
Collaborator

Hi thanks for the feedback.

Yes I know about those other methods but they still use the VB6 compatibility references. In particular: Microsoft.VisualBasic.Compatibility and STDOLE.

When creating a .Net4 project in Visual Studio it warns you that that’s obsolete. So I was hoping that there is a more current way, using ,Net 4 components and libraries, to extract the images from Inventor files.??

 

Awaiting your feedback

 

Thanks

Pieter

0 Likes
Message 4 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

I see.

 

I forgot to recommend with the other blog

http://adndevblog.typepad.com/manufacturing/2012/07/get-thumbnail-image-by-metafile.html

 

Hope this helps.

0 Likes
Message 5 of 7

Raider_71
Collaborator
Collaborator

Thanks that could help. I am trying it now but get an error " 'ThumbnailCallback' is not declared. It may be inaccessible because of its protection level"

You can download my project here: File

 

At the end of the day I would like to save the image to disk and also display it in the Picturebox.

 

2012-11-27 11-56-02 AM.png

0 Likes
Message 6 of 7

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

Obviously, you have not declared the function ThumbnailCallback. As you can see from that blog, a function is declared:

 

// callback function for GetThumbnailImageAbort

bool ThumbnailCallback()

{

    return false;

}

 

I believe it is not difficult for you to convert the code to VB.NET. 

 

Please give it a try.

 

0 Likes
Message 7 of 7

NachoShaw
Advisor
Advisor

Hi

 

If it helps, i could never get this to work and i was more interested in the Client View rather than the thumbnail image. Especially because i couldnt always get a thumbnail and apprentice doesnt work with an in process application. In the end, i made a rectangle to go around the picturebox and wrote a routine to take a snapshot of the contents inside the rectangle. works great for me 🙂

 

you can do it by using the Bitmap function

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes