
Signature
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
>> I'm doing some image manipulation in an applet using
>> the example code on this page:
[quoted text clipped - 5 lines]
>
> Toolkit.getImage()
When I try to use
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.getImage("myimage.jpg");
w = img.getWidth(null);
h = img.getHeight(null);
Then the width and height is returned as being 0. Is this caused by the
getWidth and getHeight methods needing an ImageObserver as parameter? I
haven't grasped the concept of ImageObservers. When I used an applet I
could pass that one as the argument, but in the application I don't know
how it all fits together.
I should mention that I don't need to show the image (for now). I just
want to load an image into an Image object and later extract the pixels
of the Image object into an array of integers. Swing is related to user
interfaces (as far as I know), but since I don't really even want a user
interface for now, I don't see why I need to look into the Swing package
in order to load image data. This is why I'm confused.
> There are varous differences between applets
> and applications, but rather than figuring out
> how to convert this applet to an application,
> you really need to understand how to write
> applications. Then it will become easy.
I have written many applications, including ones with Swing interfaces,
but handling images in applications happen still to confuse me.
Is there not any complete example (with code) on the net of an
application that loads an image from disc and into an Image object? I
know it's very simple, but I just haven't managed to get it to work.
Rune
--
http://runevision.com
Andrew Thompson - 16 Mar 2004 17:40 GMT
>>> http://www.akop.org/art/pixels3.htm
>>>
[quoted text clipped - 13 lines]
> Then the width and height is returned as being 0. Is this caused by the
> getWidth and getHeight methods needing an ImageObserver as parameter?
That is what the MediaTracker does.
> ...since I don't really even want a user
> interface for now,
Good choice.
>..I don't see why I need to look into the Swing package
> in order to load image data. This is why I'm confused.
My bad, I read 'application' as 'GUId application'
> Is there not any complete example (with code) on the net of an
> application that loads an image from disc and into an Image object? I
> know it's very simple, but I just haven't managed to get it to work.
Have a hunt around Marco Schmidt's site,
you will find various image related
(command line based) stuff..
<http://www.geocities.com/marcoschmidt.geo/java.html>
HTH

Signature
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology
Rune Johansen - 16 Mar 2004 18:08 GMT
> Have a hunt around Marco Schmidt's site,
> you will find various image related
> (command line based) stuff..
> <http://www.geocities.com/marcoschmidt.geo/java.html>
Thanks a lot, this looks very nice.
Rune
--
http://runevision.com
Rune Johansen - 16 Mar 2004 22:31 GMT
Hmm, so it turns out that part of my confusion is caused by NetBeans,
the IDE I'm using. I have an application now that loads an image fine if
I run it from the command prompt, but if I run it from within NetBeans
IDE, the image is not found. I don't have any idea why, yet. :(
Rune
--
http://runevision.com
Andrew Thompson - 17 Mar 2004 06:19 GMT
> Hmm, so it turns out that part of my confusion is caused by NetBeans,
> the IDE I'm using.
??
>..I have an application now that loads an image fine if
> I run it from the command prompt, but if I run it from within NetBeans
> IDE, the image is not found. I don't have any idea why, yet. :(
If you have got it running fine from the command line,
it does sound like a NetBeans problem, but I have never
used and am unqualified to comment further.
[ To put that another way, someone who regularly does
things from the command line or a simple editor is
unqualied to sort out problems with your IDE! ]

Signature
Andrew Thompson
* http://www.PhySci.org/ Open-source software suite
* http://www.PhySci.org/codes/ Web & IT Help
* http://www.1point1C.org/ Science & Technology