venus585625 发表于 2013-2-7 00:54:04

水平镜像

来自:http://bbs.eyuyan.com/read.php?tid=67694   
1. public static Image verticalMirror(Image img) {   
   2.   
   3.   int[] rgbOutput = null;   
   4.   int[] rgbInput = null;   
   5.   int width = 0, height = 0;   
   6.   int[][] tempArr = null;   
   7.   try {   
   8.         width = img.getWidth();   
   9.         height = img.getHeight();   
10.         rgbInput = new int;   
11.         rgbOutput = new int;   
12.         img.getRGB(rgbInput, 0, width, 0, 0, width, height);   
13.         int i, j, k;   
14.         k = 0;   
15.         tempArr = new int;   
16.   
17.         for (i = 0; i < height; i++) {   
18.             for (j = 0; j < width; j++) {   
19.               tempArr = rgbInput;   
20.             }   
21.         }   
22.         rgbInput = null; // 显式地设置为空值,告诉系统可以垃圾回收   
23.         int[][] tempArr1 = new int;   
24.         for (i = 0; i < height; i++) {   
25.             for (j = 0; j < width; j++) {   
26.               tempArr1 = tempArr;   
27.             }   
28.         }   
29.         tempArr = null; // 显式地设置为空值,告诉系统可以垃圾回收   
30.         k = 0;   
31.         for (i = 0; i < height; i++) {   
32.             for (j = 0; j < width; j++) {   
33.               rgbOutput = tempArr1;   
34.               k++;   
35.   
36.             }   
37.         }   
38.         tempArr1 = null; // 显式地设置为空值,告诉系统可以垃圾回收   
39.         // return img;   
40.         return Image.createRGBImage(rgbOutput, width, height, true);   
41.   } catch (OutOfMemoryError e) {   
42.         // e.printStackTrace();   
43.         ImageAlbum.showAlert("图像尺寸太大,不能完成此操作.");   
44.         return img;   
45.   } finally {   
46.         rgbOutput = null;   
47.   }   
48.   
49. }   
50.   
51. /***************************************************************************** 水平镜像的方法*/
52. public static Image horizontalMirror(Image img) {   
53.   
54.   int[] rgbOutput = null;   
55.   int[] rgbInput = null;   
56.   int width = 0, height = 0;   
57.   int[][] tempArr = null;   
58.   int[][] tempArr1 = null;   
59.   try {   
60.         width = img.getWidth();   
61.         height = img.getHeight();   
62.         rgbInput = new int;   
63.         rgbOutput = new int;   
64.         img.getRGB(rgbInput, 0, width, 0, 0, width, height);   
65.         int i, j, k;   
66.         k = 0;   
67.         tempArr = new int;   
68.   
69.         for (i = 0; i < height; i++) {   
70.             for (j = 0; j < width; j++) {   
71.               tempArr = rgbInput;   
72.             }   
73.         }   
74.         rgbInput = null; // 显式地设置为空值,告诉系统可以垃圾回收   
75.         tempArr1 = new int;   
76.         for (i = 0; i < height; i++) {   
77.             for (j = 0; j < width; j++) {   
78.               tempArr1 = tempArr;   
79.             }   
80.         }   
81.         tempArr = null; // 显式地设置为空值,告诉系统可以垃圾回收   
82.         k = 0;   
83.         for (i = 0; i < height; i++) {   
84.             for (j = 0; j < width; j++) {   
85.               rgbOutput = tempArr1;   
86.               k++;   
87.   
88.             }   
89.         }   
90.         tempArr1 = null; // 显式地设置为空值,告诉系统可以垃圾回收   
91.         return Image.createRGBImage(rgbOutput, width, height, true);   
92.   } catch (OutOfMemoryError e) {   
93.         // e.printStackTrace();   
94.         ImageAlbum.showAlert("图像尺寸太大,不能完成此操作.");   
95.         return img;   
96.   } finally {   
97.         rgbOutput = null;   
98.   }   
99.   
100. }
页: [1]
查看完整版本: 水平镜像