Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pixelColor = bitmapImage.getPixel(10, 10);
- int pixelAlpha= Color.alpha(pixelColor);
- int red = 65;// represent character A
- int green= Color.green(pixelColor);
- int blue= Color.blue(pixelColor);
- int new_pixel= Color.argb(pixelAlpha, red, green, blue);
- bitmapImage.setPixel(10, 10, new_pixel);
- String data="";
- int pixelColor = bitmapImage.getPixel(10,10);
- int red = Color.red(pixelColor);
- data+=(char)red;
- Toast.makeText(this, "Data: "+data , 20).show();
- public void saveImage(Bitmap bitmapImage,String name) throws IOException
- {
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- bitmapImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
- String fName="/mnt/sdcard/pictures/"+name+".jpg";
- File f = new File(fName);
- f.createNewFile();
- FileOutputStream fo = new FileOutputStream(f);
- fo.write(bytes.toByteArray());
- fo.flush();
- fo.close();
- }
- private Bitmap HideMessage(Bitmap src)
- {
- Bitmap dest = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig());
- for(int x = 0; x < src.getWidth(); x++)
- {
- for(int y = 0; y < src.getHeight(); y++)
- {
- dest.setPixel(x, y, src.getPixel(x, y));
- }
- }
- int pixelColor = src.getPixel(10, 10);
- int pixelAlpha= Color.alpha(pixelColor);
- int red = 65;// represent character A
- int green= Color.green(pixelColor);
- int blue= Color.blue(pixelColor);
- int new_pixel= Color.argb(pixelAlpha, red, green, blue);
- dest.setPixel(10, 10, new_pixel);
- return dest;
- }
- public void Hide()
- {
- Bitmap dest = HideMessage(image);
- try
- {
- saveImage(dest,"hidden");
- Toast.makeText(this, "Message Hidden in Image and saved", Toast.LENGTH_LONG).show();
- }
- catch (IOException e)
- {
- Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
- }
- }
- public void Show_character()
- {
- Bitmap dest = BitmapFactory.decodeFile("/mnt/sdcard/pictures/hidden.jpg");
- String data= "";
- int pixelColor = dest.getPixel(10,10);
- int red = Color.red(pixelColor);
- data+=(char)red;
- Toast.makeText(this, "Data: "+data , 20).show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement