import processing.video.*; import krister.Ess.*; Capture myCapture; PFont font; PImage Img,Pic,Bg,savePic; color All[][]; int b_n,p_n; boolean f,g,aaa; int num; AudioChannel myChannel; void setup() { size(400, 270); All = new color[width][height]; font = createFont("MINGLIU",20, false); b_n=p_n=0; num=1; myCapture = new Capture(this,400, 240,12); Img = new PImage(320,240); f=false; g=false; penbegin(); Ess.start(this); myChannel = new AudioChannel("camera.wav"); displayAll(); } void captureEvent(Capture myCapture) { myCapture.read(); Img = myCapture.get(); } void draw() { background(0); if (f) { showprint(); displayButton(); if (p_n>0 && p_n<8) addpic(); pendraw(); } else image(Img,0,0); if (g) { textFont(font, 50); fill(255,0,0); text("儲存成功", 100, 150); delay(3000); quit(); } displayText(); } void keyPressed() { if (key=='p'|| key=='P') { if (!f){ myChannel.play(); delay(100); save("/data/pic.jpg"); printall(); f=true; } } if (key=='s') { if(f){ //savepic(); g=true; }else{ save("/data/pic.jpg"); Pic=loadImage("pic.jpg"); } savepic(); } if (key=='q') { quit(); } } void displayText() { textFont(font, 12); fill(255); textFont(font, 14); text("P:拍照", 70, 260); text("S:存檔", 170, 260); text("Q:離開", 270, 260); } void bgpic(){ if (b_n==1) Bg=loadImage("bg1.gif"); if (b_n==2) Bg=loadImage("bg2.gif"); if (b_n==3) Bg=loadImage("bg3.gif"); if (b_n==4) Bg=loadImage("bg4.gif"); if (b_n==5) Bg=loadImage("bg5.gif"); if (b_n==6) Bg=loadImage("bg6.gif"); if (b_n==7) Bg=loadImage("bg7.gif"); Pic = loadImage("pic.jpg"); for (int i=0 ; i40 && mouseX<361 && mouseY <241){ if (p_n==1) image(b01,mouseX-20,mouseY-17); if (p_n==2) image(b02,mouseX-20,mouseY-17); if (p_n==3) image(b03,mouseX-20,mouseY-17); if (p_n==4) image(b04,mouseX-20,mouseY-17); if (p_n==5) image(b05,mouseX-20,mouseY-17); if (p_n==6) image(b06,mouseX-20,mouseY-17); if (p_n==7) image(b07,mouseX-20,mouseY-17); } } void printall() { loadPixels(); for (int i=0 ; i