Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] java.awt.Image


Jess,

I didn't see your attachment - perhaps the list is still having trouble with attachments.

Regarding your Bugzilla password, you might want to post to the newsgroup to get that taken care of.

Another way you can convert the AWT Image to an SWT one is as follows - this is a bit more convoluted, but uses some higher level constructs provided in Java 2 (note that I haven't tried the code yet - got the idea from one of my books :-):

BeanInfo bi = Introspector.getBeanInfo (JavaBean.class);
java.awt.Image awt = bi.getIcon (0);

awt = new ImageIcon(awt).getImage();
int width = awt.getWidth(null);
int height = awt.getHeight(null);
BufferedImage bufferedImage = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_RGB);
Graphics g = bufferedImage.createGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, width, height);
g.drawImage(awt, 0, 0, null);
g.dispose();
int[] pixels = new int[width*height];
bufferedImage.getRGB(0, 0, width, height, pixels, 0, width);
// rest of this can be taken from Silenio's example of creating
// an SWT image from a pixel array


HTH,
David
--
David Whiteman
OTI Raleigh
david_whiteman@xxxxxxx




"Jess Terr" <jst@xxxxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

11/27/2001 02:41 AM
Please respond to platform-swt-dev

       
        To:        platform-swt-dev@xxxxxxxxxxx
        cc:        
        Subject:        Re: [platform-swt-dev] java.awt.Image


Thanks for reply Silenio.
I have tried your suggestion, but my VM crashes. I tried to submit a bug to bugzilla, but I cannot login because of invalid password (the one I received contains space, maybe that is the problem - if somebody can fix it I'll be glad).

So here is my bug report, see attached ZIP for demonstation case and log file for error I received.

I am running Linux, sun's jdk1.3.1_01

Regards.
jst




Back to the top