Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / setSourceProgressivePasses on: 2005-01-25 14:09:44
Hi!

I'm using the following code to create thumbnails from images. The two ImageReadParam specified are parameters to improve the reading performance of the source images. I'd like to know how can I tweak these parameters quite a bit to get more performance, because I'm not an expert in 2D subjects.

1  
2  
3  
4  
5  
...
param.setSourceProgressivePasses(0, 4);
param.setSourceSubsampling(128, 128, 0, 0);
BufferedImage image = reader.read(0, param);
...




Thanks in advance
2  Java Game APIs & Engines / Java 2D / Re: Slow fade effect on: 2005-01-02 18:23:22
Quote
Bummer!!  What OS are you on.  Does the game say it sent me an error message?  I'd like to find out what's wrong with that so I'll check the logs just in case.


Sorry, it was my fault Tongue. It works nicely, a bit slow in my computer, though.

I copied your render() code and I get that annoying ghosting effect still. I don't know what I'm doing wrong.  :-/
How do you call the render() op ?

3  Java Game APIs & Engines / Java 2D / Re: Slow fade effect on: 2005-01-02 05:36:06
Quote
does Rimscape do the effect you're looking for?  Try changing from one menu to another and see it.



I've tried playing your game without success. BTW, do you mean this thread ?

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1103525254

Could I see the new code for your ScreenFader class ?


Thanks
4  Java Game APIs & Engines / Java 2D / Re: Slow fade effect on: 2005-01-01 16:42:43
Quote
haha whoops Wink  Yes it's not re-created EVERY frame, but it's existance can still be done without.  Sorry for the misreadings... new years, you know Wink  Yeah, the advice still holds though.  You don't need that buffer at all.


I've already tried to draw directly unto the panel's graphic context resulting in an annoying ghosting effect between the two images which doesn't appear if I use that intermediate buffer to draw the composite.

BTW, I know it's the buffer slowing the effect to a crawl, thanks for reminding me of this. I have other effects (scrolling and sliding) where I draw directly unto the panel's graphic context (no intermediate buffer) and they are pretty fast.

I'd like to know how to make the same effect without using this buffer.
5  Java Game APIs & Engines / Java 2D / Re: Slow fade effect on: 2005-01-01 11:05:09
Before you ask me, I've already tried to use the BufferStrategy class instead of my intermediate buffer with fairly similar results. I cannot use FSEM, therefore I'm unable to use the page flipping, and I have to resort to blit the contents from the buffer unto the panel's graphic context. Is there any way to speed up blit operations in java ?
6  Java Game APIs & Engines / Java 2D / Slow fade effect on: 2004-12-31 18:03:32
Hi!

I'm using the following code to do a fade transition effect between two images:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
      public void render(Graphics g, Image imageFrom, Image imageTo, int width, int height) {
 
            BufferedImage buffer=gc.createCompatibleImage(width,height);
 
            Graphics2D g2 = (Graphics2D)buffer.getGraphics();  
                               
            int counter=0;
            while (counter<90) {
                  counter=counter+2;
                  double alphaScalar = Math.sin(Math.toRadians(counter));
 
                  g2.setComposite(AlphaComposite.SrcOver);
                  g2.drawImage(imageFrom, 0, 0, null);  
                  g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)alphaScalar));
                  g2.drawImage(imageTo, 0, 0, null);
                  g.drawImage(buffer, 0, 0, null);
                  try {
                        Thread.sleep(5);  
                  }
                  catch(InterruptedException ex){}
            }                                                                    
           
            g.dispose();
            g2.dispose();
            buffer.flush();
      }
 


My main problem is that using a buffer to save the image composite before drawing it over the panel's Graphic context slows the effect considerably. I have other effects (scrolling, sliding and some more) which don't require the use of an intermediate buffer and they are way faster without it. I'm looking for a way to improve the perfomance of my fade effect. I've tried to draw the image composite over the panel's Graphic context directly (no buffer) but the screen flickers. Can anyone help me, please ?

