I have written a steganography algorithm, but it takes a long time to complete. This is because I create a new instance of bitmap, BitmapStegan
, and I take each pixel from my old bitmap, bitmap
. Whether I modify it or not, I have to set it in the new bitmap object. Therefore, I end up looping through all of the pixels, even though I only need to edit a few of them.
How can I address that problem?
Bitmap BitmapStegan = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
for(int i=0; i<bitmap.getWidth(); i++){
for(int j=0; j<bitmap.getHeight(); j++){
int pixel=bitmap.getPixel(i, j);
int red= Color.red(pixel);
int green=Color.green(pixel);
int blue=Color.blue(pixel);
if (NumberBitsInMessage>0) {
/*
I put here my bit to red and greed and blue with LSB method
*/
}
BitmapStegan.setPixel(i, j, Color.argb(Color.alpha(pixel), red, green, blue));
}
}
imageView.setImageBitmap(BitmapStegan);