Re: [問題] 讀含透明通道的PNG圖檔
※ 引述《oopsy (歐普西)》之銘言:
: 請問板上各位先進
: 要如何讀含有alpha channel的PNG圖檔呢?
: 目前是使用imageIO
: 以下為部份程式碼
: String Filename = "alpaca.png";
: File file = new File(Filename); //由路徑得到file
: Image image = javax.imageio.ImageIO.read(file);
: int width = image.getWidth(null);
: int height = image.getHeight(null);
: BufferedImage ProcessImage
: = new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
: 這樣alpha channel的值還是0
: 請問哪裡錯了嗎?
: 煩請知道的先進回答 謝謝:)
: java新手請多包涵
javax.imageio.ImageIO.read(File) method 會傳回 java.awt.image.BufferedImage
object,你可以從這個 object 獲得你想要的資訊。
上面這段碼中從檔案讀進數據並產生 BufferedImage 後沒有被程式使用到,反而再
建構一個 BufferedImage(空的)。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.217.210.69
推
10/30 11:17, , 1F
10/30 11:17, 1F
推
10/30 11:56, , 2F
10/30 11:56, 2F
推
11/01 07:34, , 3F
11/01 07:34, 3F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):