本文整理汇总了Java中net.coobird.thumbnailator.tasks.io.FileImageSource类的典型用法代码示例。如果您正苦于以下问题:Java FileImageSource类的具体用法?Java FileImageSource怎么用?Java FileImageSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileImageSource类属于net.coobird.thumbnailator.tasks.io包,在下文中一共展示了FileImageSource类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterator
import net.coobird.thumbnailator.tasks.io.FileImageSource; //导入依赖的package包/类
public Iterator<ImageSource<File>> iterator()
{
return new Iterator<ImageSource<File>>() {
Iterator<String> iter = filenames.iterator();
public boolean hasNext()
{
return iter.hasNext();
}
public ImageSource<File> next()
{
return new FileImageSource(iter.next());
}
public void remove()
{
throw new UnsupportedOperationException();
}
};
}
示例2: task_ChangeOutputFormat_File_OutputStream
import net.coobird.thumbnailator.tasks.io.FileImageSource; //导入依赖的package包/类
@Test
public void task_ChangeOutputFormat_File_OutputStream() throws IOException
{
// given
ThumbnailParameter param =
new ThumbnailParameterBuilder().size(50, 50).format("jpg").build();
ByteArrayOutputStream os = new ByteArrayOutputStream();
FileImageSource source = new FileImageSource("src/test/resources/Thumbnailator/grid.bmp");
OutputStreamImageSink destination = new OutputStreamImageSink(os);
// when
Thumbnailator.createThumbnail(
new SourceSinkThumbnailTask<File, OutputStream>(param, source, destination)
);
// then
ByteArrayInputStream destIs = new ByteArrayInputStream(os.toByteArray());
BufferedImage thumbnail = ImageIO.read(destIs);
assertEquals(50, thumbnail.getWidth());
assertEquals(50, thumbnail.getHeight());
destIs = new ByteArrayInputStream(os.toByteArray());
String formatName = TestUtils.getFormatName(destIs);
assertEquals("JPEG", formatName);
}
示例3: FileThumbnailTask
import net.coobird.thumbnailator.tasks.io.FileImageSource; //导入依赖的package包/类
/**
* Creates a {@link ThumbnailTask} in which image data is read from the
* specified {@link File} and is output to a specified {@link File}, using
* the parameters provided in the specified {@link ThumbnailParameter}.
*
* @param param The parameters to use to create the thumbnail.
* @param sourceFile The {@link File} from which image data is read.
* @param destinationFile The {@link File} to which thumbnail is written.
* @throws NullPointerException If the parameter is {@code null}.
*/
public FileThumbnailTask(ThumbnailParameter param, File sourceFile, File destinationFile)
{
super(param);
this.task = new SourceSinkThumbnailTask<File, File>(
param,
new FileImageSource(sourceFile),
new FileImageSink(destinationFile)
);
}