3 #if SILICONSTUDIO_PLATFORM_ANDROID
6 using System.Runtime.InteropServices;
7 using SiliconStudio.Core;
8 using Android.Graphics;
9 using SiliconStudio.Core.Mathematics;
11 namespace SiliconStudio.
Paradox.Graphics
16 partial class StandardImageHelper
18 public unsafe
static Image LoadFromMemory(IntPtr pSource,
int size,
bool makeACopy, GCHandle? handle)
20 using (var memoryStream =
new UnmanagedMemoryStream((byte*)pSource, size))
21 using (var bitmap = (Bitmap)BitmapFactory.DecodeStream(memoryStream))
23 var bitmapData = bitmap.LockPixels();
25 var image = Image.New2D(bitmap.Width, bitmap.Height, 1, PixelFormat.B8G8R8A8_UNorm, 1, bitmap.RowBytes);
26 #if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
28 CopyMemoryBGRA(image.PixelBuffer[0].DataPointer, bitmapData, image.PixelBuffer[0].BufferStride);
30 Utilities.CopyMemory(image.PixelBuffer[0].DataPointer, bitmapData, image.PixelBuffer[0].BufferStride);
32 bitmap.UnlockPixels();
37 Utilities.FreeMemory(pSource);
44 public static void SaveGifFromMemory(PixelBuffer[] pixelBuffers,
int count, ImageDescription description, Stream imageStream)
46 throw new NotImplementedException();
49 public static void SaveTiffFromMemory(PixelBuffer[] pixelBuffers,
int count, ImageDescription description, Stream imageStream)
51 throw new NotImplementedException();
54 public static void SaveBmpFromMemory(PixelBuffer[] pixelBuffers,
int count, ImageDescription description, Stream imageStream)
56 throw new NotImplementedException();
59 public static void SaveJpgFromMemory(PixelBuffer[] pixelBuffers,
int count, ImageDescription description, Stream imageStream)
61 throw new NotImplementedException();
64 public static void SavePngFromMemory(PixelBuffer[] pixelBuffers,
int count, ImageDescription description, Stream imageStream)
66 SaveFromMemory(pixelBuffers, count, description, imageStream, Bitmap.CompressFormat.Png);
69 public static void SaveWmpFromMemory(PixelBuffer[] pixelBuffers,
int count, ImageDescription description, Stream imageStream)
71 throw new NotImplementedException();
74 private static void SaveFromMemory(PixelBuffer[] pixelBuffers,
int count, ImageDescription description, Stream imageStream, Bitmap.CompressFormat imageFormat)
76 var colors = pixelBuffers[0].GetPixels<
int>();
77 using (var bitmap = Bitmap.CreateBitmap(colors, description.Width, description.Height, Bitmap.Config.Argb8888))
79 bitmap.Compress(imageFormat, 0, imageStream);
_In_ size_t _In_ size_t size