-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncodeWorker.java
More file actions
32 lines (25 loc) · 1007 Bytes
/
EncodeWorker.java
File metadata and controls
32 lines (25 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import javax.imageio.IIOException;
import javax.swing.SwingWorker;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.IOException;
// By: Justin Spedding & Andrew Miller
public class EncodeWorker extends SwingWorker<BufferedImage, Void> {
private SegmentedEncoder encoder;
private int currentSegment;
public EncodeWorker(String hostImagePath, String stegoPath, String password) throws FileNotFoundException, IOException, IIOException, CannotEncodeException, ImageOverflowException {
this.encoder = new SegmentedEncoder(hostImagePath, stegoPath, password);
currentSegment = 0;
}
public BufferedImage doInBackground() throws IOException, IIOException, ImageOverflowException, NoSuchSegmentException {
while (encoder.hasNext() && !isCancelled()) {
setProgress((currentSegment * 100) / encoder.getTotalSegments());
encoder.nextSegment();
currentSegment++;
}
setProgress(100);
return encoder.getEncodedImage();
}
public void done() {
}
}