//Dwindow examples for final examination! import - TopicsExpress



          

//Dwindow examples for final examination! import jlab.graphics.DWindow; import java.util.Scanner; public class TestDwindow { public static void main(String[] args) { DWindow ww = new DWindow(); DWindow w = new DWindow(); DWindow www = new DWindow(); DWindow wwww = new DWindow(); ww.loadImage(C:/Users/Administrator/Desktop/10615578_738563822859617_6558969740757888090_n.jpg); w.loadImage(C:/Users/Administrator/Desktop/10615578_738563822859617_6558969740757888090_n.jpg); loadImage(C:/Users/Administrator/Desktop/10615578_738563822859617_6558969740757888090_n.jpg); wloadImage(C:/Users/Administrator/Desktop/10615578_738563822859617_6558969740757888090_n.jpg); int[][] p = w.getPixmap(); w.setPixmap(gray(p)); int[][] ppp = getPixmap(); flipHorizontal(ppp); setPixmap(ppp); int[][] pppp = wgetPixmap(); wsetPixmap(flip(pppp)); } public static int[][] gray(int[][] p) { for (int x = 0; x < p.length; x++) { for (int y = 0; y < p[0].length; y++) { int r = DWindow.getR(p[x][y]); int g = DWindow.getG(p[x][y]); int b = DWindow.getB(p[x][y]); int gray = (r + g + b) / 3; p[x][y] = DWindow.mixRGB(gray, gray, gray); } } return p; } public static void flipHorizontal(int [][] ppp) { int width = ppp.length, height = ppp[0].length; for (int x = 0; x < width / 2; x++) { for (int y = 0; y < height; y++) { int t = ppp[x][y]; ppp[x][y] = ppp[width - x - 1][y]; ppp[width - x - 1][y] = t; } } } public static int[][] flip(int [][] pppp) { int height = pppp.length, width = pppp[0].length; int[][] a=new int [width][height]; for (int x = 0; x < height; x++) { for (int y = 0; y < width; y++) { a[y][x] = pppp[x][y]; } } return a; } }
Posted on: Tue, 25 Nov 2014 03:03:56 +0000

Trending Topics



Recently Viewed Topics




© 2015