Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
StandardImageHelper.iOS.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 #if SILICONSTUDIO_PLATFORM_IOS
4 using System;
5 using System.Drawing;
6 using System.IO;
7 using System.Runtime.InteropServices;
8 using MonoTouch.CoreGraphics;
9 using MonoTouch.Foundation;
10 using MonoTouch.UIKit;
11 using SiliconStudio.Core;
12 
13 namespace SiliconStudio.Paradox.Graphics
14 {
15  /// <summary>
16  /// This class is responsible to provide image loader for png, gif, bmp.
17  /// </summary>
18  partial class StandardImageHelper
19  {
20  public static Image LoadFromMemory(IntPtr pSource, int size, bool makeACopy, GCHandle? handle)
21  {
22  using (var imagedata = NSData.FromBytes(pSource, (uint) size))
23  using (var cgImage = new UIImage(imagedata).CGImage)
24  {
25  var image = Image.New2D(cgImage.Width, cgImage.Height, 1, PixelFormat.R8G8B8A8_UNorm, 1, cgImage.BytesPerRow);
26 
27  using (var context = new CGBitmapContext(image.PixelBuffer[0].DataPointer, cgImage.Width, cgImage.Height, 8, cgImage.Width*4, cgImage.ColorSpace, CGBitmapFlags.PremultipliedLast))
28  {
29  context.DrawImage(new RectangleF(0, 0, cgImage.Width, cgImage.Height), cgImage);
30 
31  if (handle != null)
32  handle.Value.Free();
33  else if (!makeACopy)
34  Utilities.FreeMemory(pSource);
35 
36  return image;
37  }
38  }
39  }
40 
41  public static void SaveGifFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
42  {
43  throw new NotImplementedException();
44  }
45 
46  public static void SaveTiffFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
47  {
48  throw new NotImplementedException();
49  }
50 
51  public static void SaveBmpFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
52  {
53  throw new NotImplementedException();
54  }
55 
56  public static void SaveJpgFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
57  {
58  throw new NotImplementedException();
59  }
60 
61  public static void SavePngFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
62  {
63  throw new NotImplementedException();
64  }
65 
66  public static void SaveWmpFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, Stream imageStream)
67  {
68  throw new NotImplementedException();
69  }
70  }
71 }
72 #endif
_In_ size_t count
Definition: DirectXTexP.h:174
_In_ size_t _In_ size_t size
Definition: DirectXTexP.h:175
SiliconStudio.Core.Mathematics.RectangleF RectangleF
Definition: SpriteFont.cs:17