700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > java解析webp格式图片宽高;java解析webp图片转png格式

java解析webp格式图片宽高;java解析webp图片转png格式

时间:2022-06-20 13:08:36

相关推荐

java解析webp格式图片宽高;java解析webp图片转png格式

java解析webp格式图片宽高;java解析webp图片转png格式

package 你的包名:***.***.***.***;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;/*** 图片处理工具类*/public class ImageUtils {/*** 解析webp格式图片宽高** @param inputStream IO输入流*/public static ImageBean webpToPng(InputStream inputStream) throws IOException {byte[] bytes = new byte[30];inputStream.read(bytes, 0, bytes.length);int width = ((int) bytes[27] & 0xff) << 8 | ((int) bytes[26] & 0xff);int height = ((int) bytes[29] & 0xff) << 8 | ((int) bytes[28] & 0xff);ImageBean imageBean = new ImageBean();imageBean.setWidth(width);imageBean.setHeight(height);return imageBean;}/*** 图片对象*/public static class ImageBean {private Integer width;//宽度private Integer height;//高度public Integer getWidth() {return width;}public void setWidth(Integer width) {this.width = width;}public Integer getHeight() {return height;}public void setHeight(Integer height) {this.height = height;}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。