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

Java AdvancedResizeOp类代码示例

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

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



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

示例1: writeResizedImage

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
private void writeResizedImage(CPRFile cprFile, String fileName,
                               int width, int height)
        throws IOException {
    File outputBMP = new File(imagesDirectory, fileName);
    if (outputBMP.exists()) {
        backUpFile(outputBMP);
    }
    logger.info("resizing {} to {}x{}", fileName, width, height);
    InputStream originalImageStream =
        cprFile.getInputStream("images\\" + fileName);
    BufferedImage original = ImageIO.read(originalImageStream);
    ResampleOp resampleOp = new ResampleOp(width, height);
    resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
    BufferedImage resized = resampleOp.filter(original, null);
    ImageIO.write(resized, "bmp", outputBMP);
}
 
开发者ID:dsedivec,项目名称:P3WideScreen,代码行数:17,代码来源:PatchWorker.java


示例2: resizeImageToDINA4WithDPI

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
private static BufferedImage resizeImageToDINA4WithDPI(BufferedImage origImage, int targetDpiX, int targetDpiY,
                                               int origDpiX, int origDpiY, float scaleDown) {

    float targetRatioX = (float)Consts.millisToPixels(Consts.A4_W_MM, targetDpiX)/origImage.getWidth();
    float targetRatioY = (float)Consts.millisToPixels(Consts.A4_H_MM, targetDpiY)/origImage.getHeight();
    float targetRatio = Math.min(1.0f, Math.min(targetRatioX, targetRatioY)/scaleDown);

    Logger.getLogger(ImageHelper.class.getName()).log(Level.INFO,
            "Resizing BufferedImage (px) --- "+
                    "Original dimensions: ("+Integer.toString(origImage.getWidth())+
                    ","+Integer.toString(origImage.getHeight())+")"+
                    " - Fraction: ("+Float.toString(targetRatioX)+","+Float.toString(targetRatioY)+")"+
                    " - Using ratio: "+Float.toString(targetRatio));

    ResampleOp resampleOp = new ResampleOp(DimensionConstrain.createRelativeDimension(targetRatio, targetRatio));
    resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);

    return resampleOp.filter(origImage, null);
}
 
开发者ID:nandosola,项目名称:trantor-pdf-converter,代码行数:20,代码来源:ImageHelper.java


示例3: storeCroppedProfilePictures

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
@Override
@SqlTransactional
public void storeCroppedProfilePictures(int x, int y, int size, String userId) {
    try {
        User user = getDao().getById(User.class, userId, true);
        String url = user.getProfilePictureURI();
        if (!url.startsWith("http")) {
            url = "http:" + url;
        }
        BufferedImage original = ImageIO.read(new URL(url));

        String format = FilenameUtils.getExtension(user.getProfilePictureURI());

        BufferedImage cropped = original.getSubimage(x, y, size, size);

        ResampleOp smallOp = new ResampleOp(48, 48);
        smallOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
        BufferedImage small = smallOp.filter(cropped, null);

        ResampleOp largeOp = new ResampleOp(72, 72);
        largeOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
        BufferedImage large = largeOp.filter(cropped, null);

        user.setSmallProfilePictureURI(pictureService.storedCroppedProfilePicture(small, "_small", user.getId(), format));
        user.setLargeProfilePictureURI(pictureService.storedCroppedProfilePicture(large, "_large", user.getId(), format));

        save(user);
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:32,代码来源:UserAccountServiceImpl.java


示例4: testBug

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
public void testBug(){

		int srcWidth = 100;
		int srcHeight = 100;
		int dstWidth = 2;
		int dstHeight = 2;
		ResampleOp resampleOp = new ResampleOp(dstWidth, dstHeight);
		resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
		BufferedImage rescaledImage = resampleOp.filter(new BufferedImage(srcWidth, srcHeight, BufferedImage.TYPE_INT_BGR), null);
	}
 
开发者ID:mortennobel,项目名称:java-image-scaling,代码行数:11,代码来源:Issue2.java


示例5: testBug

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
public void testBug(){

		int srcWidth = 1920;
		int srcHeight = 1200;
		int dstWidth = (int) (srcWidth * 0.6);
		int dstHeight = (int) (srcHeight*0.6);
		ResampleOp resampleOp = new ResampleOp(dstWidth, dstHeight);
		resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Normal);
		BufferedImage rescaledImage = resampleOp.filter(new BufferedImage(srcWidth, srcHeight, BufferedImage.TYPE_INT_BGR), null);
		System.out.println("rescaledImage "+rescaledImage.getWidth()+"x"+rescaledImage.getHeight());
	}
 
开发者ID:mortennobel,项目名称:java-image-scaling,代码行数:12,代码来源:Issue3.java


示例6: getResizedToWidth

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
/**
 * Generate a new Picture object resized to a specific width, maintaining
 * the same aspect ratio of the original
 * @param width
 * @return Picture scaled to new width
 */
public Picture getResizedToWidth(int width) {
    if (width > getWidth())
        throw new IllegalArgumentException("Width "+ width +" exceeds width of image, which is "+ getWidth());
    int nHeight = width * img.getHeight() / img.getWidth();
    MultiStepRescaleOp rescale = new MultiStepRescaleOp(width, nHeight);
    rescale.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Soft);
    BufferedImage resizedImage = rescale.filter(img, null);

    return new Picture(resizedImage, sourceType);
}
 
