Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public static Color[][] embedSecretImage(String publicImage, String privateImage) throws IOException {
  2.  
  3. Color[][] source = BMPIO.readBMPFile(publicImage);
  4. Color[][] toEmbed = BMPIO.readBMPFile(privateImage);
  5. Color[][] result = new Color[source.length][source.length];
  6.  
  7. try {
  8. File file = new File (publicImage);
  9. RandomAccessFile raf = new RandomAccessFile(file, "rw");
  10.  
  11. raf.seek(54);
  12. for (int j = 0; j < toEmbed[0].length; j++) {
  13. for (int i = 0; i < toEmbed.length; i++) {
  14. int r = source[i][j].getRed();
  15. int g = source[i][j].getGreen();
  16. int b = source[i][j].getBlue();
  17. r = r - (r % 16);
  18. g = g - (g % 16);
  19. b = b - (b % 16);
  20. if (i < toEmbed.length && j < toEmbed[i].length) {
  21. int r2 = toEmbed[i][j].getRed()/16;
  22. int g2 = toEmbed[i][j].getGreen()/16;
  23. int b2 = toEmbed[i][j].getBlue()/16;
  24. }
  25. raf.writeByte(b);
  26. raf.writeByte(g);
  27. raf.writeByte(r);
  28. }
  29. }
  30.  
  31. raf.close();
  32. } catch (IOException e) {
  33. System.exit(0);
  34. }
  35. return result;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement