我有以下方法:
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;
}
它需要一个Image并尝试使用Graphics对象生成BufferedImage。
我可以用这个Graphics(或BufferedImage)来实际让我使用它吗?我正在使用GIF文件。
使用字节数组传输图像数据会更容易吗?
干杯, 亚历
答案 0 :(得分:1)
您可以使用方法OutputStream
获取ImageIO.write(...)
个对象。现在您可以通过网络传输它或保存到文件或存储到数组或其他内容。
答案 1 :(得分:0)
您可以使用Graphics.drawImage在新图像中绘制原始图像。实际上,您可以使用Graphics
提供的任何操作,并将其强制转换为Graphics2D
(因为它就是这样)并使用这些操作。