Re: Fading effect
Andrew Thompson ha scritto:
lando wrote:
..
Thanks and sorry for my bad English....
Code is a lot more instructive than English*.
Can you post an SSCCE** of the code you are
currently having trouble with?
Also very helpful is an URL to the applet on the
internet, working or not.
* Thank you for taking the effort to write the
only language I understand.
** <http://www.physci.org/codes/sscce.html>
Thanks to see my post ,..but at this moment I am in a complete loop !
So as in loop is my web page !
I 've to reset and restart everything.
....then I cannot show you the complete documentation you need...
I can only say this code below give "access denied " also with files in
the same folder of .class file.
public class Fadera extends JApplet {
final BufferedImage[] images = new BufferedImage[4];
volatile BufferedImage first,next;
volatile AlphaComposite comp1 =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,1.0f);
volatile AlphaComposite comp2 =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.0f);
public void init() {
try {
for (int i=0; i<images.length; i++)
images[i] = ImageIO.read(
new File("men" + Integer.toString(i+1) + ".jpg"));
} catch (IOException ioe) {
ioe.printStackTrace();
}
The code below (very the same !...) works with images in same folder
public class Fadera extends JApplet {
final BufferedImage[] images = new BufferedImage[4];
volatile BufferedImage first,next;
volatile AlphaComposite comp1 =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,1.0f);
volatile AlphaComposite comp2 =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.0f);
String s[] = { "pic_1h.jpg", "pic_2h.jpg", "pic_3h.jpg", "pic_4h.jpg"};
for ( int i = 0; i < images.length; i++ ) {
File f = new File("/home/lando/Desktop/fade/" + s[i]);
try {
// Read in a BufferedImage from a file.
images[i] = ImageIO.read(f);
} catch (IOException e) {
System.err.println("Error reading file: " + f);
System.exit(1);
}
}
And the code below that in compilation gives
/home/lando/PgmJava/Fadera.java:85: incompatible types
found : java.awt.Image
required: java.awt.image.BufferedImage
images[0] = getImage(url1);
public class Fadera extends JApplet {
final BufferedImage[] images = new BufferedImage[4];
volatile BufferedImage first,next;
volatile AlphaComposite comp1 =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,1.0f);
volatile AlphaComposite comp2 =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.0f);
try {
URL url1 = new URL(getDocumentBase(), "men1.jpg");
BufferedImage [0] images = getImage(url1);
} catch (IOException ioe) {
ioe.printStackTrace();
}