Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 可写光栅图像png格式?_Java_Image Processing_Java Ee 6 - Fatal编程技术网

Java 可写光栅图像png格式?

Java 可写光栅图像png格式?,java,image-processing,java-ee-6,Java,Image Processing,Java Ee 6,我有一个可写的光栅对象。我想将其保存为png图像。 我学到的光栅是,它是一个矩形区域的像素 是否可以将其保存为png图像?如果是,如何保存?您可以使用JAI将图像保存到磁盘,请参见示例: JAI支持tiff、jpeg、png SampleModel sampleModel = RasterFactory.createBandedSampleModel(DataBuffer.TYPE_FLOAT, width,height,1); // Create a compatible Color

我有一个可写的光栅对象。我想将其保存为png图像。 我学到的光栅是,它是一个矩形区域的像素


是否可以将其保存为png图像?如果是,如何保存?

您可以使用JAI将图像保存到磁盘,请参见示例: JAI支持tiff、jpeg、png

SampleModel sampleModel =
  RasterFactory.createBandedSampleModel(DataBuffer.TYPE_FLOAT,  width,height,1);
  // Create a compatible ColorModel.
  ColorModel colorModel = PlanarImage.createColorModel(sampleModel);

 Raster raster = RasterFactory.createWritableRaster(sampleModel,dbuffer, new Point(0,0));
  // Create a TiledImage using the float SampleModel.
  TiledImage tiledImage = new TiledImage(0,0,width,height,0,0,
  sampleModel,colorModel);
  // Set the data of the tiled image to be the raster.
  tiledImage.setData(raster);
  // Save the image on a file.
  JAI.create("filestore",tiledImage,"floatpattern.tif","TIFF");