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

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

圖像始終是第一楨。為什么,這是為什么?

圖像始終是第一楨。為什么,這是為什么?

/*以下代碼用于連續(xù)捕獲桌面,但是用setRGB()更新之后,再重繪窗口,沒有什么反應(yīng)。*/import java.awt.*;import java.awt.image.BufferedImage;public class Image extends Frame {static BufferedImage im;public static void main(String[] args){ int i;Image image=new Image(800,600);im=image.capSc();//獲取第一楨BufferedImage temp;for(i=0;i<1000;i++){temp=image.capSc();//捕獲桌面圖像image.getdata(temp);//與原圖像逐相素對比更新image.repaint();//重繪}}public void getdata(BufferedImage temp){int i,j,height,width,pix;width=temp.getWidth();height=temp.getHeight();for(i=0;i<width-1;i+=2)for(j=0;j<height-1;j+=2){ pix=temp.getRGB(i,j);if(pix!=im.getRGB(i,j))//每個相素進行比較如果不等{im.setRGB(i,j,pix);//則更新為現(xiàn)在的像素值。}}}public BufferedImage capSc()//這個函數(shù)可略過不看,捕獲桌面,并返回圖像{ BufferedImage image=null;try{Robot robot=new Robot();Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();Rectangle screenRectangle = new Rectangle(screenSize);image = robot.createScreenCapture(screenRectangle);return image;} catch(Exception exe){exe.printStackTrace();}return image;}public Image(int width,int height){setSize(width,height);setVisible(true);}public void paint(Graphics g){g.drawImage(im,0,0,800,600,this);}}
查看完整描述

1 回答

?
慕蓋茨4494581

TA貢獻1850條經(jīng)驗 獲得超11個贊

不會啊,我試了一下圖像是變化的,不過下邊這段代碼沒太懂,為什么i和j要遞增2呢?遞增1的話感覺效果更有趣一些:)
for(i=0;i<width-1;i+=2)
for(j=0;j<height-1;j+=2)
{ pix=temp.getRGB(i,j);
if(pix!=im.getRGB(i,j))//每個相素進行比較如果不等
{im.setRGB(i,j,pix);//則更新為現(xiàn)在的像素值。
}
}

查看完整回答
反對 回復(fù) 2022-10-16
  • 1 回答
  • 0 關(guān)注
  • 146 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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