public Direct3D9FrameDecoder(Func <Device, int, int, int, Format, Usage, Texture> textureFactory, MemoryPool memoryPool, Stream stream, Format preferedFormat) : base(textureFactory, memoryPool, preferedFormat) { FStream = stream; FImageInformation = ImageInformation.FromStream(stream); Width = FImageInformation.Width; Height = FImageInformation.Height; if (preferedFormat == Format.Unknown) { FChosenFormat = FImageInformation.Format; } }
public virtual void Dispose() { FTextureFactory = null; FMemoryPool = null; }
public BitmapFrameDecoder(Func <Device, int, int, int, Format, Usage, Texture> textureFactory, MemoryPool memoryPool, Stream stream) : base(textureFactory, memoryPool) { var dataStream = stream as SharpDX.DataStream; using (var wicStream = new WICStream(Factory, new SharpDX.DataPointer(dataStream.DataPointer, (int)dataStream.Length))) using (var decoder = new BitmapDecoder(Factory, wicStream, DecodeOptions.CacheOnLoad)) { using (var frame = decoder.GetFrame(0)) { var dstPixelFormat = PixelFormat.Format32bppBGRA; FWidth = frame.Size.Width; FHeight = frame.Size.Height; FStride = PixelFormat.GetStride(dstPixelFormat, FWidth); FLength = FStride * FHeight; FBuffer = memoryPool.UnmanagedPool.GetMemory(FLength); if (frame.PixelFormat != dstPixelFormat) { using (var converter = new FormatConverter(Factory)) { converter.Initialize(frame, dstPixelFormat); converter.CopyPixels(FStride, FBuffer); } } else { frame.CopyPixels(FStride, FBuffer); } } } memoryPool.StreamPool.PutStream(stream); }
public FrameDecoder(Func <Device, int, int, int, Format, Usage, Texture> textureFactory, MemoryPool memoryPool) { FTextureFactory = textureFactory; FMemoryPool = memoryPool; }
public static FrameDecoder Create(string filename, Func <Device, int, int, int, Format, Usage, Texture> textureFactory, MemoryPool memoryPool, Stream stream) { var extension = Path.GetExtension(filename); Func <Func <Device, int, int, int, Format, Usage, Texture>, MemoryPool, Stream, FrameDecoder> decoderFactory = null; if (!FDecoderFactories.TryGetValue(extension, out decoderFactory)) { return(new BitmapFrameDecoder(textureFactory, memoryPool, stream)); } return(decoderFactory(textureFactory, memoryPool, stream)); }
public Direct3D9FrameDecoder(Func <Device, int, int, int, Format, Usage, Texture> textureFactory, MemoryPool memoryPool, Stream stream) : base(textureFactory, memoryPool) { FStream = stream; FImageInformation = ImageInformation.FromStream(stream); }
public FrameDecoder(Func <Device, int, int, int, Format, Usage, Texture> textureFactory, MemoryPool memoryPool, Format preferedFormat) { FTextureFactory = textureFactory; FMemoryPool = memoryPool; FChosenFormat = preferedFormat; }
public static FrameDecoder Create(string filename, Func <Device, int, int, int, Format, Usage, Texture> textureFactory, MemoryPool memoryPool, Stream stream, Format preferedFormat) { var extension = Path.GetExtension(filename).ToLowerInvariant(); // In case the prefered format is not supported on one device, fall back to one which works. var format = GetFallbackFormatIfPreferedFormatIsNotSupported(preferedFormat); Func <Func <Device, int, int, int, Format, Usage, Texture>, MemoryPool, Stream, Format, FrameDecoder> decoderFactory = null; if (!FDecoderFactories.TryGetValue(extension, out decoderFactory)) { return(new BitmapFrameDecoder(textureFactory, memoryPool, stream, format)); } return(decoderFactory(textureFactory, memoryPool, stream, format)); }