Ok, ive been working a long time on an applet game and it has grown considerably (5MB, 100KB .class file) and is likely to grow bigger. So i heard that applications have some advantages over applets. Is it worth converting it to an application? Will i get a significant performance increase?
There should be an increase in performance, but I wouldn’t worry about that unless you’re having performance problems already. Are you using active rendering? That will probably increase performance even more, though it may work a bit better in applications. You can look up active rendering on this forum, and I believe it’s mentioned in Java’s tutorial for full-screen exclusive mode (though I’m not sure).
The books Developing Games in Java and Killer Game Programming in Java both describe active rendering.
Converting to an application shouldn’t require much work.
No i dont think i use active rendering. I just have the standard paint(Graphics g) function. But im following a tutorial that uses it in an aplication.
I started converting anyway and noticed that aplication cant display all transparent images correctly. In applets i use
img=getImage(getCodeBase(),"img.png");
transparent images are displayed correctly whether i did them in IfranView or my graphics person did them with his high-teck graphics software. But when i try drawing images in an application, the IfranView PNGs are displayed with background even though they have transparency; my graphics person’s images are displayed properly.
Here is my image loader function:
public Image getImage(String filename){
URL url = this.getClass().getClassLoader().getResource(filename);
BufferedImage source=null;
try{
source = ImageIO.read(url);
} catch(IOException e){}
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration();
Image image = gc.createCompatibleImage(source.getWidth(),source.getHeight(),
Transparency.TRANSLUCENT);
image.getGraphics().drawImage(source,0,0,null,this);
return image;
}
The image “source” probably has the transparency handled properly. When you draw it to the image “image”, the transparency isn’t included. It’s just like drawing to the screen. The transparent part isn’t drawn.
You need to use one of the setRGB methods of BufferedImage. That will probably fix your problem, though I’ve had some strange problems with the array-based setRGB methods for some reason. It may be that in those cases something else was wrong though because I only remember that happening while I was still changing around some code.
setRGB sets one pixel to some RGB value. Now i know there should be an easier way to coax out transparency from an image besides setting each pixel to some value. ???
Irfanview only handles bitmask transparency… and it only does that if you check that checkbox and select the color. If you don’t do that you get an opaque image.
Is there a software that can make transparent images that are displayed properly in aplications.
http://img81.imageshack.us/img81/9845/screenxd3.png
What boxes do i need to check? (Note: images saved with “Save Transparent Color” box checked appear with background frame in aplications)
You should use java.awt.Graphics2D.setComposite(AlphaComposite.Src) if you want to keep the alpha channel of the source image when performing an image copy.
What boxes do i need to check?
That save transparent color one. If you save a color picker dialog will pop up where you can select the transparent color.
Is there a software that can make transparent images that are displayed properly in aplications.
Photoshop, Gimp… whatever.
[…]appear with background frame in aplications
Huh?
[quote]If you save a color picker dialog will pop up where you can select the transparent color.
[/quote]
Yeah, it pops up, i pick the color and save. But when i display it in an application its show with a background frame as if i saved it in paint or something. Applets display those images just fine.