开发者ID:onix,项目名称:diploma-bachelors-shibboleth-21-web,代码行数:17,代码来源:Picture.java


示例7: createResizedCopy

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
public static BufferedImage createResizedCopy(BufferedImage originalImage, int scaledWidth, int scaledHeight) {
	ResampleOp  resampleOp = new ResampleOp (scaledWidth,scaledHeight);
	resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.VerySharp);
	BufferedImage rescaledTomato = resampleOp.filter(originalImage, null);
	return rescaledTomato;
}
 
开发者ID:mortennobel,项目名称:java-image-scaling,代码行数:7,代码来源:Issue5.java


示例8: calculateResize

import com.mortennobel.imagescaling.AdvancedResizeOp; //导入依赖的package包/类
private Object calculateResize(Object key) {
    FrontKey fk = (FrontKey) key;
    String message = "Unknown error";
    try {
        Element e = backCache.get(new BackKey(fk));
        byte[] res = null;
        if (e != null) {
            if (e.getObjectValue() instanceof String) {
                // Backend generated an error
                return e.getObjectValue();
            }
            byte[] img = (byte[]) e.getObjectValue();
            ByteArrayInputStream bais = new ByteArrayInputStream(img);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            switch (fk.resize_filter.toLowerCase()) {
                case "lanczos":
                    // Lanczos3 rescale algorithm from:
                    // Always non proportion preserving
                    // https://code.google.com/p/java-image-scaling/
                    BufferedImage src = ImageIO.read(bais);
                    ResampleOp resampleOp = new ResampleOp(fk.resize_x, fk.resize_y);
                    resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.None);
                    resampleOp.setNumberOfThreads(2);
                    createJPEG(fk.mod, baos, resampleOp.filter(src, null));
                    src.flush();
                    break;
                case "imgscalr" :
                    // imgscalr method (Always proportion preserving)
                    // http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/
                    // Lile slower than lanczos
                    BufferedImage src2 = ImageIO.read(bais);
                    createJPEG(fk.mod,baos,Scalr.resize(src2, Scalr.Method.QUALITY, fk.resize_x, fk.resize_y, Scalr.OP_ANTIALIAS));
                    src2.flush();
                    break;
                default:
                    // Thumbnailator library method
                    // https://code.google.com/p/thumbnailator/
                    Thumbnails.of(bais)
                            .forceSize(fk.resize_x, fk.resize_y)
                            .outputFormat("jpg").outputQuality((double) fk.mod / 100.0).toOutputStream(baos);
            }
            res = baos.toByteArray();
            return res;
        }
    } catch (IOException ex) {
        message = "Request: " + fk.source_url + " resize failed.";
        Logger.getLogger(FrontCacheUpdater.class.getName()).log(Level.WARNING, message, ex);
    } catch (IllegalStateException ex2) {
        message = "Unknown Error " + ex2.getLocalizedMessage();
        Logger.getLogger(FrontCacheUpdater.class.getName()).log(Level.WARNING, message, ex2);
    }
    return message;
}
 
开发者ID:framegrace,项目名称:beume,代码行数:54,代码来源:FrontCacheUpdater.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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