本文整理匯總了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)
);
}