Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
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  
  How to load and draw an image on an image  (Read 1119 times)
0 Members and 1 Guest are viewing this topic.
Offline gcsaba2

Junior Devvie

Hello world

« Posted 2005-04-24 15:43:59 »


I really don't know what else do I have to do to make a simple image to be drawn on the offscreen. I have two images in the same directory where the application is. I tried both GIF and BMP and neither seem to have worked. I know the image is loaded cause I tried getImage().getWidth(null) and it was 32, which is the width of the image.
When I try to draw with fillRect() it works ok, it draws rectangles. But when I try drawImage() I get a blank screen.

ImageIcon Tile[] = new ImageIcon[2];

Tile[0] = new ImageIcon(new URL("file:///C:/java/eclipse/workspace/DrawTest/tile1.gif"));

// ...

ptr = Tile[0].getImage();

// this works                //Offscreen.getGraphics().fillRect(x*Crtac.SQUARE_WIDTH,y*Crtac.SQUARE_HEIGHT,30,30);

// this does not work!
Offscreen.getGraphics().drawImage(ptr, x*Crtac.SQUARE_WIDTH,
                 y*Crtac.SQUARE_HEIGHT, null);
Offline Mr_Light

Senior Devvie

Medals: 1


« Reply #1 - Posted 2005-04-24 21:42:33 »

euh from memory: ImageIcon has a build in mediaTracker or equivalent meganism.

//ok I peeked(It actualy does use MediaTracker):
wait till it's fully finished check using:


read around there why you need the media tracker and I think it should be inline with your problem.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Pages: [1]
  ignore  |  Print  

EgonOlsen (37 views)
2018-06-10 19:43:48

EgonOlsen (20 views)
2018-06-10 19:43:44

EgonOlsen (39 views)
2018-06-10 19:43:20

DesertCoockie (186 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (861 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (139 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!