• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing pictures from a dll  RSS feed

 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
How would you do it using JNI? I have googled around and not found anything.
 
Stephan van Hulst
Saloon Keeper
Posts: 7975
143
  • Mark post as helpful
  • send pies
  • 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
  • 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: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Rob! That's what i was looking for!
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!