當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。