diff --git a/src/ArrayUtils.java b/src/ArrayUtils.java new file mode 100644 index 0000000..ba148bf --- /dev/null +++ b/src/ArrayUtils.java @@ -0,0 +1,58 @@ + + +public class ArrayUtils +{ + public static boolean arrayIsPartOfOtherArrayOnOffset(byte[] src, byte[] part, int offset) + { + if(offset<0 || part.length+offset > src.length) return false; + for(int i=0; i>> 24), + (byte)(value >>> 16), + (byte)(value >>> 8), + (byte)value}; + } + + public static byte[] unsign(byte[] b) + { + byte[] u = new byte[b.length]; + for(int i=0; i= 2 && args[0].equals("-e")) + { + for(int i=1; i=2 && args[0].equals("-s")) + { + for(int i=1; i= 3 && args[0].equals("-i")) + { + String depthmap = args[1]; + for(int i=2; i.jpg ... .jpg':" + + "\n Extract the depthmap from the specified photo(s). The depthmaps will be stored with the suffix \"_d.png\"." + + "\n'-s .jpg ... .jpg':" + + "\n Extract the unblurred source image from the photo(s). These files will be stored with the suffix \"_s.jpg\"." + + "\n'-i .png .jpg .jpg':" + + "\n Inject a png file as Depthmap into the following specified jpg files." + + "\n'-h':" + + "\n Show this help text."); + } +} diff --git a/src/Gui.java b/src/Gui.java new file mode 100644 index 0000000..b2378b4 --- /dev/null +++ b/src/Gui.java @@ -0,0 +1,103 @@ +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.table.DefaultTableModel; + + +public class Gui extends JFrame +{ + /** + * + */ + private static final long serialVersionUID=1L; + JTable images; + JButton execute; + JButton close; + + public Gui() + { + super(); + this.setTitle("DepthMapExtractor"); + this.setVisible(true); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + this.setSize(new Dimension(600,400)); + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {} + JPanel content = new JPanel(new BorderLayout()); + this.add(content); + DefaultTableModel model = new DefaultTableModel(); + model.addColumn("filename"); + this.images = new JTable(model); + JButton addBtn = new JButton("+"); + addBtn.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent arg0) + { + //TODO: AddFilesDialog + } + }); + JButton remBtn = new JButton("-"); + remBtn.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent arg0) + { + //TODO: Remove selected files from table + } + }); + JPanel tablePanel = new JPanel(new FlowLayout()); + tablePanel.add(new JScrollPane(images)); + JPanel tableButtons = new JPanel(); + tableButtons.setLayout(new BoxLayout(tableButtons,BoxLayout.Y_AXIS)); + tableButtons.add(addBtn); + tableButtons.add(remBtn); + tablePanel.add(tableButtons); + content.add(tablePanel, BorderLayout.NORTH); + + execute = new JButton("Execute"); + execute.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent arg0) + { + //TODO: Actions + } + }); + close = new JButton("Close"); + close.addActionListener(new ActionListener(){ + @Override + public void actionPerformed(ActionEvent arg0) + { + dispose(); + } + }); + + JPanel buttons = new JPanel(new FlowLayout()); + buttons.add(close); buttons.add(execute); + content.add(buttons,BorderLayout.SOUTH); + this.pack(); + } + + public void executeExtraction() + { + DefaultTableModel model = (DefaultTableModel) images.getModel(); + for(int i=0; i>> 4) & 0x0F)); + buf.append(toHexChar(data & 0x0F)); + + return buf.toString(); + } + + public static char toHexChar(int i) { + if ((0 <= i) && (i <= 9)) { + return (char) ('0' + i); + } else { + return (char) ('a' + (i - 10)); + } + } + + public static byte[] generateMD5(byte[] data) + { + try + { + byte[] md5 = MessageDigest.getInstance("MD5").digest(data); + String m=""; + for(int i=0; i b = new Vector(); + for(int i=0; i