Article View: borland.public.jbuilder.java.api
Article #316Problems with loading & displaying a picture
From: Andreas Koch
Date: Sun, 01 Feb 2004 14:05
Date: Sun, 01 Feb 2004 14:05
51 lines
2512 bytes
2512 bytes
Hi,
i am doing my first steps in java by combining
snippets from the net.
Currently i have an expanded JB9 default application
with an extra frame that shows a clock (using
a BufferedImage re-painted several times a second).
Setting pixels in the BufferedImage works.
Writing text on the BufferedImage works too.
Now i loaded a small jpeg (from the local harddisk,
32x32 pixels) and want to draw it into the BufferedImage.
Unfortunately, drawImage allways returns false - the docs
state that this is the case if the picture isn't fully
loaded. But its on a local drive, and it keeps on return
false for minutes!
The (in my eyes) relevant code snippets:
class Clock extends JPanel {
...
private static Image white_marble;
...
public Clock() {
....
Toolkit toolkit = Toolkit.getDefaultToolkit();
white_marble = toolkit.getImage("0196.jpg");
}//end constructor
...
if (!gc.drawImage(white_marble,32,32,32,32,null))
gc.drawString("<loading>",32,32);
result is "<loading>" displayed instead of the image.
"0196.jpg" is in the source folder, and added to the
project. After getImage, white_marble contains an
image object, but width.int and height.int are -1.
Any hints what to do, or how to find out whats wrong?
Do i need to use an ImageObserver or Mediatracker, and
if yes, how ?
thanks a lot,
--
Andreas
He screamed: THIS IS SIG!
Technical Details
Message-ID:
<401d06eb$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,cc9d3c5ba1462852,start X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2004-02-01 06:10:43 PST Date: Sun, 01 Feb 2004 15:05:34 +0100 From: Andreas Koch <nospam@kochandreas.com> User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.api Subject: Problems with loading & displaying a picture Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 217.226.112.99 Message-ID: <401d06eb$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1075644139 217.226.112.99 (1 Feb 2004 06:02:19 -0800) Lines: 51 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail