Home pageFind It!Contact PJAPJA documentation

PJA

 PJA Toolkit forum

This forum is dedicated to PJA Toolkit.
You may read freely the messages it contents. If you want to write a message or answer to a subject, subscribe to it first.

Subjects Recent messages Login Subscribe

Messages of subject createImage(byte[]) does not work

Stefan

Member since : Jun 5, 2003
Messages : 2
 Jun 5, 2003 at 11:15 AM
Hello,

I wrote a servlet, that dynamically generates images for a web-application.

[...]
Frame f = new Frame();
f.addNotify();
Toolkit tk = f.getToolkit();
Image img =
tk.createImage(myGifData ,0,myGifData.length);
[...]
myGifData is a byte[] with the graphic-data

No proplem with this code on windows-system. But with AIX there is the headless-Problem. So I tried to use PJA, but it will not work: img is always null.

When I use the demo-code (GraphicsArcDrawer) to generate an Image, the servlet generates the gif-image correctly.

What am I doing wrong?

Stefan

PS: I got the code with PJA on windows to work, but not on AIX 4.3

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 9, 2003 at 10:04 AM
Did you try with another GIF image ?
---
Manu (moderator/modérateur)

Stefan

Member since : Jun 5, 2003
Messages : 2
 Jun 10, 2003 at 9:59 AM
Hello,

this code works:
URL url = getClass().getResource("/uebersichtskarte.gif");
Image img = null;
if (url != null)
{
img = Toolkit.getDefaultToolkit().createImage(url);
}

Exception in this code in GifDecoder:
InputStream tInstream = getClass().getResourceAsStream("/uebersichtskarte.gif");
byte tb[] = new byte[tInstream.available()];
tInstream.read(tb);
Image img = Toolkit.getDefaultToolkit().createImage(tb);

java.lang.ArrayIndexOutOfBoundsException
at com.eteks.awt.image.GIFDecoder.readCode(GIFDecoder.java:740)
at com.eteks.awt.image.GIFDecoder.readImage(GIFDecoder.java:686)
at com.eteks.awt.image.GIFDecoder.loadGIF(GIFDecoder.java:461)
at com.eteks.awt.image.GIFDecoder.addConsumer(GIFDecoder.java:161)
at com.eteks.awt.image.GIFDecoder.startProduction(GIFDecoder.java:144)
at com.eteks.awt.PJAImage$1.run(PJAImage.java:347)

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 10, 2003 at 11:04 AM
> InputStream tInstream = getClass().getResourceAsStream("/uebersichtskarte.gif");
> byte tb[] = new byte[tInstream.available()];
> tInstream.read(tb);
> Image img = Toolkit.getDefaultToolkit().createImage(tb);

How can you be sure that tInstream.available () will return the size of your file ?
available method specifications says "Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream."
Does tInstream.available () returns the size of your image ?

---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2014 eTeks - All rights reserved

PJAPJA documentation