Re: [問題] 請問PIXEL繪圖的METHOD
※ 引述《mussinaa (rea)》之銘言:
: 請問
: 給定座標和顏色之後
: 在該座標上繪出該顏色的METHOD
: 我查了很久都查不到
: 謝謝各位
有幾個方法
1.用Graphics直接畫
先setColor(Color);
再用fillOval(int x,int y,int width,int height);
但我覺得不是好方法
2.用Component來createImage(int width,int height);來得到Image
再用以下這個Method來得到BufferedImage
public BufferedImage convert(Image im)
{
BufferedImage bi = new
BufferedImage(im.getWidth(null),im.getHeight(null),BufferedImage.TYPE_INT_RGB);
Graphics bg = bi.getGraphics();
bg.drawImage(im, 0, 0, null);
bg.dispose();
return bi;
}
接著直接在BufferdImage上操作吧
BufferedImage有setRGB(int x,int y,int rgb);
相信你應該會了解怎麼用
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.105.36
討論串 (同標題文章)