• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Method类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: uploadThumbnail

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
public void uploadThumbnail(String path, ByteArrayOutputStream buffer, int width, int height) throws IOException {
    ByteArrayOutputStream thumbBuffer = new ByteArrayOutputStream();
    BufferedImage thumb = ImageIO.read(new ByteArrayInputStream(buffer.toByteArray()));
    thumb = Scalr.resize(thumb, Method.ULTRA_QUALITY,
            thumb.getHeight() < thumb.getWidth() ? Mode.FIT_TO_HEIGHT : Mode.FIT_TO_WIDTH,
            Math.max(width, height), Math.max(width, height), Scalr.OP_ANTIALIAS);
    thumb = Scalr.crop(thumb, width, height);

    ImageWriter writer = ImageIO.getImageWritersByFormatName("jpeg").next();
    ImageWriteParam param = writer.getDefaultWriteParam();
    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); // Needed see javadoc
    param.setCompressionQuality(1.0F); // Highest quality
    writer.setOutput(ImageIO.createImageOutputStream(thumbBuffer));
    writer.write(thumb);
    
    if (path.lastIndexOf('.') != -1) {
        path = path.substring(0, path.lastIndexOf('.'));
    }
    
    super.put(path + "." + width + "x" + height + ".jpg", new ByteArrayInputStream(thumbBuffer.toByteArray()),
            Long.valueOf(thumbBuffer.size()));
}
 
开发者ID:coding4people,项目名称:mosquito-report-api,代码行数:23,代码来源:PictureBucket.java


示例2: getBestFit

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
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,代码行数:25,代码来源:PdfPanel.java


