Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Embedded images/sounds?

Started by CodeMachine Sep 14, 2006 at 5:55 AM 2 replies 850+ views
Original Post
CodeMachine
CodeMachine
Hi Is embedded resources supported in Java? The thing is that I want my images/sounds to be embedded in the exe-file. (I dont want them to be individual files in my .jar-file) One solution that works for small images is to save the pixel-indexes (palette-indexes) and the palette-data as two separete arrays. Then you create the image on the fly by MemoryImageSource, IndexColorModel and Toolkit.getDefaultToolkit().createImage(MemoryImageSource). But now I have a quite large image and get the error: "The code of constructor MyPanel() is exceeding the 65535 bytes limit". The code:

public class MyPanel() extends JPanel {
 private int[] palette = {...};
 private int[] pixels = {...}; // To large, exceeding 65536 bytes.
 
 public MyPanel() {
  ...
 }

The error is shown at line "public MyPanel() {". Is this way to solve the problem impossible? Maybe there is another way to have "embedded" images? Kind Regards
OrangyTang
OrangyTang
Quote:
Original post by CodeMachine
Is embedded resources supported in Java?
The thing is that I want my images/sounds to be embedded in the exe-file.
(I dont want them to be individual files in my .jar-file)

As far as Java is concerned, adding them as files is equivilent to embedding resources in an exe. Why don't you want to do this?

IMHO the closest you can reasonably get is to serialise your resources into a file and include that in your jar.
CodeMachine
CodeMachine
Quote:
Original post by OrangyTang
Quote:
Original post by CodeMachine
Is embedded resources supported in Java?
The thing is that I want my images/sounds to be embedded in the exe-file.
(I dont want them to be individual files in my .jar-file)

As far as Java is concerned, adding them as files is equivilent to embedding resources in an exe. Why don't you want to do this?


Hi OrangyTang
I dont want the user to be able to edit my images/sounds.

Another way to control this is to calculate a checksum for each image/sound, and having them as separate files in my .jar.

But back to my question...
Is there a way to store more than 65535 bytes?
Or is it impossible?

Kind Regards

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.