• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java Antialiasing类的典型用法和代码示例

java 1次浏览

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

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

示例1: resizerThenAntialiasing

点赞 3

import net.coobird.thumbnailator.resizers.configurations.Antialiasing; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The resizer method is called.</li>
 * <li>Then, the antialiasing method is called.</li>
 * </ol>
 * and the expected outcome is,
 * <ol>
 * <li>A thumbnail is created successfully.</li>
 * </ol>
 */
@Test
public void resizerThenAntialiasing() throws IOException
{
	// given
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	// when
	BufferedImage thumbnail = Thumbnails.of(img)
		.size(50, 50)
		.resizer(Resizers.PROGRESSIVE)
		.antialiasing(Antialiasing.DEFAULT)
		.asBufferedImage();

	// then
	assertEquals(50, thumbnail.getWidth());
	assertEquals(50, thumbnail.getHeight());
}
 

开发者ID:coobird,
项目名称:thumbnailator,
代码行数:29,
代码来源:ThumbnailsBuilderTest.java

示例2: resizerFactoryThenAntialiasing

点赞 3

import net.coobird.thumbnailator.resizers.configurations.Antialiasing; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The resizer method is called.</li>
 * <li>Then, the antialiasing method is called.</li>
 * </ol>
 * and the expected outcome is,
 * <ol>
 * <li>A thumbnail is created successfully.</li>
 * </ol>
 */
@Test(expected=IllegalStateException.class)
public void resizerFactoryThenAntialiasing() throws IOException
{
	// given
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	// when
	Thumbnails.of(img)
		.size(50, 50)
		.resizerFactory(DefaultResizerFactory.getInstance())
		.antialiasing(Antialiasing.DEFAULT)
		.asBufferedImage();
	
	// then
	fail();
}
 

开发者ID:coobird,
项目名称:thumbnailator,
代码行数:28,
代码来源:ThumbnailsBuilderTest.java

示例3: testScaleImages

点赞 2

import net.coobird.thumbnailator.resizers.configurations.Antialiasing; //导入依赖的package包/类
@Test
public void testScaleImages() throws Exception {

    final int[] IMAGE_SCALE_DIMENSIONS = new int[] {575, 199, 80, 60};
    final float QUALITY = 0.8f;

    File sourceImageDir = new File("../../images/willhaben");
    File[] sourceImageFiles = sourceImageDir.listFiles();

    long currentTime = System.currentTimeMillis();

    for (File sourceImageFile : sourceImageFiles) {

        BufferedImage bufferedImage = ImageIO.read(sourceImageFile);

        for (int size : IMAGE_SCALE_DIMENSIONS) {

            BufferedImage scaledBufferedImage = Thumbnails.of(bufferedImage).
                    width(size).
                    height(size).
                    keepAspectRatio(true).
                    outputQuality(QUALITY).
                    antialiasing(Antialiasing.ON).
                    asBufferedImage();

            bufferedImage = scaledBufferedImage;

            BufferedImageFactory.writeBufferedImage(scaledBufferedImage, "jpeg", createOutputFileName("testScaleImages/" + size, sourceImageFile, "jpeg"));
        }
    }

    long duration = System.currentTimeMillis() - currentTime;

    System.out.println("Scaling source images to " + IMAGE_SCALE_DIMENSIONS.length + " previews took " + duration / sourceImageFiles.length + " ms");
}
 

开发者ID:sgoeschl,
项目名称:java-image-processing-survival-guide,
代码行数:36,
代码来源:ImageScalingThumbnailatorTest.java

示例4: scaleImageCore

点赞 2

import net.coobird.thumbnailator.resizers.configurations.Antialiasing; //导入依赖的package包/类
@Override
protected BufferedImage scaleImageCore(BufferedImage image, int targetWidth, int targetHeight,
        Map<String, Object> options) throws IOException {
    Thumbnails.Builder<BufferedImage> builder = Thumbnails.of(image).size(targetWidth, targetHeight);
    ScalingMode filter = getFilter(options);
    if (filter != null) {
        builder = builder.scalingMode(getFilter(options));
    }
    Boolean dithering = getDithering(options);
    if (dithering != null) {
        builder = builder.dithering(dithering ? Dithering.ENABLE : Dithering.DISABLE);
    }
    Boolean antialiasing = getAntialiasing(options);
    if (antialiasing != null) {
        builder = builder.antialiasing(antialiasing ? Antialiasing.ON : Antialiasing.OFF);
    }
    
    // FIXME?: Thumbnailator doesn't appear to preserve the ColorModel of indexed images nor suppport setting it.
    // so for indexed we have no choice but to pass a hardcoded RGB type, which
    // will lose the original color model... oh well?
    
    // FIXME?: can do the TYPE_PRESERVING logic better here...

    ImageType targetType = getMergedTargetImageType(options, ImageType.EMPTY);
    ImageTypeInfo targetTypeInfo = targetType.getImageTypeInfoFor(image);
    
    BufferedImage resultImage;
    if (!ImagePixelType.isTypeNoPreserveOrNull(targetTypeInfo.getPixelType())) {
        ImageTypeInfo resolvedTargetTypeInfo = ImageType.resolveTargetType(targetTypeInfo, image);

        if (isNativeSupportedDestImageType(resolvedTargetTypeInfo)) {
            // here lib will _probably_ support the type we want...
            builder.imageType(resolvedTargetTypeInfo.getPixelType());
            resultImage = builder.asBufferedImage();
        } else {
            if (isPostConvertResultImage(image, options, targetTypeInfo)) {
                // for thumbnailator, we must always specify imageType because its default is to preserve and that doesn't work
                builder.imageType(ImageType.DEFAULT_DIRECT.getPixelTypeFor(image)); 
                resultImage = builder.asBufferedImage();
                resultImage = checkConvertResultImageType(image, resultImage, options, targetTypeInfo);
            } else {
                builder.imageType(getFirstSupportedDestPixelTypeFromAllDefaults(options, image));
                resultImage = builder.asBufferedImage();
            }
        }
    } else {
        builder.imageType(getFirstSupportedDestPixelTypeFromAllDefaults(options, image)); 
        resultImage = builder.asBufferedImage();
    }
    return resultImage;
}
 

开发者ID:ilscipio,
项目名称:scipio-erp,
代码行数:52,
代码来源:ThumbnailatorImageScaler.java

示例5: antialiasing

点赞 1

import net.coobird.thumbnailator.resizers.configurations.Antialiasing; //导入依赖的package包/类
/**
 * Sets the antialiasing mode when performing the resizing
 * operation to generate the thumbnail.
 * <p>
 * Calling this method to set this parameter is optional.
 * <p>
 * Calling this method multiple times will result in an
 * {@link IllegalStateException}.
 * <p>
 * This method cannot be called in conjunction with the
 * {@link #resizerFactory(ResizerFactory)} method.
 * 
 * @param config		The antialiasing mode.
 * @return				Reference to this object.
 */
public Builder<T> antialiasing(Antialiasing config)
{
	checkForNull(config, "Antialiasing is null.");
	updateStatus(Properties.RESIZER_FACTORY, Status.CANNOT_SET);
	updateStatus(Properties.ANTIALIASING, Status.ALREADY_SET);
	antialiasing = config;
	return this;
}
 

开发者ID:farhan,
项目名称:Android-Image-Resizer-Module,
代码行数:24,
代码来源:Thumbnails.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)