Пример #1
0
        private byte[] ExportPVR(byte[] data, int offset, int length)
        {
            PVRConvertParameters @params = new PVRConvertParameters()
            {
                DataLength  = length,
                PixelFormat = PVRPixelFormat,
                Width       = Width,
                Height      = Height,
                MipMapCount = MipCount,
            };

            return(PVRConverter.WraptToPVR(data, offset, @params));
        }
Пример #2
0
        private void ExportPVR(Stream writer, Stream reader, long length)
        {
            PVRConvertParameters @params = new PVRConvertParameters()
            {
                DataLength  = length,
                PixelFormat = PVRPixelFormat,
                Width       = Width,
                Height      = Height,
                MipMapCount = MipCount,
            };

            PVRConverter.ExportPVR(writer, reader, @params);
        }
Пример #3
0
        private void ExportPVR(Stream writer, Stream reader, long length)
        {
            PVRConvertParameters @params = new PVRConvertParameters()
            {
                DataLength  = length,
                PixelFormat = PVRPixelFormat,
                Width       = Width,
                Height      = Height,
                MipMapCount = MipCount,
            };

            if (Config.IsConvertTexturesToPNG)
            {
                throw new NotImplementedException();
            }
            else
            {
                PVRConverter.ExportPVR(writer, reader, @params);
            }
        }
Пример #4
0
        public Bitmap ConvertToBitmap(IExportContainer container, Texture2D texture, byte[] data)
        {
            switch (texture.TextureFormat)
            {
            case TextureFormat.DXT1:
            case TextureFormat.DXT3:
            case TextureFormat.DXT5:
            case TextureFormat.Alpha8:
            case TextureFormat.ARGB4444:
            case TextureFormat.RGB24:
            case TextureFormat.RGBA32:
            case TextureFormat.ARGB32:
            case TextureFormat.R16:
            case TextureFormat.RGBA4444:
            case TextureFormat.BGRA32:
            case TextureFormat.RG16:
            case TextureFormat.R8:
            case TextureFormat.RGB565:
                return(DDSToBitmap(container, texture, data));

            case TextureFormat.YUY2:
            case TextureFormat.PVRTC_RGB2:
            case TextureFormat.PVRTC_RGBA2:
            case TextureFormat.PVRTC_RGB4:
            case TextureFormat.PVRTC_RGBA4:
            case TextureFormat.ETC_RGB4:
            case TextureFormat.ETC2_RGB:
            case TextureFormat.ETC2_RGBA1:
            case TextureFormat.ETC2_RGBA8:
            case TextureFormat.ASTC_RGB_4x4:
            case TextureFormat.ASTC_RGB_5x5:
            case TextureFormat.ASTC_RGB_6x6:
            case TextureFormat.ASTC_RGB_8x8:
            case TextureFormat.ASTC_RGB_10x10:
            case TextureFormat.ASTC_RGB_12x12:
            case TextureFormat.ASTC_RGBA_4x4:
            case TextureFormat.ASTC_RGBA_5x5:
            case TextureFormat.ASTC_RGBA_6x6:
            case TextureFormat.ASTC_RGBA_8x8:
            case TextureFormat.ASTC_RGBA_10x10:
            case TextureFormat.ASTC_RGBA_12x12:
            case TextureFormat.ETC_RGB4_3DS:
            case TextureFormat.ETC_RGBA8_3DS:
                using (MemoryStream dstStream = new MemoryStream())
                {
                    PVRConvertParameters @params = new PVRConvertParameters
                    {
                        DataLength  = data.Length,
                        PixelFormat = texture.PVRPixelFormat,
                        Width       = texture.Width,
                        Height      = texture.Height,
                        MipMapCount = texture.MipCount,
                    };
                    using (MemoryStream srcStream = new MemoryStream(data))
                    {
                        PVRConverter.ExportPVR(dstStream, srcStream, @params);
                    }
                    return(PVRToBitmap(texture, dstStream.ToArray()));
                }

            case TextureFormat.RHalf:
            case TextureFormat.RGHalf:
            case TextureFormat.RGBAHalf:
            case TextureFormat.RFloat:
            case TextureFormat.RGFloat:
            case TextureFormat.RGBAFloat:
            case TextureFormat.RGB9e5Float:
            case TextureFormat.ATC_RGB4:
            case TextureFormat.ATC_RGBA8:
            case TextureFormat.EAC_R:
            case TextureFormat.EAC_R_SIGNED:
            case TextureFormat.EAC_RG:
            case TextureFormat.EAC_RG_SIGNED:
                return(TextureConverter(texture, data));

            case TextureFormat.BC4:
            case TextureFormat.BC5:
            case TextureFormat.BC6H:
            case TextureFormat.BC7:
                return(Texgenpack(texture, data));

            case TextureFormat.DXT1Crunched:
            case TextureFormat.DXT5Crunched:
            {
                byte[] decompressed = DecompressCRN(data);
                return(DDSToBitmap(container, texture, decompressed));
            }

            case TextureFormat.ETC_RGB4Crunched:
            case TextureFormat.ETC2_RGBA8Crunched:
            {
                byte[] decompressed = DecompressCRN(data);
                using (MemoryStream dstStream = new MemoryStream())
                {
                    using (MemoryStream srcStream = new MemoryStream(decompressed))
                    {
                        PVRConvertParameters @params = new PVRConvertParameters
                        {
                            DataLength  = decompressed.Length,
                            PixelFormat = texture.PVRPixelFormat,
                            Width       = texture.Width,
                            Height      = texture.Height,
                            MipMapCount = texture.MipCount,
                        };
                        PVRConverter.ExportPVR(dstStream, srcStream, @params);
                    }
                    return(PVRToBitmap(texture, dstStream.ToArray()));
                }
            }

            default:
                Logger.Instance.Log(LogType.Error, LogCategory.Export, $"Unsupported texture format '{texture.TextureFormat}'");
                return(null);
            }
        }