Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2004

Tip: Looking for answers? Try searching our database.

Image manipulation in applications

Thread view: 
Rune Johansen - 16 Mar 2004 15:27 GMT
Hi.

I'm doing some image manipulation in an applet using the example code on
this page:
http://www.akop.org/art/pixels3.htm

However, I really want to make an application rather than an applet, I
just can't figure out how to do the image loading and manipulation when
it's not from inside an applet. The examples I've found on the net all
seem to use applets... Any hints on the subject are appreciated.

Thanks in advance,

Rune
--
http://runevision.com
Andrew Thompson - 16 Mar 2004 16:18 GMT
> I'm doing some image manipulation in an applet using the example code on
> this page:
> http://www.akop.org/art/pixels3.htm
>
> However, I really want to make an application rather than an applet, I
> just can't figure out how to do the image loading

Toolkit.getImage()

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.

That may sound pithy, but what I am getting
at is that it is more than just changing lines
and replacing the methods that Applets have
access to.  That's why I will say, start here..
<http://java.sun.com/docs/books/tutorial/uiswing/index.html>

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 17:12 GMT
>> 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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.