コード例 #1
0
 public static SKImage?Decode(this UTexture2D texture)
 {
     if (!texture.IsVirtual && texture.GetFirstMip() is { } mip)
     {
         DecodeTexture(mip, texture.Format, out byte[] data, out var colorType);
         using var bitmap = new SKBitmap(new SKImageInfo(mip.SizeX, mip.SizeY, colorType, SKAlphaType.Unpremul));
         unsafe
         {
             fixed(byte *p = data)
             {
                 bitmap.SetPixels(new IntPtr(p));
             }
         }
         return(SKImage.FromBitmap(bitmap));
     }
     return(null);
 }
コード例 #2
0
        public static SKImage?Decode(this UTexture2D texture, bool bNearest = false)
        {
            if (!texture.IsVirtual && texture.GetFirstMip() is { } mip)
            {
                DecodeTexture(mip, texture.Format, out byte[] data, out var colorType);

                var width  = mip.SizeX;
                var height = mip.SizeY;
                using var bitmap = new SKBitmap(new SKImageInfo(width, height, colorType, SKAlphaType.Unpremul));
                unsafe
                {
                    fixed(byte *p = data)
                    {
                        bitmap.SetPixels(new IntPtr(p));
                    }
                }

                return(SKImage.FromBitmap(!bNearest ? bitmap : bitmap.Resize(new SKImageInfo(width, height), SKFilterQuality.None)));
            }
            return(null);
        }
コード例 #3
0
ファイル: TextureDecoder.cs プロジェクト: FabianFG/CUE4Parse
 public static SKBitmap?Decode(this UTexture2D texture, ETexturePlatform platform = ETexturePlatform.DesktopMobile) => texture.Decode(texture.GetFirstMip(), platform);