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


Java DefaultResizerFactory类代码示例

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


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

示例1: resizerThenResizerFactory

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

	// then
	fail();
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:28,代码来源:ThumbnailsBuilderTest.java

示例2: resizerFactoryThenResizer

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The resizerFactory method is called.</li>
 * <li>Then, the resizer method is called.</li>
 * </ol>
 * and the expected outcome is,
 * <ol>
 * <li>An IllegalStateException is thrown.</li>
 * </ol>
 */
@Test(expected=IllegalStateException.class)
public void resizerFactoryThenResizer() throws IOException
{
	// given
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	// when
	Thumbnails.of(img)
		.size(50, 50)
		.resizerFactory(DefaultResizerFactory.getInstance())
		.resizer(Resizers.PROGRESSIVE)
		.asBufferedImage();
	
	// then
	fail();
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:28,代码来源:ThumbnailsBuilderTest.java

示例3: resizerFactoryThenAlphainterpolation

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The resizer method is called.</li>
 * <li>Then, the alphaInterpolation 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 resizerFactoryThenAlphainterpolation() throws IOException
{
	// given
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	// when
	Thumbnails.of(img)
		.size(50, 50)
		.resizerFactory(DefaultResizerFactory.getInstance())
		.alphaInterpolation(AlphaInterpolation.SPEED)
		.asBufferedImage();
	
	// then
	fail();
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:28,代码来源:ThumbnailsBuilderTest.java

示例4: resizerFactoryThenDithering

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The resizer method is called.</li>
 * <li>Then, the dithering 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 resizerFactoryThenDithering() throws IOException
{
	// given
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	// when
	Thumbnails.of(img)
		.size(50, 50)
		.resizerFactory(DefaultResizerFactory.getInstance())
		.dithering(Dithering.DEFAULT)
		.asBufferedImage();
	
	// then
	fail();
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:28,代码来源:ThumbnailsBuilderTest.java

示例5: resizerFactoryThenAntialiasing

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的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

示例6: resizerFactoryThenRendering

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The resizer method is called.</li>
 * <li>Then, the rendering 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 resizerFactoryThenRendering() throws IOException
{
	// given
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	// when
	Thumbnails.of(img)
		.size(50, 50)
		.resizerFactory(DefaultResizerFactory.getInstance())
		.rendering(Rendering.DEFAULT)
		.asBufferedImage();
	
	// then
	fail();
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:28,代码来源:ThumbnailsBuilderTest.java

示例7: defaultResizerFactory

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Sets the {@link ResizerFactory} to use {@link DefaultResizerFactory}.
 * 
 * @return				A reference to this object.
 * @since	0.4.0
 */
public ThumbnailMaker defaultResizerFactory()
{
	this.resizerFactory = DefaultResizerFactory.getInstance();
	ready.set(PARAM_RESIZER);
	ready.set(PARAM_RESIZERFACTORY);
	return this;
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:14,代码来源:ThumbnailMaker.java

示例8: testCreateThumbnail_ThumbnailTask_ResizerFactoryBeingUsed_UsingSize

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for
 * {@link Thumbnailator#createThumbnail(net.coobird.thumbnailator.tasks.ThumbnailTask)}
 * where,
 * 
 * 1) The correct parameters are given.
 * 2) The size is specified for the ThumbnailParameter.
 * 
 * Expected outcome is,
 * 
 * 1) The ResizerFactory is being used.
 * 
 * @throws IOException
 */
@Test
public void testCreateThumbnail_ThumbnailTask_ResizerFactoryBeingUsed_UsingSize() throws IOException
{
	// given
	BufferedImageSource source = new BufferedImageSource(
			new BufferedImageBuilder(200, 200, BufferedImage.TYPE_INT_ARGB).build()
	);
	BufferedImageSink sink = new BufferedImageSink();
	ResizerFactory resizerFactory = spy(DefaultResizerFactory.getInstance());
	
	ThumbnailParameter param =
		new ThumbnailParameterBuilder()
			.size(100, 100)
			.resizerFactory(resizerFactory)
			.build();
	
	
	// when
	Thumbnailator.createThumbnail(
			new SourceSinkThumbnailTask<BufferedImage, BufferedImage>(
					param, source, sink
			)
	);
	
	// then
	verify(resizerFactory)
			.getResizer(new Dimension(200, 200), new Dimension(100, 100));
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:43,代码来源:ThumbnailatorTest.java

示例9: testCreateThumbnail_ThumbnailTask_ResizerFactoryBeingUsed_UsingScale

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for
 * {@link Thumbnailator#createThumbnail(net.coobird.thumbnailator.tasks.ThumbnailTask)}
 * where,
 * 
 * 1) The correct parameters are given.
 * 2) The scale is specified for the ThumbnailParameter.
 * 
 * Expected outcome is,
 * 
 * 1) The ResizerFactory is being used.
 * 
 * @throws IOException
 */
@Test
public void testCreateThumbnail_ThumbnailTask_ResizerFactoryBeingUsed_UsingScale() throws IOException
{
	// given
	BufferedImageSource source = new BufferedImageSource(
			new BufferedImageBuilder(200, 200, BufferedImage.TYPE_INT_ARGB).build()
	);
	BufferedImageSink sink = new BufferedImageSink();
	ResizerFactory resizerFactory = spy(DefaultResizerFactory.getInstance());
	
	ThumbnailParameter param =
		new ThumbnailParameterBuilder()
			.scale(0.5)
			.resizerFactory(resizerFactory)
			.build();
	
	
	// when
	Thumbnailator.createThumbnail(
			new SourceSinkThumbnailTask<BufferedImage, BufferedImage>(
					param, source, sink
			)
	);
	
	// then
	verify(resizerFactory)
		.getResizer(new Dimension(200, 200), new Dimension(100, 100));
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:43,代码来源:ThumbnailatorTest.java

示例10: resizerFactoryThenScalingMode

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The resizerFactory method is called, then</li>
 * <li>The scalingMode method is called</li>
 * </ol>
 * and the expected outcome is,
 * <ol>
 * <li>An {@link IllegalStateException} is thrown</li>
 * </ol>
 */	
@Test(expected=IllegalStateException.class)
public void resizerFactoryThenScalingMode() throws IOException
{
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	Thumbnails.of(img)
		.size(200, 200)
		.resizerFactory(DefaultResizerFactory.getInstance())
		.scalingMode(ScalingMode.PROGRESSIVE_BILINEAR)
		.asBufferedImage();
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:23,代码来源:ThumbnailsBuilderTest.java

示例11: scalingModeThenResizerFactory

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Test for the {@link Thumbnails.Builder} class where,
 * <ol>
 * <li>The scalingMode method is called, then</li>
 * <li>The resizerFactory method is called</li>
 * </ol>
 * and the expected outcome is,
 * <ol>
 * <li>An {@link IllegalStateException} is thrown</li>
 * </ol>
 */	
@Test(expected=IllegalStateException.class)
public void scalingModeThenResizerFactory() throws IOException
{
	BufferedImage img = new BufferedImageBuilder(200, 200).build();
	
	Thumbnails.of(img)
		.size(200, 200)
		.scalingMode(ScalingMode.PROGRESSIVE_BILINEAR)
		.resizerFactory(DefaultResizerFactory.getInstance())
		.asBufferedImage();
}
 
开发者ID:coobird,项目名称:thumbnailator,代码行数:23,代码来源:ThumbnailsBuilderTest.java

示例12: createThumbnail

import net.coobird.thumbnailator.resizers.DefaultResizerFactory; //导入依赖的package包/类
/**
 * Creates a thumbnail.
 * <p>
 * The resulting thumbnail uses the default image type.
 * <p>
 * When the image is resized, the aspect ratio will be preserved.
 * <p>
 * When the specified dimensions does not have the same aspect ratio as the
 * source image, the specified dimensions will be used as the absolute
 * boundary of the thumbnail.
 * <p>
 * For example, if the source image of 100 pixels by 100 pixels, and the
 * desired thumbnail size is 50 pixels by 100 pixels, then the resulting
 * thumbnail will be 50 pixels by 50 pixels, as the constraint will be
 * 50 pixels for the width, and therefore, by preserving the aspect ratio,
 * the height will be required to be 50 pixels.
 * </p>
 * 
 * @param img				The source image.
 * @param width				The width of the thumbnail.
 * @param height			The height of the thumbnail.
 * @return					Resulting thumbnail.
 */
public static BufferedImage createThumbnail(
		BufferedImage img,
		int width,
		int height
)
{
	validateDimensions(width, height);
	
	Dimension imgSize = new Dimension(img.getWidth(), img.getHeight());
	Dimension thumbnailSize = new Dimension(width, height);
	Resizer resizer =
		DefaultResizerFactory.getInstance()
				.getResizer(imgSize, thumbnailSize);
	
	BufferedImage thumbnailImage =
		new FixedSizeThumbnailMaker(width, height, true, true)
				.resizer(resizer)
				.make(img);
	
	return thumbnailImage;
}
 
开发者ID:farhan,项目名称:Android-Image-Resizer-Module,代码行数:45,代码来源:Thumbnailator.java


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