Regards
7  Java Game APIs & Engines / Java 2D / Fade in/out effect too slow on: 2004-10-19 09:13:00
Hi!

 I'm trying to do a fade in/out effect between two images using the following code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
public void render(Graphics g, Image imageFrom, Image imageTo, int width, int height) {

      Image buffer=gc.createCompatibleVolatileImage(width,height);

      Graphics2D g2 = (Graphics2D)buffer.getGraphics();  
                               
      int counter=0;
      while (counter<90) {
            counter=counter+2;
            double alphaScalar = Math.sin(Math.toRadians(counter));
                  g2.setComposite(AlphaComposite.SrcOver);
            g2.drawImage(imageFrom, 0, 0, null);  
                  g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)alphaScalar));
            g2.drawImage(imageTo, 0, 0, null);
            g.drawImage(buffer, 0, 0, null);
            try {
                  Thread.sleep(1);  
            }
            catch(InterruptedException ex){}
      }                                                                    
           
      g.dispose();
      g2.dispose();
      buffer.flush();
}


The problem is that it's too slow and jerky. I need a smoother transition.

Before you ask me, I've put a "Thread.sleep(1)" line to allow another thread playing a background music to breath.


Thanks in advance
8  Java Game APIs & Engines / Java 2D / Re: copy the contents of an image on: 2004-10-19 09:08:02
Thanks, it works.  Grin
9  Java Game APIs & Engines / Java 2D / copy the contents of an image on: 2004-10-17 13:43:20
Hi!

I need to copy the contents of an image (bufferedimage or volatileimage) unto another for backup purposes. Is it enough to do a simple variable assignation like this ?


Image im1;
Image im2;
...
im1=im2;



thanks in advance
10  Java Game APIs & Engines / Java 2D / Re: Scroll transition between two images on: 2004-10-12 13:28:48
Thank you very much. I'm glad there are people out there helping newbies like me.  Cheesy
11  Java Game APIs & Engines / Java 2D / Re: Scroll transition between two images on: 2004-10-12 05:41:48
I'm not using a BufferStrategy. If I don't use an intermediate buffer won't the screen flicker ?
12  Java Game APIs & Engines / Java 2D / Scroll transition between two images on: 2004-10-11 16:31:26
Hi!

I'm using the following code to render a left to right scroll transition between two images over a JPanel:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
public void render(JPanel panel, Image imageFrom, Image imageTo) {

    Image buffer = gc.createCompatibleVolatileImage(panel.getWidth(), panel.getHeight());

    Graphics g = buffer.getGraphics();
    Graphics g2 = panel.getGraphics();  
                               
    for (int x=0; x<=panel.getWidth(); x+=10) {
      g.drawImage(imageFrom, x, 0, panel);  
      g.drawImage(imageTo, x-panel.getWidth(), 0, panel);
      g2.drawImage(buffer, 0, 0, panel);  
      try {
            Thread.sleep(20);  
      }
        catch(InterruptedException ex){}
    }      

    g.dispose();
    g2.dispose();
    buffer.flush();
                                                                           
}



As you can see I render out of the bounds of the screen many times during the transition. I suppose I can improve the performance not drawing the offscreen parts. How can I do it ? Is easy ? Can anyone help me, please ?

Thanks in advance
13  Java Game APIs & Engines / Java 2D / Re: Drawing images over a JPanel on: 2004-10-09 05:24:54
Yes, I'm doing animation. I'm developing a slideshow app using a panel to show the photos and do transitions (fade, scrolling, etc...) between them. I don't know if the paintComponent method you are suggesting is valid in this case.
14  Java Game APIs & Engines / Java 2D / Re: Drawing images over a JPaneso on: 2004-10-08 15:08:23
Another question, I'm a beginner in Java2D and active rendering so I don't know much them. I use the loop I shown you before to render an image on screen during some seconds. Why did I call drawImage inside a loop and didn't I call drawImage once and then call to sleep ? Because when I switch apps with alt+tab and return I loose the image on screen. Is there a better way to do this, I mean, only render the image when I loose the contents on screen ? This loop is eating all my CPU.
15  Java Game APIs & Engines / Java 2D / Drawing images over a JPanel on: 2004-10-07 05:03:54
I'm using active rendering over a JPanel implementing Runnable and I have some doubts I want share with you. Which of the following codes is better (performace, etc...):


