Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  Very strange drawImage(xyxyxyxy) behaviour  (Read 3491 times)
0 Members and 1 Guest are viewing this topic.
Offline ahristov

Senior Member


Projects: 7


Java games rock!


« Posted 2007-02-22 00:46:16 »

Hi... I'm getting some very strange behaviour (=completely broken) for a drawImage call. I've managed to scale the thing down to this file. Could someone test the following class and tell me if it works properly?

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  
public class Bug extends Frame {
   
  public static void main(String[] x) {
    new Bug();
  }
 
  public Bug() {
    setBounds(0,0,1024,768);
    setVisible(true);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        }
        );
  }
   
  public void paint(Graphics gg) {
    BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.OPAQUE);
    Graphics2D gImg = img.createGraphics();
    gImg.setColor(Color.red);
    gImg.fillOval(4,4,24,24);
    gImg.setColor(new Color(0x0));
    gImg.drawOval(4,4,24,24);
   
    gg.drawImage(img,200,200,200+15,200+15,0,0,31,31,null);
    }
}


I get garbage on Windows (and a huge amount of it) with these combinations:
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.OPAQUE);
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.BITMASK);
BufferedImage img = new BufferedImage(32,32,BufferedImage.TYPE_INT_RGB);

I get a proper result with :
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.TRANSLUCENT);
BufferedImage img = new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB);

In Linux both things seem to work (same hardware)

Thanks in advance!

Planetalia S.L. Cursos de Java
Offline moogie

JGO Knight


Medals: 12
Projects: 6
Exp: 10 years


Java games rock!


« Reply #1 - Posted 2007-02-22 01:44:02 »

I see garbage as well.

winxp

java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #2 - Posted 2007-02-22 02:08:34 »

1  
gg.drawImage(img,200,200,200+15,200+15,0,0,31,31,null);


The "null" could pose problems!? Try to use "this" instead - see if the problem is still there...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ahristov

Senior Member


Projects: 7


Java games rock!


« Reply #3 - Posted 2007-02-22 21:04:56 »

1  
gg.drawImage(img,200,200,200+15,200+15,0,0,31,31,null);


The "null" could pose problems!? Try to use "this" instead - see if the problem is still there...

The null is who gets notified of image progress, it should be  (and in this case is) irrelevant.
Seems a problem with the BitBlt software routines. I'll test if this happens with Java 6 and file a bug if it does.

Planetalia S.L. Cursos de Java
Offline Kova

Senior Member





« Reply #4 - Posted 2007-02-23 10:15:07 »

I have Java 6 and also get garbage. I guess you can file a bug.
Offline ahristov

Senior Member


Projects: 7


Java games rock!


« Reply #5 - Posted 2007-02-23 18:33:00 »

I have Java 6 and also get garbage. I guess you can file a bug.


Thanks! I'll do it...

Planetalia S.L. Cursos de Java
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #6 - Posted 2007-03-08 22:26:33 »

Hm. Works fine for me with jdk6.

What's your desktop depth?

Dmitri

Offline Kova

Senior Member





« Reply #7 - Posted 2007-03-09 00:09:52 »

mine is 32bit, 1024x768, ati x800...
used jre6 I think, just like described, when using original it doesn't work, using .TRANSLUCENT it works (no garbage around circle as I remember)
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #8 - Posted 2007-03-09 01:08:51 »

Works fine for me.  I see a small black square with a red circle in it.

Windows XP Pro

java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)

It could be a driver issue.  Make sure your video card drivers are up to date.

Offline Kova

Senior Member





« Reply #9 - Posted 2007-03-09 08:22:15 »

Works fine for me.  I see a small black square with a red circle in it.

the black square is garbage... you didn't try workaround. Instead of OPAQUE put TRANSLUCENT and you'll see that image changes, the black square disappears and only red circle is visible.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #10 - Posted 2007-03-09 14:10:50 »

the black square is garbage... you didn't try workaround. Instead of OPAQUE put TRANSLUCENT and you'll see that image changes, the black square disappears and only red circle is visible.

I don't consider the black square garbage.  If you make a BufferedImage opaque, then some colour has to be drawn for every pixel that it covers.  Since BufferedImages store their information in an array of primitives(byte, int, etc) then they are defaulted to 0 unless you overwrite them.  Since 0 red, 0 green and 0 blue is black, that is what is drawn.  Every type that ahristov presented gave me results that I would expect.

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2007-03-09 14:12:27 »

By garbage he means it has funny colors

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline SimonH
« Reply #12 - Posted 2007-03-09 14:35:43 »

No problems with jre 1.5.0_07...

People make games and games make people
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #13 - Posted 2007-03-09 15:20:10 »

By garbage he means it has funny colors
Kova said the black square is the garbage.  In my earlier post I said that it looked fine for me with no funny colours.

I also tried it on a Windows NT machine with:
java version "1.5.0_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03)
Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing)

It works fine for me there as well.  So that is why I am thinking it is a driver issue.

Offline Kova

Senior Member





« Reply #14 - Posted 2007-03-09 22:27:51 »

sorry, I put it very bad, as I remember it had some funny colors around circle, not black square itself
Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #15 - Posted 2007-03-10 01:33:37 »

sorry, I put it very bad, as I remember it had some funny colors around circle, not black square itself
No problem.  I wasn't sure if I understood the question.  Now it seems clear.

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.

BurntPizza (21 views)
2014-09-19 17:14:18

Dwinin (35 views)
2014-09-12 23:08:26

Norakomi (62 views)
2014-09-11 03:57:51

TehJavaDev (87 views)
2014-09-10 20:39:09

Tekkerue (42 views)
2014-09-09 16:24:56

mitcheeb (65 views)
2014-09-08 20:06:29

BurntPizza (47 views)
2014-09-07 15:13:42

Longarmx (35 views)
2014-09-07 15:12:14

Longarmx (40 views)
2014-09-07 15:11:22

Longarmx (36 views)
2014-09-07 15:10:19
List of Learning Resources
by Longor1996
2014-08-17 00:40:00

List of Learning Resources
by SilverTiger
2014-08-06 09:33:27

Resources for WIP games
by CogWheelz
2014-08-02 06:20:17

Resources for WIP games
by CogWheelz
2014-08-02 06:19:50

List of Learning Resources
by SilverTiger
2014-08-01 06:29:50

List of Learning Resources
by SilverTiger
2014-08-01 06:26:06

List of Learning Resources
by SilverTiger
2014-08-01 01:54:12

HotSpot Options
by dleskov
2014-07-08 15: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!