drawOpaqueImage(Image, int, int, ImageObserver, double alpha) needed!!!

I got image1, and image2 and I want to blend them with each other. I could do that with MemoryImageSources if only image1 and image2 were MemoryImageSources, but they are standard images getted from getImage method, or PixelGrabber what ever their type is...
[273 byte] By [mikaelkuisma] at [2007-9-26 2:39:43]
# 1
What you might want to do is draw one of them to a BufferedImage and then write a .5 in the alpha channel in every pixel. you could then draw both of them anywhere you want, make sure to draw the BufferedImage on top.
glicious at 2007-6-29 10:12:42 > top of Java-index,Security,Cryptography...
# 2

What's wrong with this?

<CODE>

public void drawBlendImage(Graphics g, Image img1, Image img2, float opacity)

{

BufferedImage buf=new BufferedImage(320,200, BufferedImage.TYPE_4BYTE_ABGR);

Graphics bufg=buf.createGraphics();

bufg.drawImage(image1, 0, 0, null);

Raster alpha=buf.getAlphaRaster();

for (int i=0;i<320;i++)

for (int j=0;j<200;j++)

{

alpha.setSample(i,j,0, opacity);

}

g.drawImage(img2,0,0, null);

g.drawImage(buf, 0, 0, null);

}

</CODE>

mikaelkuisma at 2007-6-29 10:12:42 > top of Java-index,Security,Cryptography...
# 3

What's wrong with this?

[<CODE>]

public void drawBlendImage(Graphics g, Image img1, Image img2, float opacity)

{

BufferedImage buf=new BufferedImage(320,200, BufferedImage.TYPE_4BYTE_ABGR);

Graphics bufg=buf.createGraphics();

bufg.drawImage(image1, 0, 0, null);

Raster alpha=buf.getAlphaRaster();

for (int i=0;i<320;i++)

for (int j=0;j<200;j++)

{

alpha.setSample(i,j,0, opacity);

}

g.drawImage(img2,0,0, null);

g.drawImage(buf, 0, 0, null);

}

[</CODE>]

mikaelkuisma at 2007-6-29 10:12:42 > top of Java-index,Security,Cryptography...
# 4
I got that working now, since i was using opacity value 0.5 as said, but it should have been 128.0 . It's terribly slow... can this done more faster say optimising setSample method, since it seems that it calls at least three methods every time a pixel is set?
mikaelkuisma at 2007-6-29 10:12:42 > top of Java-index,Security,Cryptography...