1st one:
-----------


1  
2  
3  
4  
5  
6  
7  
    BufferedImage im=loadImage(file);
    Graphics2D g = (Graphics2D) getGraphics();  

    while (threadSuspended) {
      g.drawImage(im, 0, 0, this);  
    }
   g.dispose();




2nd one:
------------


1  
2  
3  
4  
5  
6  
7  
    BufferedImage im=loadImage(file);

    while (threadSuspended) {
        Graphics2D g = (Graphics2D) getGraphics();  
      g.drawImage(im, 0, 0, this);  
        g.dispose();
    }




Do I have to flush the BufferedImage too ? when ?



Thanks in advance
16  Java Game APIs & Engines / Java 2D / Threading issues on: 2004-09-28 17:32:48
I don't know if this is the right forum to ask this. Please move it if you find it doesn't fit here.

I'm developing a slideshow app. I'm using Java2D and the javalayer lib to play MP3 files as background music for the slideshows. I'm drawing the images using active rendering on a JPanel implementing Runnable and the music plays in its own thread too. I had to lower the priority of the drawing thread because the music one wouldn't start until the end of the slideshow, and I want the music to play during the slideshow. I have a problem though, every time there is a transition between the slides, the music stops for a second or something and then it continues. I'm a bit lost about this issue, so any guiding in the right direction would be appreciated.


Thanks
17  Java Game APIs & Engines / Java 2D / Dissolve effect on: 2004-07-27 05:31:01
Hi!

I'd like to know how to do a dissolve effect between two images. Something like this:

http://www.dseffects.com/applets/DS_Dissolve/DS_Dissolve.html

Any help (code,etc...) would be appreciated.


Regards
18  Java Game APIs & Engines / Java 2D / Re: Active rendering on: 2004-06-10 19:15:50
Thanks for the article, it helped me understand this whole thing better.

Quote
Is there a particular reason you were using a VolatileImage instead of a BufferStrategy for your backbuffer?


Can BufferStrategy be used outside FSEM ?
19  Java Game APIs & Engines / Java 2D / Active rendering on: 2004-06-10 08:22:59
I'm using active rendering in my pseudo fullscreen mode app (no FSEM) using a VolatileImage as a buffer, but I don't know how to recover the screen after switching apps or when I click the mouse to open a popup I registered in the frame of my app. Any help, please ?
20  Java Game APIs & Engines / Java 2D / Image transition effects on: 2004-05-22 14:38:38
Hi!

I'd like to know if there is a ready made library with source code for image transitions, like fades, dissolves, scrollings, and so on. If there is none, where can I find information about this, please ?


regards
21  Java Game APIs & Engines / Java 2D / Re: How to fade between two images ? on: 2004-05-02 20:18:45

