• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Accessing pictures from a dll

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a dll made with Dev-C++ that includes several pictures. I was wondering if there was a way to access them and use them in my Java program. Thanks in advance.
 
Sheriff
Posts: 22854
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't. Or at least, you definitely can't without JNI. DLLs are a Windows specific technique, and the way images are stored inside is too. It's possible to access the resources (not just images) from DLLs or EXEs (I've used a tool that can do this several times) but I haven't seen anything in Java yet.
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would you do it using JNI? I have googled around and not found anything.
 
Bartender
Posts: 15741
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Write some C to extract the picture from the DLL and call the C functions using JNI.
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not very familiar with C/C++. The whole reason i have the dll full of pictures is because i have 101 pictures that i need to use for the program i am using. Is there a way to have all of those pictures in one file and call them from Java? The images can be in any format, i still need to make them in Photoshop.
 
Rob Spoor
Sheriff
Posts: 22854
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd put them into one JAR file, possibly your application JAR file itself, then access them as resources. If they are located in their own JAR file you should (probably) use absolute paths. Check out Class.getResource, Class.getResourceAsStream and the matching methods in ClassLoader.
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob! That's what i was looking for!
 
Rob Spoor
Sheriff
Posts: 22854
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic