Click to See Complete Forum and Search --> : Reading Images in a Canvas-derived Class


skippy
May 5th, 2000, 06:16 AM
Hi !
I have coded an applet which uses a derived-from-Canvas class to
do some graphics. Now I want to load an iamge from disk, but

getImage(getCodeBase(),"mypix.jpg");



doesn't work cause there is no codebase. How can I implement
that ?

cya
Skippy

kib63613
May 6th, 2000, 06:01 AM
getImage is the method of the class Applet. Hence, you can not call this method in the subclass of
Canvas. You should get this image by the method getImage() which is called in the init() method of
the applet. And put the image object that you get via the getImage() method to the subclass of Canvas
for painting. You may set the image to the subclass of Canvas and draw this image in the method
paint() which override the same method in the Canvas.
good luck,
Alfred Wu

skippy
May 6th, 2000, 06:28 AM
Hi ,
and thanks for the answer. This was the only possibility I had in mind, too. Hence the applet
is not my part in this project, I have to set up a function in my subclass, i.e

void setMyImage(Image myImg){blah}



to get the Image into my subclass, right?
Ok, even better than hardcoding all the Images
pixel by pixel...

cu
Skippy