วันพฤหัสบดีที่ 4 มิถุนายน พ.ศ. 2558

How to convert JLabel.getIcon() to BufferedImage แปลงรูปภาพไฟล์ JLabel.getIcon() เป็น BufferedImage ในภาษา Java

How to convert JLabel.getIcon() to BufferedImage แปลงรูปภาพไฟล์ JLabel.getIcon() เป็น BufferedImage ในภาษา Java
ในภาษาJava มีหลายวิธีในการแปลงรูปแบบเอกสาร หรือรูปภาพ เพื่อความสะดวกในการจัดเก็บ หรือนำไปใช้งานในด้านอื่นๆ
วีธีการแปลงจากIcon  เป็นBufferedImage  และGraphics

// Get the icon
Icon ico = label1.getIcon();

// Create a buffered image
BufferedImage bimg = new BufferedImage(ico.getIconWidth(), ico.getIconHeight(),BufferedImage.TYPE_INT_RGB);

// Create the graphics context
Graphics g = bimg.createGraphics();

// Now paint the icon
ico.paintIcon(null, g, 0, 0);
g.dispose();

ติดตามกันต่อ...

https://twitter.com/Cavaji

https://plus.google.com


ขอบใจทุกคนที่เข้ามาอ่าน น่ะครับ By Cavaji

แหล่งที่มา : How to convert JLabel.getIcon() to BufferedImage

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

หมายเหตุ: มีเพียงสมาชิกของบล็อกนี้เท่านั้นที่สามารถแสดงความคิดเห็น