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


Java Mode.FIT_TO_WIDTH属性代码示例

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


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

示例1: getBestFit

private BufferedImage getBestFit (BufferedImage bi, int maxWidth, int maxHeight)
  {
if (bi == null)
	return null ;

  	Mode mode = Mode.AUTOMATIC ;
  	int maxSize = Math.min(maxWidth, maxHeight) ;
  	double dh = (double)bi.getHeight() ;
  	if (dh > Double.MIN_VALUE)
  	{
  		double imageAspectRatio = (double)bi.getWidth() / dh ;
      	if (maxHeight * imageAspectRatio <=  maxWidth)
      	{
      		maxSize = maxHeight ;
      		mode = Mode.FIT_TO_HEIGHT ;
      	}
      	else
      	{
      		maxSize = maxWidth ;
      		mode = Mode.FIT_TO_WIDTH ;
      	}	
  	}
  	return Scalr.resize(bi, Method.QUALITY, mode, maxSize, Scalr.OP_ANTIALIAS) ; 
  }
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:24,代码来源:PdfPanel.java

示例2: scaleImage

private BufferedImage scaleImage(BufferedImage image, int frameWidth, int frameHeight) throws IOException {
	int targetSize = 0;
	Mode mode;
	if (props.getScreenshotViewScaling() == ViewScaling.HORIZONTAL) {
		targetSize = (int) (frameWidth * 0.97);
		mode = Mode.FIT_TO_WIDTH;
	} else {
		targetSize = frameHeight - 160;
		mode = Mode.FIT_TO_HEIGHT;
	}

	if (mode == Mode.FIT_TO_WIDTH && image.getWidth() <= targetSize) {
		return image;
	} else if (mode == Mode.FIT_TO_HEIGHT && image.getHeight() <= targetSize) {
		return image;
	} else {
		BufferedImage scaledImage = Scalr.resize(image, mode, targetSize, Scalr.OP_ANTIALIAS);
		return scaledImage;
	}
}
 
开发者ID:mnikliborc,项目名称:clicktrace,代码行数:20,代码来源:ScreenShotView.java

示例3: paintComponent

/**
 * {@inheritDoc}.
 */
@Override
protected synchronized void paintComponent(Graphics g) {
    g.setColor(Color.LIGHT_GRAY);
    g.fillRect(0, 0, getWidth(), getHeight());
    if (image != null) 
    {
    	Mode mode = Mode.AUTOMATIC ;
    	int maxSize = Math.min(this.getWidth(), this.getHeight()) ;
    	double dh = (double)image.getHeight() ;
    	if (dh > Double.MIN_VALUE)
    	{
    		double imageAspectRatio = (double)image.getWidth() / dh ;
     	if (this.getHeight() * imageAspectRatio <=  this.getWidth())
     	{
     		maxSize = this.getHeight() ;
     		mode = Mode.FIT_TO_HEIGHT ;
     	}
     	else
     	{
     		maxSize = this.getWidth() ;
     		mode = Mode.FIT_TO_WIDTH ;
     	}	
    	}
    	BufferedImage scaledImg = Scalr.resize(image, Method.AUTOMATIC, mode, maxSize, Scalr.OP_ANTIALIAS) ;  
        g.drawImage(scaledImg, 0, 0, scaledImg.getWidth(), scaledImg.getHeight(), this);
    }
}
 
开发者ID:roikku,项目名称:swift-explorer,代码行数:30,代码来源:ImagePanel.java

示例4: fitTo

static public BufferedImage fitTo(BufferedImage source, int width, int height) {
    Mode mode;
    if (source.getHeight() > source.getWidth()) {
        mode = Mode.FIT_TO_HEIGHT;
    } else {
        mode = Mode.FIT_TO_WIDTH;
    }
    return Scalr.resize(source, Method.QUALITY, mode, width, height);
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:9,代码来源:Picture.java


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