I found a full piece of code at Sun site that does exactly what I was trying to do LOL

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
  import java.awt.*;
  import java.awt.image.*;
  import javax.swing.*;
  import java.util.Timer;
  import java.util.TimerTask;
 
  public class Converge extends JFrame {
 
    ImageIcon saloonIcon =
      new ImageIcon("saloon.gif");
    ImageIcon coachIcon =
      new ImageIcon("oldstage.gif");
    Image saloon = saloonIcon.getImage();
    Image coach = coachIcon.getImage();
 
    BufferedImage dest;
 
    float sourcePercentage = 1,
      destinationPercentage = 0;
    private static int STEPS = 100;
    private static float STEP_CHANGE =
      1.0f/STEPS;
    private static int SLEEP_DELAY = 100;
 
    Insets insets;
 
    public Converge() {
      super("Image Blending");
      setDefaultCloseOperation(
        JFrame.EXIT_ON_CLOSE);
      dest = new BufferedImage(200, 200,
        BufferedImage.TYPE_INT_ARGB);
      setSize(200, 200);
      TimerTask task = new TimerTask() {
        public void run() {
          repaint();
          sourcePercentage -= STEP_CHANGE;
          destinationPercentage +=
            STEP_CHANGE;
          if (sourcePercentage < 0) {
            sourcePercentage = 0;
            destinationPercentage = 1;
            cancel();
          }
        }
      };
      Timer timer = new Timer();
      timer.schedule(task, 0, SLEEP_DELAY);
    }
 
    public void paint(Graphics g) {
      if (insets == null) {
        insets = getInsets();
      }
      g.translate(insets.left, insets.top);
      Graphics2D g2d = (Graphics2D)g;
      Graphics2D destG = dest.createGraphics();

      destG.setComposite(AlphaComposite.getInstance(
        AlphaComposite.SRC, sourcePercentage));
      destG.drawImage(coach, 0, 0, this);
      destG.setComposite(AlphaComposite.getInstance(
        AlphaComposite.XOR, destinationPercentage));
      destG.drawImage(saloon, 0, 0, this);
      g2d.drawImage(dest, 0, 0, this);
    }
   
    public static void main(String args[]) {
      new Converge().show();
    }
  }
22  Java Game APIs & Engines / Java 2D / Loading a rescaled version of a JPEG image on: 2004-05-02 17:17:48

I'm using the following code to load an scaled version of a big JPEG image. I'd like to know if there are better (faster) ways to do it. I'm developing a thumbnail explorer-type app and I'd like to create the thumbnails the fastest way possible.

Here is the code. As you can see, I'm not loading the full image and then rescaling it. I rescale it while loading. Also, I'd like to know if the result BufferedImage is hardware accelerated:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
private static BufferedImage readSubsampling(File file, int maxSize) throws IOException {
      Iterator readers = ImageIO.getImageReadersByFormatName("jpeg");
      ImageReader reader = (ImageReader)readers.next();
      ImageInputStream iis=null;
      iis = ImageIO.createImageInputStream(file);
      reader.setInput(iis, true, true);
      ImageReadParam param = reader.getDefaultReadParam();
      int size = Math.max(reader.getWidth(0), reader.getHeight(0));
      int subsampling = size/maxSize + (size%maxSize != 0 ? 1 : 0);
      param.setSourceProgressivePasses(0, 4);
      param.setSourceSubsampling(subsampling, subsampling, 0, 0);
      BufferedImage image = reader.read(0, param);
      reader.dispose();
                 
      return image;
}



Thanks in advance
23  Java Game APIs & Engines / Java 2D / Re: How to fade between two images ? on: 2004-05-02 15:13:35
Thank you for your answers, I will try them now
24  Java Game APIs & Engines / Java 2D / How to fade between two images ? on: 2004-05-02 14:33:11
Hi!

 I'd like to know how can I make a fade in/out transition between two BufferedImages in java ? Any tutorial out there ?


Thanks
25  Java Game APIs & Engines / Java 2D / Re: About fullscreen mode on: 2004-05-02 14:29:55
One more question, can I use BufferStrategy outside FSEM ?
26  Java Game APIs & Engines / Java 2D / About fullscreen mode on: 2004-05-01 19:51:01
Hi!

 I'm developing a slideshow java application but I'm new to the whole Java 2D world. I've read some things about the fullscreen mode only available for windows and I'd like my app to run in linux too, is that true ? which is the alternative option, then ? Can you point me in the right direction, please ?


thanks
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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!