I know this is probably close to a duplicate of this thread: Animated GIF in Splashscreen
But since it seems unanswered and I can't comment on it or anything I'm sorry to repost this but it would be awesome if someone could give me an answer.
I am making a game and this game takes quite a lot of time to start. Therefore I want to give the user feedback during the loading screen so he knows the application hasn't crashed. That's why I use the SplashScreen API from java 7.
In eclipse, when I run my application using the following configuration in VM Arguments, SplashScreen.getSplashScreen() returns null.
-splash:src/aapplication/Splash.gif
But when I use this configuration, it works fine (I have to files in the same package, one is Splash.png and the other Splash.gif):
-splash:src/aapplication/Splash.png
In a jar file (in MANIFEST.MF), this doesn't work:
SplashScreen-Image: aapplication/Splash.gif
While this does:
SplashScreen-Image: aapplication/Splash.png
My GIF is about 1Mb in size while the PNG is 50kb.
Can anyone explain to me why does the GIF can't even be loaded while the PNG does (I know it's not the path since they have the same)?
Everywhere I looked, it said it should work just as fine as for PNGs.
Thanks for your help!
I think you'll find that the problem comes down to two things...
Using the command line parameter (-splash), Java expects the image to be a file on the file system, whereas the manifest file expects it to be an embedded resource.
Java doesn't seem capable of playing optimised gifs, that is gifs whose frames represent the difference between the last and current frame, instead of a complete image (as far as the splash screen goes).
I tried using
and
The first image failed, but the second worked, the difference, as near as I can tell, is the first is optimised and the second is not...
Related
My issue is that I need to use Java code and Python code, each generating a window, Java still being the main process.
What I need is to link those two windows together. When I resize one, it resize the other, and same behavior when moving one, minimizing,...
I tried looking at the documentation or other solution on the Internet but I found nothing near my issue.
Will I need to implement a whole solution for it (listeners on both window to get size and resize the other, or position,...) or is there something I have been missing ?
I am aware the question has been asked before. However, I have tried all the solutions and none seem to work. I have created a simple GUI program using javax.swing, and of course it works perfectly in IntelliJ. However, its consequent jar file has quite a few issues. First and foremost, none of the images even display. I have been importing them as so:
img = new ImageIcon((ImageIO.read(new File("image_name.png"))));
I found a solution suggesting I use:
BufferedImage img = ImageIO.read(new FileInputStream("res/name.png"));
However, not only does it not load in the jar, it takes 5 seconds for the program to even launch in the compiler.
This is getting extremely frustrating, making this an executable.
If it's of any use, the JButton components on the jar also don't seem to work. Whenever you click them, they remain pressed but nothing happens further.
I understand this isn't loads of info, but I would nontheless appreciate any help you can give. Thanks!
Earlier I asked a question on how I could manage to draw an image with my applet:
How am I supposed to draw an image from my Java Applet?
The update is that my Java Applet runs from the file system and I think that might be giving me the error I am getting.
I would truly appreciate it if one would take the time to view my question. If you don't want to read the other question a quick recap is that I am getting the "Access Denied" message whenever I try the g.drawImage function. A user brought up the fact that it is because I may be running my applet from the file system, how do I go about fixing this?
Try this one if the image in the "build" (also called bin) folder together with the classes.
I have posted an answer in your last question itself.
How am I supposed to draw an image from my Java Applet?.
What I am trying to accomplish is to select an area on the screen with the mouse (outside of the may frame) and get the resulting region coordinates using Sikuli.
The code that should do this looks is below:
Screen screen = Screen.getPrimaryScreen();
Region region = screen.selectRegion("Select the area.");
What happens is that the cursor turns into a selector cross (the ones you usually see when you expect this function), but I can't select the area and actually the only way I can get back from the application is by killing it. Not too many examples I have found so I am asking for help here.
How can I make this work?
Also one other question:
I have downloaded the following script version:
Sikuli-IDE-1.0.0-Win64.zip
This means if I want to create a crossplatform solution I have to include like 6 jars? I have found a more universal Java API it seems (that is what it is called actually):
https://code.google.com/p/sikuli-api/
With all required supported OS but I can't find a single example on what I am trying to do that is similar to the little code snippet I pasted here. The sikuli script I am using now and this Sikuli API (apparently not the same) seems to be just different enough to amke this difficult.
Any suggestions? Thanks a lot in advance.
As it turns out, this only happens if I put this functionality on a Swing button's actionhandler. I have reported the bug to Sikuli and it will be probably fixed in the next release.
So after doing a lot of digging around here, and elsewhere, there is no good, simple, CURRENT way to grab images from iSight in Java. So first of all I would love if someone could point me to a good way to do this, and OpenCV does not work for Java in case you were thinking of that.
Here's a workaround of sorts that I'm thinking about using, even though it is incredibly flawed:
Open up Photo Booth
Use java's Robot class to grab an image of the portion of the screen that holds the feed from the iSight.
If you just need to capture single pictures, you could use a command line program like imagesnap, run it with Runtime.exec, save the picture to a temp directory, then open the image file.