Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Color[][] embedSecretImage(String publicImage, String privateImage) throws IOException {
- Color[][] source = BMPIO.readBMPFile(publicImage);
- Color[][] toEmbed = BMPIO.readBMPFile(privateImage);
- Color[][] result = new Color[source.length][source.length];
- try {
- File file = new File (publicImage);
- RandomAccessFile raf = new RandomAccessFile(file, "rw");
- raf.seek(54);
- for (int j = 0; j < toEmbed[0].length; j++) {
- for (int i = 0; i < toEmbed.length; i++) {
- int r = source[i][j].getRed();
- int g = source[i][j].getGreen();
- int b = source[i][j].getBlue();
- r = r - (r % 16);
- g = g - (g % 16);
- b = b - (b % 16);
- if (i < toEmbed.length && j < toEmbed[i].length) {
- int r2 = toEmbed[i][j].getRed()/16;
- int g2 = toEmbed[i][j].getGreen()/16;
- int b2 = toEmbed[i][j].getBlue()/16;
- }
- raf.writeByte(b);
- raf.writeByte(g);
- raf.writeByte(r);
- }
- }
- raf.close();
- } catch (IOException e) {
- System.exit(0);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement