Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Converting to application  (Read 1410 times)
0 Members and 1 Guest are viewing this topic.
Offline alexxz4

Junior Member


Projects: 1



« Posted 2008-01-25 15:11:05 »

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?


[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Offline fletchergames

Senior Member





« Reply #1 - Posted 2008-01-25 18:43:22 »

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.
Offline alexxz4

Junior Member


Projects: 1



« Reply #2 - Posted 2008-01-25 20:32:17 »

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
1  
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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
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;
   }

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline fletchergames

Senior Member





« Reply #3 - Posted 2008-01-26 15:34:16 »

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.
Offline alexxz4

Junior Member


Projects: 1



« Reply #4 - Posted 2008-01-26 16:04:09 »

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.  Huh

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #5 - Posted 2008-01-26 17:10:44 »

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.

弾幕 ☆ @mahonnaiseblog
Offline alexxz4

Junior Member


Projects: 1



« Reply #6 - Posted 2008-01-26 18:07:12 »

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)

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #7 - Posted 2008-01-26 20:19:36 »

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.

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.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #8 - Posted 2008-01-26 20:26:28 »

>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?

弾幕 ☆ @mahonnaiseblog
Offline alexxz4

Junior Member


Projects: 1



« Reply #9 - Posted 2008-01-28 21:37:55 »

Quote
If you save a color picker dialog will pop up where you can select the transparent color.
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.

[ Motherload Unlimited looking for programmers ] [ Solitaire ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (12 views)
2014-08-28 18:26:30

CopyableCougar4 (24 views)
2014-08-22 19:31:30

atombrot (37 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (29 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (28 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!