3

I am struggling with ESRI's Picture / IPicture Java documentation for ArcObjects 10.4.

I just need to grab the image file from my project's source (src) folder, and cast that as a Picture. Here's what I've tried:

File pictureFile = new File("myImage.bmp");
Picture pictureDisp = (Picture) pictureFile;
//  FAIL: java.io.File cannot be cast to com.esri.arcgis.support.ms.stdole.Picture

or

Image image = ImageIO.read(getClass().getResource("myImage.bmp"));
Picture pictureDisp = (Picture) image;
// FAIL: java.awt.image.BufferedImage cannot be cast to com.esri.arcgis.support.ms.stdole.Picture

I've tried the above scenarios with IPicture as well. I have no idea by what process on can set the Picture (or IPicture) in ArcObjects Java.

I can't use a file path, this project will be deployed as an add-in, and not all users will have access to the same file paths. I need the file embedded in my program. I just want my image file to be accessible via Picture or IPicture.

I've also tried creating via BmpPictureElement, with zero success.

http://help.arcgis.com/EN/sdk/10.0/Java_AO_ADF/api/arcobjects/com/esri/arcgis/support/ms/stdole/Picture.html

http://resources.esri.com/help/9.3/arcgisengine/java/api/arcobjects/com/esri/arcgis/support/ms/stdole/IPicture.html#selectPicture(int,%20int[],%20int[])

http://resources.esri.com/help/9.3/ArcGISEngine/java/api/arcobjects/com/esri/arcgis/carto/BmpPictureElement.html

  • 2
    There is no such product as "ArcDesktop". There is a product known as "ArcGIS Desktop", but it includes both ArcMap/ArcCatalog/... and ArcGIS Pro. Your documentation links are all from ArcObjects for Java (albeit long retired versions thereof). Do you mean that you are working with the "ArcObjects Java SDK"? – Vince Jan 31 at 18:59
0

In C# I use something like this:

System.Drawing.Bitmap dotNetBmp = new System.Drawing.Bitmap(@"C:\Temp\MyBitmap.bmp");     
stdole.IPictureDisp pict = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(dotNetBmp );

Maybe it's in Java similar.

|improve this answer|||||
  • Alas. Of the 2 examples and 3 links in the question, plus many other fruitless searches, I couldn't find a functioning java equivalent. Always possible that I missed it, of course. – lep Feb 25 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.