我想将图像保存在磁盘上,例如c:/ images,这是使用java ..捕获的网络摄像头,并且我想在JForm上将该图像显示为标签... 这是可能的使用Java和NetBeans 我在Java如何使用java将磁盘上的图像保存到磁盘上的文件夹
1
A
回答
1
可以保存图像
private static void save(BufferedImage image, String ext) {
File file = new File(fileName + "." + ext);
BufferedImage image = toBufferedImage(file);
try {
ImageIO.write(image, ext, file); // ignore returned boolean
} catch(IOException e) {
System.out.println("Write error for " + file.getPath() +
": " + e.getMessage());
}
}
,并从磁盘读取图像,并显示到标签为
File file = new File("image.gif");
image = ImageIO.read(file);
JFrame frame = new JFrame();
JLabel label = new JLabel(new ImageIcon(image));
frame.getContentPane().add(label, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
1
您可以使用BufferedImage中从硬盘加载图像新:
BufferedImage img = null;
try {
img = ImageIO.read(new File("strawberry.jpg"));
} catch (IOException e) {
}
尝试此链接以获取更多信息。 Reading/Loading Images in Java
而这一个用于保存图像。 Writing/Saving an Image
try {
// retrieve image
BufferedImage bi = getMyImage();
File outputfile = new File("saved.png");
ImageIO.write(bi, "png", outputfile);
} catch (IOException e) {
...
}
-1
//Start Photo Upload with No//
if (simpleLoanDto.getPic() != null && simpleLoanDto.getAdharNo() != null) {
String ServerDirPath = globalVeriables.getAPath() + "\\";
File ServerDir = new File(ServerDirPath);
if (!ServerDir.exists()) {
ServerDir.mkdirs();
}
// Giving File operation permission for LINUX//
IOperation.setFileFolderPermission(ServerDirPath);
MultipartFile originalPic = simpleLoanDto.getPic();
byte[] ImageInByte = originalPic.getBytes();
FileOutputStream fosFor = new FileOutputStream(
new File(ServerDirPath + "\\" + simpleLoanDto.getAdharNo() + "_"+simpleLoanDto.getApplicantName()+"_.jpg"));
fosFor.write(ImageInByte);
fosFor.close();
}
//End Photo Upload with No//
相关问题
- 1. 如何将图像保存到磁盘
- 2. 用WinJS将图像保存到磁盘
- 3. Carrierwave不保存磁盘上的文件
- 4. X509Certificate.Import磁盘上的文件夹文件
- 5. Java保存资源文件夹到磁盘文件夹
- 6. 在磁盘上保存文件
- 7. Chrome扩展程序:如何将文件保存到磁盘上
- 8. 如何将NSImageView图层保存到磁盘上的PNG?
- 9. UWP将zip文件保存到磁盘
- 10. 提示将文件保存到磁盘
- 11. 将trie保存到磁盘
- 12. 将nsdate保存到磁盘
- 13. 将DynamicMethod保存到磁盘
- 14. Flex:将多个图像拖入一个文件夹并保存在磁盘上
- 15. BLOB保存到磁盘图像C#
- 16. 将上传的文件保存在磁盘上,ubuntu路径
- 17. 如何将IFormFile保存到磁盘?
- 18. 如何将ImageCache保存到磁盘中?
- 19. 如何使用python将XML文件保存到磁盘?
- 20. 如何将所有文件和目录从磁盘移动到该磁盘上的文件夹?
- 21. 列表保存到磁盘上
- 22. 如何将WPF图像资源的文件夹写入磁盘?
- 23. 如何将图像存储到Java中的磁盘?
- 24. 使用MailKit将消息写入磁盘上的文件夹
- 25. JavaMail将邮件导出到磁盘上定义的文件夹
- 26. 将图像缓存到磁盘
- 27. iphone - 将图像存储到磁盘
- 28. 使用javascript将图像保存到用户磁盘
- 29. Office API,将邮件保存到磁盘
- 30. 将Outlook附件保存到磁盘
听起来好像要*负载*图像从磁盘。顺便说一句,你在这里使用的是哪个版本的netbeans-7? – aioobe
是的,这是可能的。 :) –
使用此链接[阅读/用Java加载图像](http://docs.oracle.com/javase/tutorial/2d/images/loadimage.html) –