Java:保存上传的png图像
当我保存用户上传的 png 文件时遇到问题。它失去了透明度。这是我保存它的方法。
ServletFileUpload upload = new ServletFileUpload(factory);
ProgressListenerImpl listener = new ProgressListenerImpl();
UploadProgressBar uop = new UploadProgressBar(listener);
List<FileItem> fileItemsList = upload.parseRequest(request);
for(FileItem fi : fileItemsList) {
///get name etc.
File fNew= new File(fileLocation, justName);
fi.write(fNew);
}
它设置了黑色背景。还有其他方法可以将其另存为 png 吗?
I am having issue when i save a png file uploaded by user . It loses its transparency . Here is how I save it .
ServletFileUpload upload = new ServletFileUpload(factory);
ProgressListenerImpl listener = new ProgressListenerImpl();
UploadProgressBar uop = new UploadProgressBar(listener);
List<FileItem> fileItemsList = upload.parseRequest(request);
for(FileItem fi : fileItemsList) {
///get name etc.
File fNew= new File(fileLocation, justName);
fi.write(fNew);
}
it puts a black background . Any other way to save it as png ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您要在服务器端创建 BufferedImage,请确保将其创建为支持 alpha 通道的类型,例如
Paul
If you're creating a BufferedImage on the server side, make sure you create it as a type that supports the alpha channel, e.g.
Paul