Hi,
Just like the title says, how can I convert Bitmap object to byte[] without the use of Bitmap.Compress?
This is what I've done so far but failed on .ToArray() method.
ByteBuffer byteBuffer = ByteBuffer.Allocate(bitmap.ByteCount);
bitmap.CopyPixelsToBuffer(byteBuffer);
byte[] bytes = byteBuffer.ToArray<byte>();
return bytes;
with the following stack trace:
at Android.Runtime.JNIEnv.AssertCompatibleArrayTypes (IntPtr sourceArray, System.Type destType) [0x0001a] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:581
07-12 14:49:05.433 I/mono-stdout(12726): at Android.Runtime.JNIEnv.AssertCompatibleArrayTypes (IntPtr sourceArray, System.Type destType) [0x0001a] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:581
at Android.Runtime.JNIEnv.GetArray[Byte] (IntPtr array_ptr) [0x00026] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:1000
at Java.Lang.Object.ToArray[Byte] () [0x00000] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:232
at Intersoft.Crosslight.Android.BitmapExtensions.ToByteArray (Android.Graphics.Bitmap bitmap) [0x00016] in d:\hpv-tfs12\ComponentProjects\Crosslight\Intersoft.Crosslight.Android\Extensions\BitmapExtensions.cs:16
07-12 14:49:05.433 I/mono-stdout(12726): at Android.Runtime.JNIEnv.GetArray[Byte] (IntPtr array_ptr) [0x00026] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:1000
07-12 14:49:05.443 I/mono-stdout(12726): at Java.Lang.Object.ToArray[Byte] () [0x00000] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Java.Lang/Object.cs:232
07-12 14:49:05.443 I/mono-stdout(12726): at Intersoft.Crosslight.Android.BitmapExtensions.ToByteArray (Android.Graphics.Bitmap bitmap) [0x00016] in d:\hpv-tfs12\ComponentProjects\Crosslight\Intersoft.Crosslight.Android\Extensions\BitmapExtensions.cs:16
Any help would be appreciated. Thanks!