1 / 8

多 媒 體 安 全

多 媒 體 安 全. ImageJ BouncingBar. 指導教授 : 黃文楨 班級 : 企電所 1A 學號 : 9722811 姓名 : 王嘉苑. BouncingBar. 主要功能 :  產生一張有框的圖片,這個圖片內會產生顏色漸層出現的 bar ,然後將這個 bar 設定只會出現在框內。. 程式解釋. width = 600; 設定 image 的寬 height = 200; 設定 image 的長

hanley
Download Presentation

多 媒 體 安 全

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 多 媒 體 安 全 ImageJ BouncingBar 指導教授:黃文楨 班級: 企電所1A 學號: 9722811 姓名: 王嘉苑

  2. BouncingBar 主要功能:  產生一張有框的圖片,這個圖片內會產生顏色漸層出現的bar,然後將這個bar設定只會出現在框內。

  3. 程式解釋 • width = 600;設定image的寬 • height = 200; 設定image的長 • newImage(“Untitled”, “RGB”, width, height, 1);產生一張新的圖片,如果沒有設定“RGB” 就會顯示“8-bit”灰階的圖片 • lw = width/15; 設定bar的寬度 • lw2 = lw/2; 設定框與圖的間距

  4. snapshot(); create a backup image that can be restored later. • autoUpdate(false); disable automatic display updates. • x1=0.2*width; y1=0.5*height; x2=0.8*width; y2=y1;設定x1,y1,x2,y2的初始值,為bar的座標 • inc=2; x1inc=0.5*inc; y1inc=-inc; x2inc=-inc; y2inc=0.5*inc; x1inc,y1inc,x2inc,y2inx這邊變數將會跟x1,y1,x2,y2想加減來改變bar出現的位置 • rinc=1; binc=1; ginc=0.5; 這些變數將會跟r.g.b相加減產生不同的顏色 • r=255; g=0; b=0; 設定r.g.b的初始值

  5. while (true) { 開始無線迴圈 • x1+=x1inc; x1=120,x1inc=1 Value=120,121,122,~579,578,577,~21,22~23~579 • y1+=y1inc; y1=100,y1inc=-2 Value=100,98,96,~~22, 24,26,~~178,176,174~22 • x2+=x2inc; x2=480,x2inc=-2 • Value=480,478,476,~~22, 24,26,~~578,576,574~22 • y2+=y2inc; y2=100,y2inc=1 • Value=100,101,~~179,178,177,~ 21,22,23~179

  6. 設定x1,y1,x2,y2於x=20~580,y=20~180 • if (x1<=lw2 || x1>=width-lw2) x1inc=-x1inc; 把x1介於x座標20~580之間 • if (y1<=lw2 || y1>=height-lw2) y1inc=-y1inc; 把y1介於y座標20~180之間 • if (x2<=lw2 || x2>=width-lw2) x2inc=-x2inc; 把x2介於x座標20~580之間 • if (y2<=lw2 || y2>=height-lw2) y2inc=-y2inc;把y2介於y座標20~180之間

  7. 設定r.g.b的值 • r-=rinc; g+=ginc; b+=binc; • if (r<=0||r>=255) rinc=-rinc; 從254一直減到0在從0增加到254 • if (g<=0||g>=255) ginc=-ginc; 從1一直增加到254在從254減少到1 • if (b<=0||b>=255) binc=-binc; 從0.5一直增加到254在從254減少到0.5

  8. reset(); restore the backup image • setColor(r,g,b); bar's color • setLineWidth(lw); bar's width • drawLine(x1,y1,x2,y2);draw a bar • updateDisplay(); update the image • } 如果沒有設定reset()將產生以上這張圖

More Related