Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. int pixelColor = bitmapImage.getPixel(10, 10);
  2.  
  3. int pixelAlpha= Color.alpha(pixelColor);
  4. int red = 65;// represent character A
  5. int green= Color.green(pixelColor);
  6. int blue= Color.blue(pixelColor);
  7.  
  8. int new_pixel= Color.argb(pixelAlpha, red, green, blue);
  9.  
  10. bitmapImage.setPixel(10, 10, new_pixel);
  11.  
  12. String data="";
  13. int pixelColor = bitmapImage.getPixel(10,10);
  14. int red = Color.red(pixelColor);
  15. data+=(char)red;
  16.  
  17. Toast.makeText(this, "Data: "+data , 20).show();
  18.  
  19. public void saveImage(Bitmap bitmapImage,String name) throws IOException
  20. {
  21. ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  22. bitmapImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
  23.  
  24.  
  25. String fName="/mnt/sdcard/pictures/"+name+".jpg";
  26. File f = new File(fName);
  27. f.createNewFile();
  28.  
  29.  
  30. FileOutputStream fo = new FileOutputStream(f);
  31. fo.write(bytes.toByteArray());
  32. fo.flush();
  33. fo.close();
  34.  
  35. }
  36. private Bitmap HideMessage(Bitmap src)
  37. {
  38.  
  39. Bitmap dest = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
  40.  
  41.  
  42. for(int x = 0; x < src.getWidth(); x++)
  43. {
  44. for(int y = 0; y < src.getHeight(); y++)
  45. {
  46. dest.setPixel(x, y, src.getPixel(x, y));
  47. }
  48. }
  49.  
  50. int pixelColor = src.getPixel(10, 10);
  51.  
  52. int pixelAlpha= Color.alpha(pixelColor);
  53. int red = 65;// represent character A
  54. int green= Color.green(pixelColor);
  55. int blue= Color.blue(pixelColor);
  56.  
  57. int new_pixel= Color.argb(pixelAlpha, red, green, blue);
  58.  
  59. dest.setPixel(10, 10, new_pixel);
  60.  
  61. return dest;
  62. }
  63.  
  64. public void Hide()
  65. {
  66.  
  67. Bitmap dest = HideMessage(image);
  68. try
  69. {
  70. saveImage(dest,"hidden");
  71. Toast.makeText(this, "Message Hidden in Image and saved", Toast.LENGTH_LONG).show();
  72. }
  73. catch (IOException e)
  74. {
  75. Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
  76. }
  77. }
  78. public void Show_character()
  79. {
  80. Bitmap dest = BitmapFactory.decodeFile("/mnt/sdcard/pictures/hidden.jpg");
  81.  
  82. String data= "";
  83. int pixelColor = dest.getPixel(10,10);
  84. int red = Color.red(pixelColor);
  85. data+=(char)red;
  86.  
  87. Toast.makeText(this, "Data: "+data , 20).show();
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement