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


Java JPEGEncodeParam.setQuality方法代码示例

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


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

示例1: saveToDisk

import com.sun.media.jai.codec.JPEGEncodeParam; //导入方法依赖的package包/类
public void saveToDisk(TiledImage ti, String fn) throws IOException {
    BufferedImage buffImg = new BufferedImage(ti.getWidth(), ti.getHeight(), BufferedImage.TYPE_INT_RGB);
    Graphics g2d = buffImg.getGraphics();
    g2d.drawImage(ti.getAsBufferedImage(), 0, 0, null);
    buffImg.flush();

    JPEGEncodeParam jpgParam = new JPEGEncodeParam();
    jpgParam.setQuality(0.85f);
    JAI.create("filestore", buffImg, fn, "JPEG", jpgParam);
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:11,代码来源:ClassImageRenderer.java

示例2: getEncoder

import com.sun.media.jai.codec.JPEGEncodeParam; //导入方法依赖的package包/类
@Override
protected ImageEncoder getEncoder(final RenderedImage image, final OutputStream out) {
  final JPEGEncodeParam param = new JPEGEncodeParam();
  param.setQuality(1f);
  return com.sun.media.jai.codec.ImageCodec.createImageEncoder("JPEG", out, param); //$NON-NLS-1$
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:7,代码来源:JpegEncoder.java

示例3: saveCurrentView

import com.sun.media.jai.codec.JPEGEncodeParam; //导入方法依赖的package包/类
/**
 * stores the current viewport as an image file. Executes a fileChooser for choosing the file and
 * displays a JOptionPane if successful.
 */
public void saveCurrentView() {
    JFileChooser fc = new JFileChooser();
    FileNameExtensionFilter filter = new FileNameExtensionFilter("*.jpg", "jpg");
    fc.setFileFilter(filter);
    String snapShotFileName = recognitionFrame.getPicName();
    snapShotFileName = snapShotFileName.replaceAll(RawUtilsCommon.getExtension(snapShotFileName, false), "snapshot.jpg");
    fc.setSelectedFile(new File(snapShotFileName));
    int returnVal = fc.showSaveDialog(this);
    String fn = null;
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        fn = fc.getSelectedFile().getAbsolutePath();
        if (!fn.toLowerCase().endsWith(".jpg")) fn += ".jpg";
    }
    fc = null;
    this.repaint();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    if (fn != null) {
        BufferedImage bi;
        Robot robot;
        try {
            Rectangle r = recognitionFrame.getBounds();
            r.x += recognitionFrame.getLocationOnScreen().x;
            r.y += recognitionFrame.getLocationOnScreen().y;
            robot = new Robot();
            bi = robot.createScreenCapture(r);
            JPEGEncodeParam jpgParam = new JPEGEncodeParam();
            jpgParam.setQuality(0.85f);
            JAI.create("filestore", bi, fn, "JPEG", jpgParam);
            System.gc(); // forces JAI to close the filehandle
            logger.debug("finished writing");
            JOptionPane.showMessageDialog(this, "Screenshot successfully saved to " + fn, "Screenshot saved", JOptionPane.INFORMATION_MESSAGE);
        } catch (AWTException e) {
            logger.error("error saving screenshot", e);
        }
    }
}
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:45,代码来源:ImageFrame.java

示例4: makeImageSnapshot

import com.sun.media.jai.codec.JPEGEncodeParam; //导入方法依赖的package包/类
public void makeImageSnapshot() {
     if (((long) bimg.getWidth() * bimg.getHeight()) > (8000L * 8000L)) {
         JOptionPane.showMessageDialog(this, "In the current version this feature can only be used for images where width*height <= 8000*8000.\nHowever, you can use the Orbit Agent to download the file.", "Image too large", JOptionPane.ERROR_MESSAGE);
         return;
     }

     JFileChooser fc = new JFileChooser();
     FileNameExtensionFilter filter = new FileNameExtensionFilter("*.tif", "tif");
     fc.setFileFilter(filter);
     String snapShotFileName = getPicName();
     snapShotFileName = snapShotFileName.replaceAll(RawUtilsCommon.getExtension(snapShotFileName, false), "tif");
     fc.setSelectedFile(new File(snapShotFileName));

     int returnVal = fc.showSaveDialog(this);
     if (returnVal == JFileChooser.APPROVE_OPTION) {

         logger.debug("begin making image snapshot");
         String fn = fc.getSelectedFile().getAbsolutePath();
         if (!fn.toLowerCase().endsWith(".tif")) fn += ".tif";

         Dimension2D oldVPSize = viewPortSize;
         Point2D oldVPOffs = getViewPortOffset();
         double sc = getScale();
         setScale(100d);
         setViewPortOffset(new Point(0, 0));
         viewPortSize = new Dimension(bimg.getWidth(), bimg.getHeight());
		
/*
ColorModel colorModel = new ComponentColorModel(
		 ColorSpace.getInstance(ColorSpace.CS_sRGB),
		 new int[]{8,8,8}, false, false,
		 Transparency.OPAQUE, 
		 DataBuffer.TYPE_BYTE); 
SampleModel sampleModel = colorModel.createCompatibleSampleModel(256, 256);
DiskMemImage tiledImage = new DiskMemImage(0, 0, bimg.getWidth(), bimg.getHeight(), 0, 0, sampleModel, colorModel);
Graphics2D g2d = (Graphics2D)tiledImage.createGraphics();
((DiskMemImageGraphics)g2d).overwriteRenderingHint((((Graphics2D)getGraphics()).getRenderingHints()));
*/
         // Update 1.7.2010: Fallback to normal bufferedImage (only up to 30kx30k pixel!)
         // due to rendering problems with class image (only first tile problem)

         BufferedImage buffImg = new BufferedImage(bimg.getWidth(), bimg.getHeight(), BufferedImage.TYPE_INT_RGB);
         Graphics2D g2d = buffImg.createGraphics();
         buffImg.flush();


         paint(g2d);
         setScale(sc);
         setViewPortOffset(oldVPOffs);
         viewPortSize = oldVPSize;
         logger.info("finished painting");

         TIFFEncodeParam param = new TIFFEncodeParam();
         param.setTileSize(128, 128);
         param.setWriteTiled(true);
         param.setCompression(TIFFEncodeParam.COMPRESSION_JPEG_TTN2);
         JPEGEncodeParam jpgParam = new JPEGEncodeParam();
         jpgParam.setQuality(0.85f);
         param.setJPEGEncodeParam(jpgParam);

         // TODO: extraImages (Iterator where .next() returns further (low-res) RenderedImages
         //param.setExtraImages(extraImages)

         JAI.create("filestore", /*tiledImage*/buffImg, fn, "TIFF", param);

         logger.info("finished writing");

         JOptionPane.showMessageDialog(null, "Image successfully saved to " + fn, "Image saved", JOptionPane.INFORMATION_MESSAGE);

         //tiledImage = null;
         //DiskMemImage.getCommonTileCache().flush();
         Runtime.getRuntime().gc();
         Runtime.getRuntime().gc();
         Runtime.getRuntime().gc();
         logger.debug("cleaning up finished");

     }

 }
 
开发者ID:mstritt,项目名称:orbit-image-analysis,代码行数:80,代码来源:RecognitionFrame.java


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