第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

請問sun.awt.image.ToolkitImage@73486eef該怎么轉(zhuǎn)換為圖片?

請問sun.awt.image.ToolkitImage@73486eef該怎么轉(zhuǎn)換為圖片?

德瑪西亞99 2019-05-23 11:50:58
img=Toolkit.getDefaultToolkit().createImage(xp.asBytes());System.out.println("圖片:"+img);結(jié)果為圖片:sun.awt.image.ToolkitImage@73486eef這樣的該怎么轉(zhuǎn)換為圖片?
查看完整描述

2 回答

?
三國紛爭

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊

publicstaticBufferedImagetoBufferedImage(Imageimage){
if(imageinstanceofBufferedImage){
return(BufferedImage)image;
}
image=newImageIcon(image).getImage();
BufferedImagebimage=null;
GraphicsEnvironmentge=GraphicsEnvironment.getLocalGraphicsEnvironment();
try{
inttransparency=Transparency.OPAQUE;
GraphicsDevicegs=ge.getDefaultScreenDevice();
GraphicsConfigurationgc=gs.getDefaultConfiguration();
bimage=gc.createCompatibleImage(
image.getWidth(null),image.getHeight(null),transparency);
}catch(HeadlessExceptione){
}
if(bimage==null){
inttype=BufferedImage.TYPE_INT_RGB;
bimage=newBufferedImage(image.getWidth(null),image.getHeight(null),type);
}
Graphicsg=bimage.createGraphics();
g.drawImage(image,0,0,null);
g.dispose();
returnbimage;
}
Imageimage=Toolkit.getDefaultToolkit().createImage(byte[]bytes);
BufferedImagebufferedImage=toBufferedImage(image);
try{
ImageIO.write(bufferedImage,"JPG",newFile("路徑"));
}catch(IOExceptione){
e.printStackTrace();
}
                            
查看完整回答
反對 回復(fù) 2019-05-23
?
MM們

TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊

輸出到控制臺當(dāng)然是只能顯示為文本(調(diào)用對象的toString()方法并將其輸出),如果需要顯示Image,考慮使用Swing中JLabel這樣的組件。
img=Toolkit.getDefaultToolkit().createImage(xp.asBytes());
JLabellblImg=newJLabel(newImageIcon(img));
//...將JLabel加入到JFrame,并將JFrame顯示的代碼
                            
查看完整回答
反對 回復(fù) 2019-05-23
  • 2 回答
  • 0 關(guān)注
  • 360 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號