createImage fail if image is 300 * 46800

I want to create an large image for a component in Applet. If 16bit color is used, it works. However, if 24bit color is used, it fails. The error is:

com/ms/awt/peer/INativeImage.create

at com/ms/awt/image/ImageRepresentation.offscreenInit

at com/ms/awt/image/Image.<init>

at com/ms/awt/ImageX.<init>

at com/ms/awt/WComponentPeer.createImage

at java/awt/Component.createImage

The problem is how to create image with less no of bits with the actual color is 24bit.

Please advise. Many thanks

[565 byte] By [KwanY] at [2007-9-26 6:40:30]
# 1

Offcorse it failes. Its too high. What is it you want to achive? It can probably be done without your infinitly huge image. Afterall, all you can show on screen is an image the size of the screen or smaller.

":-)

Ragnvald Barth

Software enigneer

http://blake.prohosting.com/ragnvald

Ragnvald at 2007-7-1 15:58:39 > top of Java-index,Desktop,Core GUI APIs...
# 2
I draw on the image a long list of strings. Also, I use scroll bar to scroll up & down so it may larger than the sreen size.It seems the use of lesser color will work but don't know how to config that.
KwanY at 2007-7-1 15:58:39 > top of Java-index,Desktop,Core GUI APIs...
# 3

Just to see what happens, try running the applet with Netscape Navigator and in the IE with the help of the Java plug-in. Also, what version of the MS JVM are you using?

Are you drawing the whole image to the component or just the visible portion? Is there any possibility of you sharing your code so that we could see what you are trying to do and how.

ajmas at 2007-7-1 15:58:39 > top of Java-index,Desktop,Core GUI APIs...
# 4

This is how I would solve the problem.

[code]

// assuming the wisible part of the image is no more than pix 800 high:

img = createImage(300* 800);

gr = img.getGraphics();

// then where you draw the strings onto your image:

scrollY = getScrollPosition().y;// update scrollY everytime scrolling is performed.

gr.drawString(str, x, y - scrollY);

// subtract the scrollposition from the y value.

// then where you paint the image to the component:

g.drawImage(img, 0, scrollY, this);

Hope this works ok for you!

Ragnvald at 2007-7-1 15:58:39 > top of Java-index,Desktop,Core GUI APIs...
# 5
correction:img = createImage(300, 800); Hope this works ok for you!
Ragnvald at 2007-7-1 15:58:39 > top of Java-index,Desktop,Core GUI APIs...