Code example for Bitmap

Methods: getDensitygetHeightgetPixelsgetWidthrecycle

0
	public Steganography() {} 
 
	// encodes secret to bitmap 
	public static Bitmap encode(Bitmap bmp, String secret)
	{ 
		int height = bmp.getHeight();
		int width = bmp.getWidth();
		 
		Bitmap newImage = null;
		int[] imgPixels = new int[width * height];
		bmp.getPixels(imgPixels, 0, width, 0, 0, width, height);
		int density = bmp.getDensity();
		bmp.recycle();
		try 
		{ 
			byte[] byteImage = LSB2bit.encodeMessage(imgPixels, width, height, secret);
			 
			newImage = Bitmap.createBitmap(width, height, Config.ARGB_8888);
			newImage.setDensity(density);
			int imgMod[] = LSB2bit.byteArrayToIntArray(byteImage);