如何从java中的图像获取光栅?
我正在尝试将gif图像从url加载到java.util.image.graster中,以便对其进行操作。我能找到的加载和解压缩图像的唯一方法是Toolkit.getImage,它返回一个java.awt.image。我需要把它转换成光栅,这样我就可以使用它了。建议?将图像加载到缓冲图像中,然后从中获取数据如何从java中的图像获取光栅?,java,image,awt,raster,Java,Image,Awt,Raster,我正在尝试将gif图像从url加载到java.util.image.graster中,以便对其进行操作。我能找到的加载和解压缩图像的唯一方法是Toolkit.getImage,它返回一个java.awt.image。我需要把它转换成光栅,这样我就可以使用它了。建议?将图像加载到缓冲图像中,然后从中获取数据 BufferedImage img = null; try { img = ImageIO.read(new File ("c:/imageFile.gif")); } catch(Ex
BufferedImage img = null;
try {
img = ImageIO.read(new File ("c:/imageFile.gif"));
} catch(Exception e) {}
Raster R=img.getData();
将图像加载到缓冲图像中,然后从中获取数据
BufferedImage img = null;
try {
img = ImageIO.read(new File ("c:/imageFile.gif"));
} catch(Exception e) {}
Raster R=img.getData();
如果您只想在此图像上绘制,可以从BuffereImage中获取Graphics2D上下文
Graphics2D g=(Graphics2D) image.getGraphics();
//draw over your image
g.drawLine(1,1,100,100);
g.dispose();
//save your image, display it, etc...
如果您只想在此图像上绘制,可以从BuffereImage中获取Graphics2D上下文
Graphics2D g=(Graphics2D) image.getGraphics();
//draw over your image
g.drawLine(1,1,100,100);
g.dispose();
//save your image, display it, etc...