keeping transparency copying an modified image

i need to do some modifications for a image file. so i load it, make my mods and save it to another file.

so i loaded my (transparent) png


dstImage = new BufferedImage(width, height, srcImage.getType());

did some voodoo and saved it back


ImageIO.write(dstImage, "png", new File(filename));

my problem is that all transparent pixels turn to black. if i use BufferedImage.TYPE_INT_ARGB, the transparency gets converted properly.
but the source image can be any type of bit depth…
wheres the mistake ?

If you want to keep the alpha information you need to set the AlphaComposite like this:

g.setComposite(AlphaComposite.Src);
then:
g.drawImage(img,0,0,null);

hmmm, seems that im doing something wrong.
if i try this code snippet for only creating a bufferedimage with the source-type and transparency (no painting at all) the background still gets painted black…


ImageFramesOptimizer ifo = new ImageFramesOptimizer();
            
ifo.loadImage(IMAGE_SRC);
ifo.dstImage   = new BufferedImage(300, 300, ifo.srcImage.getType());
Graphics2D g = (Graphics2D)ifo.dstImage.getGraphics();
g.setComposite(AlphaComposite.Src);
ifo.writeImage(IMAGE_DEST);

same happens when i draw the source on it. shouldnt a completely transparent image get created ?

im sad, no further suggestions ?! :’(