Hi Sandhya,
just found your previous email and finally got what you wanted to do.
Try this (suppose that image1/2 are transparent gifs):
public void paint(Graphics g) {
int h = image1.getHeight(null);
int w = image1.getWidth(null);
BufferedImage bi =
new BufferedImage(h, w, BufferedImage.TYPE_INT_ARGB);
Graphics gi = bi.getGraphics();
gi.drawImage(image1, 0, 0, null);
gi.drawImage(image2, 4, 4, null);
g.drawImage(bi, 50, 50, null);
}
BTW, this line
> > Graphics2D g = (Graphics2D)gifImage.getGraphics();
in your snippet is not valid and should be throwing
java.lang.IllegalAccessError: getGraphics() only valid for images created with
createImage(w, h)
Thank you,
Dmitri
On Wed, Aug 09, 2000 at 04:14:0p -0700, Dmitri Trembovetski wrote:
> Hi Sandhya,
>
> On Wed, Aug 09, 2000 at 03:41:0p -0700, Sandhya Venkatesh wrote:
> > Hi,
> >
> >
> > I am rendering a transparent image "gifImage"
> > Graphics2D g = (Graphics2D)gifImage.getGraphics();
> > g.setComposite(AlphaComposite.SrcIn);
> > g.drawImage(gifImage,0,0,null);
> >
> > but it becomes opaque after this. What can I do to
> > keep the tranparency??
>
> What did you want to achieve?
>
> From the snippet you've provided it looks like you're rendering the
> image to itself. Is that what you really wanted?
>
> If all you want is to render image with transparency to screen (or
> BufferedImage), you just need to call drawImage on the
> destination Graphics object (you don't need to set composite
> rule). Something like
> public void paint(Graphics g) {
> g.drawImage(gifImage, 0, 0, null);
> }
>
> Thank you,
> Dmitri
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".