4̓Jbg摜ۑ.
13 {
14 int cpuGraph = 0;
15 int lx = 0, rx = 0, ty = 0, by = 0;
16 int w, h;
17 int a;
18
19 cpuGraph = LoadARGB8ColorSoftImage(_pass.c_str());
20
21 if (cpuGraph == -1)
22 {
23 return cpuGraph;
24 }
25
26 GetSoftImageSize(cpuGraph, &w, &h);
27
28 bool isBreak = false;
29
30 for (int i = 0; i < w; i++)
31 {
32 for (int j = 0; j < h; j++)
33 {
34 GetPixelSoftImage(cpuGraph, i, j, NULL, NULL, NULL, &a);
35
36 if (a > 0)
37 {
38 lx = i;
39 isBreak = true;
40 break;
41 }
42 }
43
44 if (isBreak)
45 {
46 break;
47 }
48 }
49
50 isBreak = false;
51
52 for (int j = 0; j < h; j++)
53 {
54 for (int i = lx; i < w; i++)
55 {
56 GetPixelSoftImage(cpuGraph, i, j, NULL, NULL, NULL, &a);
57
58 if (a > 0)
59 {
60 ty = j;
61 isBreak = true;
62 break;
63
64 }
65 }
66 if (isBreak)
67 {
68 break;
69 }
70 }
71
72 isBreak = false;
73
74 for (int i = w - 1; i > lx; i--)
75 {
76 for (int j = h - 1; j > ty; j--)
77 {
78 GetPixelSoftImage(cpuGraph, i, j, NULL, NULL, NULL, &a);
79
80 if (a > 0)
81 {
82 rx = i;
83 isBreak = true;
84 break;
85
86 }
87 }
88
89 if (isBreak)
90 {
91 break;
92 }
93 }
94
95 isBreak = false;
96
97 for (int j = h - 1; j > ty; j--)
98 {
99 for (int i = w - 1; i > lx; i--)
100 {
101 GetPixelSoftImage(cpuGraph, i, j, NULL, NULL, NULL, &a);
102
103 if (a > 0)
104 {
105 by = j;
106 isBreak = true;
107 break;
108
109 }
110 }
111
112 if (isBreak)
113 {
114 break;
115 }
116 }
117
118 int cpuGraph2 = MakeARGB8ColorSoftImage(rx - lx, by - ty);
119 BltSoftImage(lx, ty, rx, by, cpuGraph, 0, 0, cpuGraph2);
120
121 int img = CreateGraphFromSoftImage(cpuGraph2);
122
123 DeleteSoftImage(cpuGraph);
124 DeleteSoftImage(cpuGraph2);
125
126 return img;
127
128 }