当前位置: 首页>>代码示例>>Java>>正文


Java ImageReader.getDefaultReadParam方法代码示例

本文整理汇总了Java中javax.imageio.ImageReader.getDefaultReadParam方法的典型用法代码示例。如果您正苦于以下问题:Java ImageReader.getDefaultReadParam方法的具体用法?Java ImageReader.getDefaultReadParam怎么用?Java ImageReader.getDefaultReadParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.imageio.ImageReader的用法示例。


在下文中一共展示了ImageReader.getDefaultReadParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cut

import javax.imageio.ImageReader; //导入方法依赖的package包/类
public static BufferedImage cut(String format, InputStream src, int x, int y, int w, int h) throws IOException {
	Iterator<ImageReader> iterator = ImageIO.getImageReadersByFormatName(format);
	ImageReader reader = (ImageReader) iterator.next();
	ImageInputStream iis = ImageIO.createImageInputStream(src);
	reader.setInput(iis, true);
	ImageReadParam param = reader.getDefaultReadParam();
	int imgWidth = reader.getWidth(0);
	int imgHeight = reader.getHeight(0);
	if (x + w > imgWidth) {
		w = imgWidth - x;
	}
	if (y + h > imgHeight) {
		h = imgHeight - y;
	}
	Rectangle rect = new Rectangle(x, y, w, h);
	param.setSourceRegion(rect);
	BufferedImage bi = reader.read(0, param);
	return bi;
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:20,代码来源:ImageSizeUtils.java

示例2: newData

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Override
public void newData(byte[] bytes) {
	if(Dashboard.visionInitialized()){
		Mat m = CvProcessing.byteArray2Mat(bytes);
		Dashboard.setForVision(m);
	}
	if(mode == DisplayMode.Normal){
		ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
        Iterator<?> readers = ImageIO.getImageReadersByFormatName("jpeg");
 
        ImageReader reader = (ImageReader) readers.next();
        Object source = bis; 
       
		try {
			ImageInputStream iis = ImageIO.createImageInputStream(source); 
		    reader.setInput(iis, true);
		    ImageReadParam param = reader.getDefaultReadParam();
		    BufferedImage image = reader.read(0, param); 
		    setImage(image);
		} catch (IOException e) {
		}
	}

}
 
开发者ID:Flash3388,项目名称:FlashLib,代码行数:25,代码来源:CameraViewer.java

示例3: read

import javax.imageio.ImageReader; //导入方法依赖的package包/类
public static BufferedImage read(String format, InputStream in) throws IOException {
	Iterator<ImageReader> iterator = ImageIO.getImageReadersByFormatName(format);
	ImageReader reader = (ImageReader) iterator.next();
	ImageInputStream iis = ImageIO.createImageInputStream(in);
	reader.setInput(iis, true);
	ImageReadParam param = reader.getDefaultReadParam();
	BufferedImage bi = reader.read(0, param);
	return bi;
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:10,代码来源:ImageUtils.java

示例4: testCropFullHeightOffset

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testCropFullHeightOffset() throws IOException {
  ImageReader reader = getReader("prime_shaped.jpg");
  TurboJpegImageReadParam param = (TurboJpegImageReadParam) reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(192, 9, 172, 500));
  BufferedImage img = reader.read(0, param);
  assertThat(img).hasDimensions(172, 500);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:9,代码来源:TurboJpegImageReaderTest.java

示例5: testType

import javax.imageio.ImageReader; //导入方法依赖的package包/类
private static void testType(ImageReader reader,
                             ImageTypeSpecifier t,
                             BufferedImage src)
    throws IOException
{
    ImageReadParam p = reader.getDefaultReadParam();
    p.setDestinationType(t);
    BufferedImage dst = reader.read(0, p);

    verify(src, dst, t);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:ReadAsGrayTest.java

示例6: test

import javax.imageio.ImageReader; //导入方法依赖的package包/类
private static void test(String format) throws IOException {
    System.out.println("Format: " + format);

    BufferedImage src = createSrc();

    ImageInputStream iis = prepareInput(src, format);

    ImageReader reader = ImageIO.getImageReaders(iis).next();

    reader.setInput(iis);

    ImageReadParam p = reader.getDefaultReadParam();
    int cnt = 0;
    do {
        System.out.println("cnt: " + cnt);
        p.setSourceRegion(new Rectangle(width / 4, height / 4,
                                        width / 2, height / 2));

        BufferedImage dst = reader.read(0, p);

        final Color c = new Color(dst.getRGB(10, 10), true);

        if (!sameColor(c, srcColor)) {
            throw new RuntimeException(
                String.format("Test failed: read color 0x%X\n",
                              c.getRGB()));
        }
    } while (++cnt < max);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:MultiReadTest.java

示例7: readTestImage

import javax.imageio.ImageReader; //导入方法依赖的package包/类
public static BufferedImage readTestImage(String fileName,
                               BufferedImage dest,
                               Rectangle srcROI)
{
    BufferedImage bi = null;

    try {
        FileImageInputStream is =
            new FileImageInputStream(new File(fileName));
        ImageReader reader =
            (ImageReader)ImageIO.getImageReaders(is).next();
        ImageReadParam param = reader.getDefaultReadParam();
        if (dest != null) {
            param.setDestination(dest);
        }
        if (srcROI != null) {
            param.setSourceRegion(srcROI);
        }
        reader.setInput(is);
        bi = reader.read(0, param);
    } catch (IOException e) {
        System.err.println("Error " + e +
                           " when reading file: " + fileName);
        throw new RuntimeException(e);
    }

    return bi;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:JPEGsNotAcceleratedTest.java

示例8: testReadRegionAligned

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testReadRegionAligned() throws IOException {
  ImageReader reader = getReader("crop_aligned.jpg");
  ImageReadParam param = reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(32, 32, 96, 96));
  BufferedImage img = reader.read(0, param);
  assertThat(img)
      .hasDimensions(96, 96)
      .hasNoPixelsOfColor(-1 /* white */);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:11,代码来源:TurboJpegImageReaderTest.java

示例9: testReadRegionUnaligned

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testReadRegionUnaligned() throws IOException {
  ImageReader reader = getReader("crop_unaligned.jpg");
  ImageReadParam param = reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(116, 148, 204, 172));
  BufferedImage img = reader.read(0, param);
  assertThat(img)
      .hasDimensions(204, 172)
      .hasNoPixelsOfColor(-1 /* white */);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:11,代码来源:TurboJpegImageReaderTest.java

示例10: testReadUnalignedScaled

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testReadUnalignedScaled() throws IOException {
  ImageReader reader = getReader("crop_unaligned.jpg");
  ImageReadParam param = reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(87, 111, 152, 129));
  BufferedImage img = reader.read(1, param);
  assertThat(img)
      .hasDimensions(152, 129)
      .hasNoPixelsOfColor(-1 /* white */);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:11,代码来源:TurboJpegImageReaderTest.java

示例11: testReadUnalignedRotated

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testReadUnalignedRotated() throws IOException {
  ImageReader reader = getReader("crop_unaligned_rot90.jpg");
  TurboJpegImageReadParam param = (TurboJpegImageReadParam) reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(16, 16, 339, 319));
  param.setRotationDegree(90);
  BufferedImage img = reader.read(0, param);
  assertThat(img)
      .hasDimensions(319, 339)
      .hasNoPixelsOfColor(-1 /* white */);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:12,代码来源:TurboJpegImageReaderTest.java

示例12: testReadRotated

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testReadRotated() throws IOException {
  ImageReader reader = getReader("crop_unaligned.jpg");
  TurboJpegImageReadParam param = (TurboJpegImageReadParam) reader.getDefaultReadParam();
  param.setRotationDegree(90);
  BufferedImage img = reader.read(0, param);
  img = img.getSubimage(192, 116, 172, 204);

  // Need to copy the image so we can check the image data
  BufferedImage copy = new BufferedImage(img.getWidth(), img.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
  Graphics g = copy.createGraphics();
  g.drawImage(img, 0, 0, null);
  assertThat(img).hasNoPixelsOfColor(-1);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:15,代码来源:TurboJpegImageReaderTest.java

示例13: testReadRegionRotated

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testReadRegionRotated() throws IOException {
  ImageReader reader = getReader("crop_unaligned.jpg");
  TurboJpegImageReadParam param = (TurboJpegImageReadParam) reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(116, 148, 204, 172));
  param.setRotationDegree(90);
  BufferedImage img = reader.read(0, param);
  assertThat(img)
      .hasDimensions(172, 204)
      .hasNoPixelsOfColor(-1 /* white */);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:12,代码来源:TurboJpegImageReaderTest.java

示例14: testUnalignedCropOnPrimeShaped

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testUnalignedCropOnPrimeShaped() throws IOException {
  ImageReader reader = getReader("prime_shaped.jpg");
  TurboJpegImageReadParam param = (TurboJpegImageReadParam) reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(131, 57, 239, 397));
  BufferedImage img = reader.read(0, param);
  assertThat(img).hasDimensions(239, 397)
          .hasNoPixelsOfColor(-1);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:10,代码来源:TurboJpegImageReaderTest.java

示例15: testCropFullWidth

import javax.imageio.ImageReader; //导入方法依赖的package包/类
@Test
public void testCropFullWidth() throws IOException {
  ImageReader reader = getReader("prime_shaped.jpg");
  TurboJpegImageReadParam param = (TurboJpegImageReadParam) reader.getDefaultReadParam();
  param.setSourceRegion(new Rectangle(0, 192, 521, 172));
  BufferedImage img = reader.read(0, param);
  assertThat(img).hasDimensions(521, 172);
}
 
开发者ID:dbmdz,项目名称:imageio-jnr,代码行数:9,代码来源:TurboJpegImageReaderTest.java


注:本文中的javax.imageio.ImageReader.getDefaultReadParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。