Example #1
0
 public static TexImage Create(Vector2Int size, PixelFormat.EFormat format)
 {
     try {
         var texture = new Texture2D(size.x, size.y, format.GetTextureFormat(), false);
         var image   = CreateInstance <TexImage> ();
         image.Texture = texture;
         return(image);
     } catch (InvalidOperationException) {
         throw new ArgumentException("Specified format is unsupported yet", nameof(format));
     }
 }
Example #2
0
 /// <summary>
 /// 构造包装纹理的内部数据(RawTextureData)的结构体。通过该构造函数可以直接封送纹理
 /// 数据到C++处理。
 /// </summary>
 ///
 /// <param name="texture">纹理对象,必须开启可读属性(isReadable=true)</param>
 ///
 /// <exception cref="ArgumentException">纹理对象的格式不受支持(目前支持的格式见
 ///     <see cref="PixelFormat.EFormat"/>)</exception>
 /// <author>Nianchen Deng</author>
 public NativeImage(Texture2D texture)
 {
     try {
         format = texture.format.GetPixelFormat();
     } catch (InvalidOperationException ex) {
         throw new ArgumentException(
                   "Texture's format is not supported yet", nameof(texture), ex);
     }
     size = new Vector2Int(texture.width, texture.height);
     unsafe {
         data = (IntPtr)texture.GetRawTextureData <byte> ()
                .GetUnsafePtr();
     }
 }
Example #3
0
 public static extern bool Camera_setFormat(IntPtr p_inst, PixelFormat.EFormat format);