请问ImageIO.write(image, "bmg", filWriterOne);括号里的三个参数分别代表说明意思?
![](https://profile-avatar.csdnimg.cn/9c82f3718c4946ea9c537d38424856e9_qq_61832536.jpg!4)
java中ImageIO.write()参数含义
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- kkjt0130 2022-05-10 16:40关注
image:图片对象
"bmg" :图片格式
, filWriterOne 需要写入的地方
源码中有三个方法/** * Writes an image using the an arbitrary <code>ImageWriter</code> * that supports the given format to an * <code>ImageOutputStream</code>. The image is written to the * <code>ImageOutputStream</code> starting at the current stream * pointer, overwriting existing stream data from that point * forward, if present. * * <p> This method <em>does not</em> close the provided * <code>ImageOutputStream</code> after the write operation has completed; * it is the responsibility of the caller to close the stream, if desired. * * @param im a <code>RenderedImage</code> to be written. * @param formatName a <code>String</code> containing the informal * name of the format. * @param output an <code>ImageOutputStream</code> to be written to. * * @return <code>false</code> if no appropriate writer is found. * * @exception IllegalArgumentException if any parameter is * <code>null</code>. * @exception IOException if an error occurs during writing. */ public static boolean write(RenderedImage im, String formatName, ImageOutputStream output) throws IOException { if (im == null) { throw new IllegalArgumentException("im == null!"); } if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } if (output == null) { throw new IllegalArgumentException("output == null!"); } return doWrite(im, getWriter(im, formatName), output); } /** * Writes an image using an arbitrary <code>ImageWriter</code> * that supports the given format to a <code>File</code>. If * there is already a <code>File</code> present, its contents are * discarded. * * @param im a <code>RenderedImage</code> to be written. * @param formatName a <code>String</code> containing the informal * name of the format. * @param output a <code>File</code> to be written to. * * @return <code>false</code> if no appropriate writer is found. * * @exception IllegalArgumentException if any parameter is * <code>null</code>. * @exception IOException if an error occurs during writing. */ public static boolean write(RenderedImage im, String formatName, File output) throws IOException { if (output == null) { throw new IllegalArgumentException("output == null!"); } ImageOutputStream stream = null; ImageWriter writer = getWriter(im, formatName); if (writer == null) { /* Do not make changes in the file system if we have * no appropriate writer. */ return false; } try { output.delete(); stream = createImageOutputStream(output); } catch (IOException e) { throw new IIOException("Can't create output stream!", e); } try { return doWrite(im, writer, stream); } finally { stream.close(); } } /** * Writes an image using an arbitrary <code>ImageWriter</code> * that supports the given format to an <code>OutputStream</code>. * * <p> This method <em>does not</em> close the provided * <code>OutputStream</code> after the write operation has completed; * it is the responsibility of the caller to close the stream, if desired. * * <p> The current cache settings from <code>getUseCache</code>and * <code>getCacheDirectory</code> will be used to control caching. * * @param im a <code>RenderedImage</code> to be written. * @param formatName a <code>String</code> containing the informal * name of the format. * @param output an <code>OutputStream</code> to be written to. * * @return <code>false</code> if no appropriate writer is found. * * @exception IllegalArgumentException if any parameter is * <code>null</code>. * @exception IOException if an error occurs during writing. */ public static boolean write(RenderedImage im, String formatName, OutputStream output) throws IOException { if (output == null) { throw new IllegalArgumentException("output == null!"); } ImageOutputStream stream = null; try { stream = createImageOutputStream(output); } catch (IOException e) { throw new IIOException("Can't create output stream!", e); } try { return doWrite(im, getWriter(im, formatName), stream); } finally { stream.close(); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 3无用 1
悬赏问题
- ¥15 关于arduino编程toCharArray()函数的使用
- ¥100 vc++混合CEF采用CLR方式编译报错
- ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
- ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
- ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
- ¥50 如何openEuler 22.03上安装配置drbd
- ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
- ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
- ¥15 Windows11, backspace, enter, space键失灵
- ¥15 cfx离心泵非稳态计算