java命名空间javax.imageio类imagewriter的类成员方法:
preparewriteempty定义及介绍
本文导语:
preparewriteempty
public void preparewriteempty(iiometadata streammetadata,
imagetypespecifier imagetype,
int width,
int height,
iiometadata imagemetadata,
...
preparewriteempty
public void preparewriteempty(iiometadata streammetadata,
imagetypespecifier imagetype,
int width,
int height,
iiometadata imagemetadata,
list extends bufferedimage> thumbnails,
imagewriteparam param)
throws ioexception
- 从写入完整图像流开始,该图像流由带有要输出的不确定像素值、有关元数据和缩略图的单个图像组成。像素值可通过以后调用
replacepixels 方法来确定。如果输出是一个 imageoutputstream,则位于当前寻找位置之前的现有内容不受影响,并且这些内容不必是可读或可写的。
直到调用 endwriteempty 才完成写入操作。调用 preparereplacepixels、replacepixels 和 endreplacepixels 可能发生在调用 preparewriteempty 和 endwriteempty 之间。不过,调用 preparewriteempty 是不可嵌套的,调用 preparewriteempty 和 prepareinsertempty 不能被散置。
如果 canwriteempty 返回 false,则将抛出 unsupportedoperationexception。
可以有选择地提供 imagewriteparam 来控制写入过程。如果 param 为 null,则将使用默认 write 参数。
如果所提供的 imagewriteparam 包含不受此 writer 支持的可选设置值(例如 逐步编码或任何特定于格式的设置),则将忽略这些设置。
如果输出为 null,则默认实现抛出 illegalstateexception,否则抛出 unsupportedoperationexception。
- 参数:
streammetadata - 表示流元数据的 iiometadata 对象;或者为 null,表示使用默认值。imagetype - 描述图像布局的 imagetypespecifier。width - 图像的宽度。height - 图像的高度。imagemetadata - 表示图像元数据的 iiometadata 对象,或者为 null。thumbnails - 此图像的 bufferedimage 缩略图的 list,或者为 null。param - 一个 imagewriteparam,或者为 null,表示使用默认 imagewriteparam。
- 抛出:
illegalstateexception - 如果尚未设置输出。
unsupportedoperationexception - 如果 canwriteempty 返回 false。
illegalstateexception - 如果以前已经调用 preparewriteempty,但没有相应地调用 endwriteempty。
illegalstateexception - 如果以前已经调用 prepareinsertempty,但没有相应地调用 endinsertempty。
illegalargumentexception - 如果 imagetype 为 null,或者 thumbnails 包含 null 引用或对象,而不是 bufferedimage。
illegalargumentexception - 如果宽度或高度小于 1。
ioexception - 如果在写期间发生 i/o 错误。