本文整理汇总了C#中SharpDX.Direct3D9.ImageInformation类的典型用法代码示例。如果您正苦于以下问题:C# ImageInformation类的具体用法?C# ImageInformation怎么用?C# ImageInformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageInformation类属于SharpDX.Direct3D9命名空间,在下文中一共展示了ImageInformation类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllocateFromStream_NoLock
protected void AllocateFromStream_NoLock(Stream stream)
{
Texture texture;
ImageInformation info = new ImageInformation();
try
{
stream.Seek(0, SeekOrigin.Begin);
texture = AllocateFromImageStream(stream, ref info);
}
catch (Exception e)
{
ServiceRegistration.Get<ILogger>().Warn("TextureAssetCore: Error loading texture from file data stream", e);
return;
}
if (texture != null)
FinalizeAllocation(texture, info.Width, info.Height);
}
示例2: AllocateFromImageStream
protected Texture AllocateFromImageStream(Stream dataStream, ref ImageInformation info)
{
Texture texture = null;
FIBITMAP image = FIBITMAP.Zero;
try
{
image = FreeImage.LoadFromStream(dataStream);
// Write uncompressed data to temporary stream.
using (var memoryStream = new MemoryStream())
{
// Scale down larger images
int resizeWidth = MAX_TEXTURE_DIMENSION;
int resizeHeight = MAX_TEXTURE_DIMENSION;
if (_decodeWidth > 0)
resizeWidth = Math.Min(_decodeWidth, MAX_TEXTURE_DIMENSION);
if (_decodeHeight > 0)
resizeHeight = Math.Min(_decodeHeight, MAX_TEXTURE_DIMENSION);
Stream loadStream = dataStream;
if (!image.IsNull)
{
image = ResizeImage(image, resizeWidth, resizeHeight);
FreeImage.SaveToStream(image, memoryStream, FREE_IMAGE_FORMAT.FIF_BMP);
loadStream = memoryStream;
}
loadStream.Position = 0;
texture = Texture.FromStream(GraphicsDevice.Device, loadStream, (int)loadStream.Length, _decodeWidth, _decodeHeight, 1,
Usage.None, Format.A8R8G8B8, Pool.Default, Filter.None, Filter.None, 0, out info);
}
}
catch (Exception)
{
ServiceRegistration.Get<ILogger>().Warn("TextureAssetCore: Error loading texture from stream using FreeImage and DirectX");
}
finally
{
FreeImage.UnloadEx(ref image);
}
return texture;
}
示例3: AllocateFromFile
protected void AllocateFromFile(string path)
{
lock (_syncObj)
_state = State.LoadingSync;
Texture texture;
ImageInformation info = new ImageInformation();
try
{
using (Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 2048, true))
texture = AllocateFromImageStream(stream, ref info);
}
catch (Exception e)
{
ServiceRegistration.Get<ILogger>().Warn("TextureAssetCore: Error loading texture from file '{0}'", e, path);
return;
}
FinalizeAllocation(texture, info.Width, info.Height);
}
示例4: FromMemory
/// <summary>
/// Creates a <see cref="CubeTexture"/> from a memory buffer.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="buffer">The buffer.</param>
/// <param name="size">The size.</param>
/// <param name="levelCount">The level count.</param>
/// <param name="usage">The usage.</param>
/// <param name="format">The format.</param>
/// <param name="pool">The pool.</param>
/// <param name="filter">The filter.</param>
/// <param name="mipFilter">The mip filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="imageInformation">The image information.</param>
/// <returns>
/// A <see cref="CubeTexture"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateCubeTextureFromFileInMemoryEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataSize,[In] unsigned int Size,[In] unsigned int MipLevels,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[In] unsigned int Filter,[In] unsigned int MipFilter,[In] D3DCOLOR ColorKey,[Out] D3DXIMAGE_INFO* pSrcInfo,[Out, Buffer] PALETTEENTRY* pPalette,[In] IDirect3DCubeTexture9** ppCubeTexture)</unmanaged>
public static unsafe CubeTexture FromMemory(Device device, byte[] buffer, int size, int levelCount, Usage usage, Format format, Pool pool, Filter filter, Filter mipFilter, int colorKey, out ImageInformation imageInformation)
{
fixed (void* pImageInfo = &imageInformation)
return CreateFromMemory(device, buffer, size, levelCount, usage, format, pool, filter, mipFilter, colorKey, (IntPtr)pImageInfo, null);
}
示例5: FromStream
/// <summary>
/// Creates a <see cref="CubeTexture"/> from a stream.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="stream">The stream.</param>
/// <param name="sizeBytes">The size bytes.</param>
/// <param name="size">The size.</param>
/// <param name="levelCount">The level count.</param>
/// <param name="usage">The usage.</param>
/// <param name="format">The format.</param>
/// <param name="pool">The pool.</param>
/// <param name="filter">The filter.</param>
/// <param name="mipFilter">The mip filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="imageInformation">The image information.</param>
/// <param name="palette">The palette.</param>
/// <returns>
/// A <see cref="CubeTexture"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateCubeTextureFromFileInMemoryEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataSize,[In] unsigned int Size,[In] unsigned int MipLevels,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[In] unsigned int Filter,[In] unsigned int MipFilter,[In] D3DCOLOR ColorKey,[Out] D3DXIMAGE_INFO* pSrcInfo,[Out, Buffer] PALETTEENTRY* pPalette,[In] IDirect3DCubeTexture9** ppCubeTexture)</unmanaged>
public static unsafe CubeTexture FromStream(Device device, Stream stream, int sizeBytes, int size, int levelCount, Usage usage, Format format, Pool pool, Filter filter, Filter mipFilter, int colorKey, out ImageInformation imageInformation, out PaletteEntry[] palette)
{
palette = new PaletteEntry[256];
fixed (void* pImageInfo = &imageInformation)
return CreateFromStream(device, stream, sizeBytes, size, levelCount, usage, format, pool, filter, mipFilter, colorKey, (IntPtr)pImageInfo, palette);
}
示例6: FromFileInStream
/// <summary>
/// Loads a volume from a file in a strean.
/// </summary>
/// <param name="volume">The volume.</param>
/// <param name="stream">The stream.</param>
/// <param name="filter">The filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="sourceBox">The source box.</param>
/// <param name="destinationBox">The destination box.</param>
/// <param name="imageInformation">The image information.</param>
/// <returns>
/// A <see cref="SharpDX.Result"/> object describing the result of the operation.
/// </returns>
/// <unmanaged>HRESULT D3DXLoadVolumeFromFileInMemory([In] IDirect3DVolume9* pDestVolume,[Out, Buffer] const PALETTEENTRY* pDestPalette,[In] const void* pDestBox,[In] const void* pSrcData,[In] unsigned int SrcDataSize,[In] const void* pSrcBox,[In] D3DX_FILTER Filter,[In] int ColorKey,[In] void* pSrcInfo)</unmanaged>
public static void FromFileInStream(Volume volume, Stream stream, Filter filter, int colorKey, Box sourceBox, Box destinationBox, out ImageInformation imageInformation)
{
FromFileInStream(volume, stream, filter, colorKey, sourceBox, destinationBox, null, out imageInformation);
}
示例7: FromFileInMemory
/// <summary>
/// Loads a volume from a file in memory.
/// </summary>
/// <param name="volume">The volume.</param>
/// <param name="memory">The memory.</param>
/// <param name="filter">The filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="sourceBox">The source box.</param>
/// <param name="destinationBox">The destination box.</param>
/// <param name="imageInformation">The image information.</param>
/// <returns>
/// A <see cref="SharpDX.Result"/> object describing the result of the operation.
/// </returns>
/// <unmanaged>HRESULT D3DXLoadVolumeFromFileInMemory([In] IDirect3DVolume9* pDestVolume,[Out, Buffer] const PALETTEENTRY* pDestPalette,[In] const void* pDestBox,[In] const void* pSrcData,[In] unsigned int SrcDataSize,[In] const void* pSrcBox,[In] D3DX_FILTER Filter,[In] int ColorKey,[In] void* pSrcInfo)</unmanaged>
public static void FromFileInMemory(Volume volume, byte[] memory, Filter filter, int colorKey, Box sourceBox, Box destinationBox, out ImageInformation imageInformation)
{
FromFileInMemory(volume, memory, filter, colorKey, sourceBox, destinationBox, null, out imageInformation);
}
示例8: FromFile
/// <summary>
/// Loads a volume from a file on the disk.
/// </summary>
/// <param name="volume">The volume.</param>
/// <param name="fileName">Name of the file.</param>
/// <param name="filter">The filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="sourceBox">The source box.</param>
/// <param name="destinationBox">The destination box.</param>
/// <param name="imageInformation">The image information.</param>
/// <returns>
/// A <see cref="SharpDX.Result"/> object describing the result of the operation.
/// </returns>
/// <unmanaged>HRESULT D3DXLoadVolumeFromFileW([In] IDirect3DVolume9* pDestVolume,[In] const PALETTEENTRY* pDestPalette,[In] const D3DBOX* pDestBox,[In] const wchar_t* pSrcFile,[In] const D3DBOX* pSrcBox,[In] unsigned int Filter,[In] D3DCOLOR ColorKey,[In] D3DXIMAGE_INFO* pSrcInfo)</unmanaged>
public static void FromFile(Volume volume, string fileName, Filter filter, int colorKey, Box sourceBox, Box destinationBox, out ImageInformation imageInformation)
{
FromFile(volume, fileName, filter, colorKey, sourceBox, destinationBox, null, out imageInformation);
}
示例9: FromStream
/// <summary>
/// Creates a <see cref="VolumeTexture"/> from a stream.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="stream">The stream.</param>
/// <param name="sizeBytes">The size bytes.</param>
/// <param name="size">The size.</param>
/// <param name="levelCount">The level count.</param>
/// <param name="usage">The usage.</param>
/// <param name="format">The format.</param>
/// <param name="pool">The pool.</param>
/// <param name="filter">The filter.</param>
/// <param name="mipFilter">The mip filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="imageInformation">The image information.</param>
/// <returns>
/// A <see cref="VolumeTexture"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateVolumeTextureFromFileInMemoryEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataSize,[In] unsigned int Size,[In] unsigned int MipLevels,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[In] unsigned int Filter,[In] unsigned int MipFilter,[In] D3DCOLOR ColorKey,[Out] D3DXIMAGE_INFO* pSrcInfo,[Out, Buffer] PALETTEENTRY* pPalette,[In] IDirect3DVolumeTexture9** ppVolumeTexture)</unmanaged>
public static unsafe VolumeTexture FromStream(Device device, Stream stream, int sizeBytes, int width, int height, int depth, int levelCount, Usage usage, Format format, Pool pool, Filter filter, Filter mipFilter, int colorKey, out ImageInformation imageInformation)
{
fixed (void* pImageInfo = &imageInformation)
return CreateFromStream(device, stream, sizeBytes, width, height, depth, levelCount, usage, format, pool, filter, mipFilter, colorKey, (IntPtr)pImageInfo, null);
}
示例10: FromMemory
/// <summary>
/// Creates a <see cref="VolumeTexture"/> from a memory buffer.
/// </summary>
/// <param name="device">The device.</param>
/// <param name="buffer">The buffer.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="depth">The depth.</param>
/// <param name="levelCount">The level count.</param>
/// <param name="usage">The usage.</param>
/// <param name="format">The format.</param>
/// <param name="pool">The pool.</param>
/// <param name="filter">The filter.</param>
/// <param name="mipFilter">The mip filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="imageInformation">The image information.</param>
/// <param name="palette">The palette.</param>
/// <returns>
/// A <see cref="VolumeTexture"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateVolumeTextureFromFileInMemoryEx([In] IDirect3DDevice9* pDevice,[In] const void* pSrcData,[In] unsigned int SrcDataSize,[In] unsigned int Size,[In] unsigned int MipLevels,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[In] unsigned int Filter,[In] unsigned int MipFilter,[In] D3DCOLOR ColorKey,[Out] D3DXIMAGE_INFO* pSrcInfo,[Out, Buffer] PALETTEENTRY* pPalette,[In] IDirect3DVolumeTexture9** ppVolumeTexture)</unmanaged>
public static unsafe VolumeTexture FromMemory(Device device, byte[] buffer, int width, int height, int depth, int levelCount, Usage usage, Format format, Pool pool, Filter filter, Filter mipFilter, int colorKey, out ImageInformation imageInformation, out PaletteEntry[] palette)
{
palette = new PaletteEntry[256];
fixed (void* pImageInfo = &imageInformation)
return CreateFromMemory(device, buffer, width, height, depth, levelCount, usage, format, pool, filter, mipFilter, colorKey, (IntPtr)pImageInfo, palette);
}
示例11: FromFile
/// <summary>
/// Creates a <see cref="Texture"/> from a file
/// </summary>
/// <param name="device">The device.</param>
/// <param name="filename">The filename.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="levelCount">The level count.</param>
/// <param name="usage">The usage.</param>
/// <param name="format">The format.</param>
/// <param name="pool">The pool.</param>
/// <param name="filter">The filter.</param>
/// <param name="mipFilter">The mip filter.</param>
/// <param name="colorKey">The color key.</param>
/// <param name="imageInformation">The image information.</param>
/// <param name="palette">The palette.</param>
/// <returns>
/// A <see cref="Texture"/>
/// </returns>
/// <unmanaged>HRESULT D3DXCreateTextureFromFileExW([In] IDirect3DDevice9* pDevice,[In] const wchar_t* pSrcFile,[In] unsigned int Size,[In] unsigned int MipLevels,[In] unsigned int Usage,[In] D3DFORMAT Format,[In] D3DPOOL Pool,[In] unsigned int Filter,[In] unsigned int MipFilter,[In] D3DCOLOR ColorKey,[In] void* pSrcInfo,[Out, Buffer] PALETTEENTRY* pPalette,[In] IDirect3DTexture9** ppTexture)</unmanaged>
public static unsafe Texture FromFile(Device device, string filename, int width, int height, int levelCount, Usage usage, Format format, Pool pool, Filter filter, Filter mipFilter, int colorKey, out ImageInformation imageInformation, out PaletteEntry[] palette)
{
palette = new PaletteEntry[256];
fixed (void* pImageInfo = &imageInformation)
return CreateFromFile(device, filename, width, height, levelCount, usage, format, pool, filter, mipFilter, colorKey, (IntPtr)pImageInfo, palette);
}
示例12: AllocateFromImageStream_GDI
protected Texture AllocateFromImageStream_GDI(Stream dataStream, ref ImageInformation info)
{
Texture texture = null;
try
{
if (dataStream.CanSeek)
dataStream.Position = 0;
Image image = Image.FromStream(dataStream);
// Scale down larger images
int resizeWidth = MAX_TEXTURE_DIMENSION;
int resizeHeight = MAX_TEXTURE_DIMENSION;
if (_decodeWidth > 0)
resizeWidth = Math.Min(_decodeWidth, MAX_TEXTURE_DIMENSION);
if (_decodeHeight > 0)
resizeHeight = Math.Min(_decodeHeight, MAX_TEXTURE_DIMENSION);
image.ExifAutoRotate();
if (image.Size.Width > resizeWidth || image.Size.Height > resizeHeight)
{
var oldImage = image;
image = ImageUtilities.ResizeImage(image, resizeWidth, resizeHeight);
oldImage.Dispose();
}
// Write uncompressed data to temporary stream.
using (var loadStream = new MemoryStream())
{
image.Save(loadStream, ImageFormat.Bmp);
image.Dispose();
loadStream.Position = 0;
texture = Texture.FromStream(GraphicsDevice.Device, loadStream, (int)loadStream.Length, _decodeWidth, _decodeHeight, 1,
Usage.None, Format.A8R8G8B8, Pool.Default, Filter.None, Filter.None, 0, out info);
}
}
catch (Exception ex)
{
ServiceRegistration.Get<ILogger>().Warn("TextureAssetCore: Error loading texture from stream using GDI", ex);
}
return texture;
}
示例13: AllocateFromImageStream
protected Texture AllocateFromImageStream(Stream dataStream, ref ImageInformation info)
{
// GDI decoding was measured to be faster in nearly all cases. WIC based was faster, but was missing rotation support and had other dependencies (WPF or SharpDX.WIC).
// FreeImage decoding is kept in place as fallback to support image formats which are not handled by GDI.
Texture texture =
AllocateFromImageStream_GDI(dataStream, ref info) ??
AllocateFromImageStream_FreeImage(dataStream, ref info);
return texture;
}