示例3: getThumbnail

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
public byte[] getThumbnail(InputStream inputStream, String contentType, String rotation) throws IOException {
	try{
		String ext = contentType.replace("image/", "").equals("jpeg")? "jpg":contentType.replace("image/", "");

		BufferedImage bufferedImage = readImage(inputStream);	
		BufferedImage thumbImg = Scalr.resize(bufferedImage, Method.QUALITY,Mode.AUTOMATIC, 
				100,
				100, Scalr.OP_ANTIALIAS);
		//convert bufferedImage to outpurstream 
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ImageIO.write(thumbImg,ext,baos);
		baos.flush();

		return baos.toByteArray();
	}catch(Exception e){
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:stasbranger,项目名称:RotaryLive,代码行数:20,代码来源:ImageServiceImpl.java


示例4: scaleByWidth

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
/**
 * Scales the given image, preserving aspect ratio.
 */
public static BufferedImage scaleByWidth(BufferedImage inImage, int xSize)
{
	double aspectRatio = ((double) inImage.getHeight())
			/ inImage.getWidth();
	int ySize = (int) (xSize * aspectRatio);
	if (ySize == 0)
		ySize = 1;
	
	// This library is described at http://stackoverflow.com/questions/1087236/java-2d-image-resize-ignoring-bicubic-bilinear-interpolation-rendering-hints-os
	BufferedImage scaled = Scalr.resize(inImage, Method.QUALITY, xSize, ySize);

	if (inImage.getType() == BufferedImage.TYPE_BYTE_GRAY && scaled.getType() != BufferedImage.TYPE_BYTE_GRAY)
	{
		scaled = convertToGrayscale(scaled);
	}

	return scaled;
}
 
开发者ID:jeheydorn,项目名称:nortantis,代码行数:22,代码来源:ImageHelper.java


示例5: scaleByHeight

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
/**
 * Scales the given image, preserving aspect ratio.
 */
public static BufferedImage scaleByHeight(BufferedImage inImage, int ySize)
{
	double aspectRatioInverse = ((double) inImage.getWidth())
			/ inImage.getHeight();
	int xSize = (int) (aspectRatioInverse * ySize);
	if (xSize == 0)
		xSize = 1;
	
	// This library is described at http://stackoverflow.com/questions/1087236/java-2d-image-resize-ignoring-bicubic-bilinear-interpolation-rendering-hints-os
	BufferedImage scaled = Scalr.resize(inImage, Method.QUALITY, xSize, ySize);
	
	if (inImage.getType() == BufferedImage.TYPE_BYTE_GRAY && scaled.getType() != BufferedImage.TYPE_BYTE_GRAY)
	{
		scaled = convertToGrayscale(scaled);
	}
	
	return scaled;
}
 
开发者ID:jeheydorn,项目名称:nortantis,代码行数:22,代码来源:ImageHelper.java


示例6: getStyledImage

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
public static BufferedImage getStyledImage(File img, float brightness, float transparency, int size) {
    BufferedImage outputImage = null;
    try {
        BufferedImage readBufferedImage = ImageIO.read(img);
        BufferedImage inputBufferedImage = convertToArgb(readBufferedImage);
        outputImage = inputBufferedImage;
        if (size > 0) {
            outputImage = Scalr.resize(inputBufferedImage
                    , Method.BALANCED
                    , size
                    , size);
        }

        float brightnessFactor = 1.0f + brightness/100.0f;
        float transparencyFactor = Math.abs(transparency/100.0f - 1.0f);
        RescaleOp rescale = new RescaleOp(
                new float[]{brightnessFactor, brightnessFactor, brightnessFactor, transparencyFactor},
                new float[]{0f, 0f, 0f, 0f}, null);
        rescale.filter(outputImage, outputImage);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return outputImage;
}
 
开发者ID:shaolinwu,项目名称:uimaster,代码行数:25,代码来源:ImageUtil.java


示例7: getStyledImage

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
private BufferedImage getStyledImage(float brightness, float transparency, int size) {
    BufferedImage outputImage = null;
    try {
        BufferedImage readBufferedImage = ImageIO.read(new File(imageFilePath));
        BufferedImage inputBufferedImage = convertToArgb(readBufferedImage);
        outputImage = inputBufferedImage;
        if (size > 0) {
            outputImage = Scalr.resize(inputBufferedImage
                    , Method.BALANCED
                    , size
                    , size);
        }

        float brightnessFactor = 1.0f + brightness/100.0f;
        float transparencyFactor = Math.abs(transparency/100.0f - 1.0f);
        RescaleOp rescale = new RescaleOp(
                new float[]{brightnessFactor, brightnessFactor, brightnessFactor, transparencyFactor},
                new float[]{0f, 0f, 0f, 0f}, null);
        rescale.filter(outputImage, outputImage);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return outputImage;
}
 
开发者ID:atominvention,项目名称:AndroidDevToolbox,代码行数:25,代码来源:StatefulButtonController.java


示例8: saveScreenshotThumb

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
/**
 * Save screenshot thumb.
 * 
 * @param screenShotFile
 *            the screen shot file
 * @return the string
 */
private String saveScreenshotThumb(final String screenShotFile) {
    final int thumbWidth = 150;
    final int thumbHeight = 100;
    String screenShotThumb =
            "images" + File.separator + screenShotFile + "_Thumb.png";
    try {
        String screenShotOriginalFile =
                builder.getReportFolderLocation() + File.separator
                        + "images" + File.separator + screenShotFile;
        BufferedImage img = ImageIO.read(new File(screenShotOriginalFile));
        BufferedImage thumb =
                Scalr.resize(img, Method.SPEED, thumbWidth, thumbHeight,
                        Scalr.OP_ANTIALIAS, Scalr.OP_BRIGHTER);

        ImageIO.write(thumb, "png", new File(screenShotOriginalFile
                + "_Thumb.png"));

    } catch (IOException e) {
        e.printStackTrace();
    }
    return screenShotThumb;
}
 
开发者ID:VTAF,项目名称:VirtusaSeleniumWebdriverRuntime,代码行数:30,代码来源:Reporter.java


示例9: checkOptions

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
/**
 * Checks the validity of the options values.
 * @return true if all options have valid values, false otherwise
 */
private boolean checkOptions() {
	String dName = m_nameText.getText();
	if ("".equals(dName)) {
		showError("The default picture start name cannot be empty !");
		return false;
	}
	Method gMethod = m_methodList.getSelectedValue();
	if (gMethod == null) {
		showError("You must select a scaling method to generate the thumbnails !");
		return false;		
	}
	int tSize = (Integer) m_sizeText.getValue();
	if ((tSize < m_minThumbnailSize) || (tSize > m_maxThumbnailSize)) {
		showError("The thumbnail size must be between "+m_minThumbnailSize+ " and "+m_maxThumbnailSize+ " !");
		return false;
	}
	return true;
}
 
开发者ID:geberle,项目名称:PhotMan,代码行数:23,代码来源:PhotManOptionsPane.java


示例10: getListCellRendererComponent

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
@Override
public Component getListCellRendererComponent(JList<? extends Thumb> list, Thumb value, int index, boolean isSelected, boolean cellHasFocus) {
	Thumb entry = (Thumb) value;
	ImageIcon currentIcon = entry.getPreviewImageIconThumbImage();
	//no preview image so let's just try to resize it
	if (currentIcon == null) {
		currentIcon = entry.getImageIconThumbImage();
		//Image scaledImg = currentIcon.getImage().getScaledInstance(250, 250, java.awt.Image.SCALE_SMOOTH);
		BufferedImage img = (BufferedImage) currentIcon.getImage();
		BufferedImage scaledImage = Scalr.resize(img, Method.QUALITY, 250, 250, Scalr.OP_ANTIALIAS);
		currentIcon = new ImageIcon(scaledImage);
	}
	setIcon(currentIcon);
	if (isSelected) {
		setBackground(HIGHLIGHT_COLOR);
		setForeground(Color.white);
	} else {
		setBackground(Color.white);
		setForeground(Color.black);
	}
	return this;
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:23,代码来源:FanartPickerRenderer.java


示例11: imageLoaded

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
@Override
public void imageLoaded(BufferedImage img) {
	//clean up old references, just to be safe
	this.resizedImage = null;
	this.img = null;

	this.img = img;
	if (img != null) {
		isPosterCandidate = (img.getHeight() >= img.getWidth());
		Dimension newImageSize = calculateDimensionFit(img.getWidth(), img.getHeight(), getSize().width, getSize().height);
		this.resizedImage = Scalr.resize(img, Method.QUALITY, Scalr.Mode.AUTOMATIC, newImageSize.width, newImageSize.height, Scalr.OP_ANTIALIAS);

	}
	doneLoading = true;
	repaint();
	handleAutoSelection();
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:18,代码来源:AsyncImageComponent.java


示例12: initializeResourceIcon

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
private static ImageIcon initializeResourceIcon(String resourceName) {
	try {
		URL url = GUIMain.class.getResource(resourceName);
		if (url != null) {
			BufferedImage iconBufferedImage = ImageIO.read(url);
			if (iconBufferedImage != null) {
				iconBufferedImage = Scalr.resize(iconBufferedImage, Method.QUALITY, iconSizeX, iconSizeY, Scalr.OP_ANTIALIAS);
				return new ImageIcon(iconBufferedImage);
			} else
				return new ImageIcon();
		}
		return new ImageIcon();
	} catch (IOException e1) {
		e1.printStackTrace();
		return null;
	}
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:18,代码来源:GUIMainButtonPanel.java


示例13: initializeResourceIcon

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
private ImageIcon initializeResourceIcon(String resourceName, int iconSizeX, int iconSizeY) {
	try {
		URL url = GUIMain.class.getResource(resourceName);
		if (url != null) {
			BufferedImage iconBufferedImage = ImageIO.read(url);
			if (iconBufferedImage != null) {
				iconBufferedImage = Scalr.resize(iconBufferedImage, Method.QUALITY, iconSizeX, iconSizeY, Scalr.OP_ANTIALIAS);
				return new ImageIcon(iconBufferedImage);
			} else
				return new ImageIcon();
		}
		return new ImageIcon();
	} catch (IOException e1) {
		e1.printStackTrace();
		return null;
	}
}
 
开发者ID:DoctorD1501,项目名称:JAVMovieScraper,代码行数:18,代码来源:SiteParsingProfile.java


示例14: scaleImage

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
/**
 * @param buffImage
 * @param scaleWidth
 * @param scaleHeight
 * @return
 */
public static BufferedImage scaleImage(BufferedImage buffImage, int scaleWidth, int scaleHeight) {
    int imgHeight = buffImage.getHeight();
    int imgWidth = buffImage.getWidth();

    float destHeight = scaleHeight;
    float destWidth = scaleWidth;

    if ((imgWidth >= imgHeight) && (imgWidth > scaleWidth)) {
        destHeight = imgHeight * ((float) scaleWidth / imgWidth);
    } else if ((imgWidth < imgHeight) && (imgHeight > scaleHeight)) {
        destWidth = imgWidth * ((float) scaleHeight / imgHeight);
    } else {
        return buffImage;
    }

    return Scalr.resize(buffImage, Method.BALANCED, Mode.AUTOMATIC, (int) destWidth, (int) destHeight);
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:24,代码来源:ImageUtil.java


示例15: generateImageThumbnail

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
public static BufferedImage generateImageThumbnail(InputStream imageStream) throws IOException {
    try {
        int idealWidth = 256;
        BufferedImage source = ImageIO.read(imageStream);
        if (source == null) {
            return null;
        }
        int imgHeight = source.getHeight();
        int imgWidth = source.getWidth();

        float scale = (float) imgWidth / idealWidth;
        int height = (int) (imgHeight / scale);

        BufferedImage rescaledImage = Scalr.resize(source, Method.QUALITY,
                Mode.AUTOMATIC, idealWidth, height);
        if (height > 400) {
            rescaledImage = rescaledImage.getSubimage(0, 0,
                    Math.min(256, rescaledImage.getWidth()), 400);
        }
        return rescaledImage;
    } catch (Exception e) {
        LOG.error("Generate thumbnail for error", e);
        return null;
    }
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:26,代码来源:ImageUtil.java


示例16: processImage

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
private static byte[] processImage(BufferedImage image, int xRatio, int yRatio, int width, int height, PictureMode pictureMode) {
    final BufferedImage transformed, scaled;
    switch (pictureMode) {
    case FIT:
        transformed = Picture.transformFit(image, xRatio, yRatio);
        break;
    case ZOOM:
        transformed = Picture.transformZoom(image, xRatio, yRatio);
        break;
    default:
        transformed = Picture.transformFit(image, xRatio, yRatio);
        break;
    }
    scaled = Scalr.resize(transformed, Method.QUALITY, Mode.FIT_EXACT, width, height);
    return Picture.writeImage(scaled, ContentType.PNG);
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:17,代码来源:Photograph.java


示例17: resize

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
/**
 * resize image
 * @param image image to resize
 * @param size result image size
 * @return result image
 */
protected BufferedImage resize(BufferedImage image, int size) {
	if (size == image.getWidth() && 
		size == image.getHeight()) {
		log.info("Resize Image, Image's Width And Height Equals [{}], Ignore.", size);
		return image;
	}
	log.info("Resize Image To Size [{}]x[{}].", size, size);
	return Scalr.resize(image, Method.QUALITY, size, size);
}
 
开发者ID:chyxion,项目名称:image-combine,代码行数:16,代码来源:ImageCombine.java


示例18: resize

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
public static File resize(File file, int width, int height) {
	File resized = null;
	BufferedImage source = readFile(file);
	BufferedImage scaledImg = Scalr.resize(source, Method.QUALITY, height, width, Scalr.OP_ANTIALIAS);
	resized = writeAsJpeg(scaledImg, 100);
	return resized;
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:8,代码来源:ImageUtils.java


示例19: createThumbnail

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
public static void createThumbnail(File sourceImage, int width, int height, String extension) throws IOException {
	  BufferedImage img = ImageIO.read(sourceImage); // load image
	  BufferedImage thumbImg = Scalr.resize(img, Method.ULTRA_QUALITY,Mode.AUTOMATIC, 
			  width, height, Scalr.OP_ANTIALIAS);
	  
	   //convert bufferedImage to outpurstream 
	  ByteArrayOutputStream os = new ByteArrayOutputStream();
	  ImageIO.write(thumbImg,extension.toLowerCase(),os);
	  ImageIO.write(thumbImg, extension.toLowerCase(), sourceImage);
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:11,代码来源:ImageUtil.java


示例20: call

import org.imgscalr.Scalr.Method; //导入依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
  String source = ((StringValue) arguments[0].head()).getStringValue();
  String target = ((StringValue) arguments[1].head()).getStringValue();      
  String formatName = ((StringValue) arguments[2].head()).getStringValue();
  int targetSize = (int) ((Int64Value) arguments[3].head()).longValue();
  try {                             
    File targetFile = new File(target);                
    if (targetFile.isDirectory()) {          
      throw new IOException("Output file \"" + targetFile.getAbsolutePath() + "\" already exists as directory");          
    } else if (!targetFile.getParentFile().isDirectory() && !targetFile.getParentFile().mkdirs()) {
      throw new IOException("Could not create output directory \"" + targetFile.getParentFile().getAbsolutePath() + "\"");
    } else if (targetFile.isFile() && !targetFile.delete()) {
      throw new IOException("Error deleting existing target file \"" + targetFile.getAbsolutePath() + "\"");
    }               
    InputStream is;
    if (source.startsWith("http")) {
      is = new URL(source).openStream();
    } else {
      File file;
      if (source.startsWith("file:")) {
        file = new File(new URI(source));
      } else {
        file = new File(source);
      }                    
      if (!file.isFile()) {
        throw new IOException("File \"" + file.getAbsolutePath() + "\" not found or not a file");
      } 
      is = new BufferedInputStream(new FileInputStream(file));
    } 
    try {                
      BufferedImage img = ImageIO.read(is);          
      BufferedImage scaledImg = Scalr.resize(img, Method.AUTOMATIC, Mode.AUTOMATIC, targetSize, targetSize);
      BufferedImage imageToSave = new BufferedImage(scaledImg.getWidth(), scaledImg.getHeight(), BufferedImage.TYPE_INT_RGB);
      Graphics g = imageToSave.getGraphics();
      g.drawImage(scaledImg, 0, 0, null);          
      ImageIO.write(imageToSave, formatName, targetFile);
    } finally {
      is.close();
    }
    return EmptySequence.getInstance();
  } catch (Exception e) {
    throw new XPathException("Error scaling image \"" + source + "\" to \"" + target + "\"", e);
  }
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:46,代码来源:Scale.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContinuationSupport类代码示例发布时间:2022-05-21
下一篇:
Java Layout类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap