开发者

Using data in BufferedImage that is drawn by Graphics

I have the method below:

private Graphics getBufferedImage(Image image) {
    // Create empty BufferedImage, sized to Image
    buffImage  = 
      new BufferedImage(
          image.getWidth(null), 
          image.getHeight(null), 
          BufferedImage.TYPE_INT_ARGB);

    // Draw Image into BufferedImage
    Graphics wholeImage = buffImage.getGraphics();
    return wholeImage;
}

It takes an Image and tries to generate the Buf开发者_如何学CferedImage with a Graphics object.

What can I do with this Graphics (or BufferedImage) to actually let me use it? I'm using GIF files.

Would it be easier to use a byte array to transfer Image data over?

Cheers, Alex


You can get OutputStream object using method ImageIO.write(...). Now you can transfer it over the network or save to file or store to array or something else.


You can use Graphics.drawImage to draw the original image in the new image. In fact you can use any operation that Graphics offers, as well as cast it to Graphics2D (because that's what it is) and use those operations too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