🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14478

createImage(w,h) is null ?

#14478
From: Dan Woods
Date: Thu, 02 Sep 1999 00:00
31 lines
1784 bytes
This one is driving me nuts, please help.  I have written many applets
and have no problem with image manipulation by using an offscreen
image buffer.  I am now writing a JDK1.1.5 application (command line)
to read in an image and *create* a new image stored to disk.

My main class extends Panel(), calls another class expecting a
Component() (ie: 'this' panel) and a source image, and tries to
create a new image based on the source image.  My lines of code:
// ------------- 'comp' is the Component() passed in
/*
    Image composite = comp.createImage( new MemoryImageSource(
	  imgWidth, imgHeight, new int[imgWidth * imgHeight], 0, imgWidth) );
*/
/*
    Image composite = comp.getToolkit().createImage(
    			new byte[imgWidth * imgHeight]);
*/
    Image composite = comp.createImage(imgWidth, imgHeight);
    try { Thread.sleep(1000); } catch (Exception e) {}
// -------------

However, none of my attempts work.  In the last case, composite is
always 'null'.  In the first two, they work except that when I try
	Graphics offG = composite.getGraphics();
it complains that getGraphics() only works for an image created
using "createImage(int width, int height)"

The last case has always worked in applets, but not for this app.
Any ideas ?   Is this a bug ?

Thanks...Dan.
Technical Details
Message-ID: <37CF61B9.DE2B20A9@ucalgary.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,2ef73006d99f91a3,start
X-Google-Attributes: gidf74b3,public
From: Dan Woods <dwoods@ucalgary.ca>
Subject: createImage(w,h) is null ?
Date: 1999/09/02
Message-ID: <37CF61B9.DE2B20A9@ucalgary.ca>
X-Deja-AN: 520478949
Content-Transfer-Encoding: 7bit
Organization: University of Calgary
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language