Skip to content
This repository was archived by the owner on Aug 1, 2020. It is now read-only.

Commit 3d08f08

Browse files
committed
first commit
1 parent 68fb8ca commit 3d08f08

15 files changed

+660
-0
lines changed

.classpath

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>image blur</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

bin/Load$1.class

697 Bytes
Binary file not shown.

bin/Load$2.class

1.29 KB
Binary file not shown.

bin/Load$3.class

1.29 KB
Binary file not shown.

bin/Load$Loader.class

1.63 KB
Binary file not shown.

bin/Load$Worker.class

1.48 KB
Binary file not shown.

bin/Load$Worker1.class

1.32 KB
Binary file not shown.

bin/Load$WorkerGate.class

1.61 KB
Binary file not shown.

bin/Load.class

4.79 KB
Binary file not shown.

bin/LoadImageApp$1.class

1.29 KB
Binary file not shown.

bin/LoadImageApp$2.class

1.34 KB
Binary file not shown.

bin/LoadImageApp.class

6.79 KB
Binary file not shown.

src/Load.java

+316
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
import java.awt.Graphics;
2+
import java.awt.Image;
3+
import java.awt.image.BufferedImage;
4+
import java.awt.image.BufferedImageOp;
5+
import java.awt.image.ConvolveOp;
6+
import java.awt.image.Kernel;
7+
import java.io.File;
8+
import java.io.FilenameFilter;
9+
import java.io.IOException;
10+
import java.util.concurrent.CountDownLatch;
11+
12+
import javax.imageio.ImageIO;
13+
import javax.swing.ImageIcon;
14+
import javax.swing.JLabel;
15+
import javax.swing.JPanel;
16+
17+
public class Load {
18+
19+
BufferedImage img;
20+
//Image img;
21+
public String ll;
22+
File[] files;
23+
ImageIcon imgIcon;
24+
int Counter=0;
25+
long End=0;
26+
long Start=0;
27+
long last=0;
28+
int x=0;
29+
30+
Image ImgArr[];
31+
ImageIcon ImageIconArr[];
32+
33+
CountDownLatch gate;
34+
35+
Thread threadArr[];
36+
37+
int numProc = Runtime.getRuntime().availableProcessors() + 1;
38+
39+
public void FilesArray(String file) {
40+
files = new File(file).listFiles(new FilenameFilter() {
41+
public boolean accept(File dir, String name) {
42+
return name.endsWith(".jpg");
43+
}
44+
});
45+
}
46+
47+
public void NormalLOAD(){
48+
49+
ImgArr = new Image[files.length];
50+
ImageIconArr = new ImageIcon[files.length];
51+
52+
for (int i = 0; i < files.length; i++) {
53+
try {
54+
ImgArr[i] = ImageIO.read(files[i]);
55+
ImageIconArr[i] = new ImageIcon(ImgArr[i]);
56+
57+
} catch (IOException e) {
58+
//e.printStackTrace();
59+
System.out.println("Loading Error : IO Exception");
60+
}catch (NullPointerException e){
61+
System.out.println("Loading Error : Pointer Exeption");
62+
}
63+
}
64+
}
65+
66+
public Thread ParallelLOAD() {
67+
68+
ImgArr = new Image[files.length];
69+
ImageIconArr = new ImageIcon[files.length];
70+
Thread t = new Thread(new Runnable() {
71+
@Override
72+
public void run() {
73+
// TODO Auto-generated method stub
74+
for (int i = 0; i < files.length; i++) {
75+
try {
76+
ImgArr[i] = ImageIO.read(files[i]);
77+
ImageIconArr[i] = new ImageIcon(ImgArr[i]);
78+
} catch (NullPointerException e) {
79+
System.out.println("Loading Error : Pointer Exeption");
80+
} catch (IOException e) {
81+
//e.printStackTrace();
82+
System.out.println("Loading Error : IO Exception");
83+
}
84+
}
85+
}
86+
});
87+
return t;
88+
}
89+
90+
public Thread[] ConceranteLOAD() {
91+
92+
ImgArr = new Image[files.length];
93+
ImageIconArr = new ImageIcon[files.length];
94+
threadArr = new Thread[files.length];
95+
for (int i = 0; i < files.length; i++) {
96+
Counter = i;
97+
Thread e =new Thread(new Runnable() {
98+
@Override
99+
public void run() {
100+
// TODO Auto-generated method stub
101+
try {
102+
ImgArr[Counter] = ImageIO.read(files[Counter]);
103+
ImageIconArr[Counter] = new ImageIcon(ImgArr[Counter]);
104+
105+
} catch (IOException e) {
106+
// TODO Auto-generated catch block
107+
System.out.println("Loading Error : IO Exception");
108+
} catch (NullPointerException e){
109+
// TODO Auto-generated catch block
110+
System.out.println("Loading Error : Pointer Exeption");
111+
}
112+
}
113+
});
114+
threadArr[i]=e;
115+
}
116+
return threadArr;
117+
}
118+
119+
public void newload(JPanel j){
120+
try {
121+
Graphics g = (Graphics)j.getGraphics();
122+
ImgArr[x] = ImageIO.read(files[x]); //img = ImageIO.read(new File(files[x].toString()));
123+
g.drawImage(ImgArr[x], 20, 20, null);
124+
ImageIconArr[x]= new ImageIcon(ImgArr[x]);
125+
j.removeAll();
126+
j.repaint();
127+
j.add(new JLabel(ImageIconArr[x]));
128+
} catch (IOException e) {
129+
System.out.println("error");
130+
}
131+
}
132+
133+
public void KOKO(){
134+
135+
/*ImgArr = new Image[files.length];
136+
ImageIconArr = new ImageIcon[files.length];
137+
138+
for (int i = 0; i < files.length; i++) {
139+
Counter = i;
140+
Thread k = new Thread(new Worker(ImgArr,ImageIconArr,files,Counter));
141+
k.start();
142+
}*/
143+
}
144+
145+
public void KOKOK(){
146+
Thread k = new Thread(new Worker1());
147+
k.start();
148+
}
149+
150+
public void KOKOKO(){
151+
152+
gate = new CountDownLatch(1);
153+
Thread k = new Thread(new WorkerGate(gate));
154+
k.start();
155+
try {
156+
System.out.println("berfore");
157+
gate.await(0, null);
158+
System.out.println("after await");
159+
} catch (InterruptedException e) {
160+
// TODO Auto-generated catch block
161+
e.printStackTrace();
162+
System.out.println("With Gate");
163+
}
164+
}
165+
166+
public Thread Return(){
167+
168+
gate = new CountDownLatch(1);
169+
Thread k = new Thread(new WorkerGate(gate));
170+
return k;
171+
}
172+
173+
public class Loader extends Thread{
174+
175+
Thread t;
176+
177+
public Loader(Thread h){t=h;}
178+
public Loader() {
179+
// TODO Auto-generated constructor stub
180+
}
181+
public void setRun(Thread h){t=h;}
182+
public void startWorking()
183+
{
184+
t.start();
185+
186+
}
187+
188+
@Override
189+
public void run() {
190+
// TODO Auto-generated method stub
191+
ImgArr = new Image[files.length];
192+
ImageIconArr = new ImageIcon[files.length];
193+
for (int i = 0; i < files.length; i++) {
194+
try {
195+
ImgArr[i] = ImageIO.read(files[i]);
196+
ImageIconArr[i] = new ImageIcon(ImgArr[i]);
197+
} catch (IOException e) {
198+
//e.printStackTrace();
199+
System.out.println("Loading Error : IO Exception");
200+
}catch (NullPointerException e){
201+
System.out.println("Loading Error : Pointer Exeption");
202+
}
203+
}
204+
}
205+
206+
207+
208+
}
209+
210+
class Worker implements Runnable{
211+
212+
public Worker(Image[] imgArr1, ImageIcon[] imageIconArr1, File[] files1, int counter1) {
213+
ImgArr = imgArr1;
214+
ImageIconArr = imageIconArr1;
215+
files = files1;
216+
counter1 = Counter;
217+
// TODO Auto-generated constructor stub
218+
}
219+
220+
@Override
221+
public void run() {
222+
// TODO Auto-generated method stub
223+
ImgArr = new Image[files.length];
224+
ImageIconArr = new ImageIcon[files.length];
225+
try {
226+
ImgArr[Counter] = ImageIO.read(files[Counter]);
227+
ImageIconArr[Counter] = new ImageIcon(ImgArr[Counter]);
228+
229+
} catch (IOException e) {
230+
// TODO Auto-generated catch block
231+
//e.printStackTrace();
232+
System.out.println("Loading Error : IO Exception");
233+
}
234+
catch (NullPointerException e)
235+
{
236+
System.out.println("Loading Error : Pointer Exeption");
237+
}
238+
239+
}
240+
}
241+
242+
class Worker1 implements Runnable{
243+
244+
public Worker1() {}
245+
246+
@Override
247+
public void run() {
248+
// TODO Auto-generated method stub
249+
ImgArr = new Image[files.length];
250+
ImageIconArr = new ImageIcon[files.length];
251+
for (int i = 0; i < files.length; i++) {
252+
try {
253+
ImgArr[i] = ImageIO.read(files[i]);
254+
ImageIconArr[i] = new ImageIcon(ImgArr[i]);
255+
System.out.println("here");
256+
} catch (IOException e) {
257+
//e.printStackTrace();
258+
System.out.println("Loading Error : IO Exception");
259+
}catch (NullPointerException e){
260+
System.out.println("Loading Error : Pointer Exeption");
261+
}
262+
}
263+
}
264+
}
265+
266+
class WorkerGate implements Runnable{
267+
268+
CountDownLatch count;
269+
270+
public WorkerGate(CountDownLatch d){
271+
count = d = new CountDownLatch(1);
272+
ImgArr = new Image[files.length];
273+
ImageIconArr = new ImageIcon[files.length];
274+
}
275+
276+
@Override
277+
public void run() {
278+
// TODO Auto-generated method stub
279+
for (int i = 0; i < files.length; i++) {
280+
try {
281+
ImgArr[i] = ImageIO.read(files[i]);
282+
ImageIconArr[i] = new ImageIcon(ImgArr[i]);
283+
System.out.println("Here Gate");
284+
} catch (IOException e) {
285+
//e.printStackTrace();
286+
System.out.println("Loading Error : IO Exception");
287+
}catch (NullPointerException e){
288+
System.out.println("Loading Error : Pointer Exeption");
289+
}
290+
}
291+
count.countDown();
292+
System.out.println(count.toString());
293+
}
294+
}
295+
296+
public void blurImage(int dimension, JPanel j){
297+
int n = dimension*dimension;
298+
float[] matrix = new float[n];
299+
for (int i = 0; i < matrix.length; i++)
300+
matrix[i] = 1.0f/(float)n;
301+
//long start = System.nanoTime();
302+
BufferedImageOp op = new ConvolveOp(new Kernel(dimension, dimension, matrix) );
303+
img = op.filter(img, null);
304+
//long end = System.nanoTime();
305+
//repaint();
306+
307+
/*Graphics g = (Graphics)j.getGraphics(); //img = ImageIO.read(new File(files[x].toString()));
308+
g.drawImage(img, 20, 20, null);
309+
imgIcon= new ImageIcon(img);
310+
j.removeAll();
311+
j.repaint();
312+
j.add(new JLabel(imgIcon));*/
313+
newload(j);
314+
}
315+
316+
}

0 commit comments

Comments
 (0)