Code example for Bitmap

Methods: copyPixelsToBuffergetConfiggetHeightgetRowBytesgetWidthrecycle

0
			// android:name="android.permission.WRITE_EXTERNAL_STORAGE" 
			// into AndroidManifest.xml file 
			RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
 
			// get the width and height of the source bitmap. 
			int width = original.getWidth();
			int height = original.getHeight();
			Config type = original.getConfig();
 
			// Copy the byte to the file 
			// Assume source bitmap loaded using options.inPreferredConfig = 
			// Config.ARGB_8888; 
			FileChannel channel = randomAccessFile.getChannel();
			MappedByteBuffer map = channel.map(MapMode.READ_WRITE, 0,
					original.getRowBytes() * height);
			original.copyPixelsToBuffer(map);
			// recycle the source bitmap, this will be no longer used. 
			original.recycle();
			System.gc();// try to force the bytes from the imgIn to be released
			original = null;
 
			// Create a new bitmap to load the bitmap again. Probably the memory 
			// will be available.