using Android.Graphics; using System; public void ReleaseBitmap(Bitmap bitmap) { if(bitmap != null) { bitmap.Dispose(); } }
using Android.Graphics; using System; public void LoadBitmap(string filePath) { using (var options = new BitmapFactory.Options()) { options.InJustDecodeBounds = false; options.InPreferredConfig = Bitmap.Config.Argb8888; using (var bitmap = BitmapFactory.DecodeFile(filePath, options)) { // Use bitmap here } } }This code example demonstrates how to use the Dispose method with a using statement. The using statement ensures that the Dispose method is called automatically when the code block is exited. The code also demonstrates how to load a Bitmap from a file using the BitmapFactory class. The Bitmap.Config is set to Argb8888 to ensure that the Bitmap has a high-quality color configuration.