OutOfMemoryError while decoding and encoding Base64 String into Bitmap

When showing Bitmap in ImageView from a file first decode it with the help of BitmapHelper.decodeFile(picturePath, 200, 200, true) this will return compressed Bitmap so that while encoding this Bitmap you can handle high resolution images as well as heavy size images upto 100 MB of file. After decoding file set it to your ImageView … Read more

Recycle ImageView’s Bitmap

In your onDestroy method you could try something like this: ImageView imageView = (ImageView)findViewById(R.id.my_image); Drawable drawable = imageView.getDrawable(); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap bitmap = bitmapDrawable.getBitmap(); bitmap.recycle(); } The cast should work since setImageBitmap is implemented as public void setImageBitmap(Bitmap bm) { setImageDrawable(new BitmapDrawable(mContext.getResources(), bm)); }

C# “Parameter is not valid.” creating new bitmap

Keep in mind, that is a LOT of memory you are trying to allocate with that Bitmap. Refer to http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/37684999-62c7-4c41-8167-745a2b486583/ .NET is likely refusing to create an image that uses up that much contiguous memory all at once. Slightly harder to read, but this reference helps as well: Each image in the system has the … Read more

How to encode Bitmaps into a video using MediaCodec?

I have modified the code provided by abalta to accept bitmaps in realtime (ie you don’t already need to have the bitmaps saved to disc). It also has a performance improvement since you don’t need to write then read the bitmaps from disc. I also increased the TIMEOUT_USEC from the original example which fixed some … Read more

Saving a bitmap into a MemoryStream

.NET is a managed environment: specifically, memory allocation is usually managed on your behalf by the .NET runtime. You don’t typically need to allocate the memory yourself. Sometimes, however, you do need to inform the runtime when you’ve finished with memory by using Close() or Dispose(). The using statement can be used to wrap a … Read more