/// <summary> /// Determines whether this requested format is supported. /// </summary> /// <param name="format">The format.</param> /// <returns> /// <c>true</c> if the formats is supported; otherwise, <c>false</c>. /// </returns> public bool SupportFormat(SiliconStudio.Xenko.Graphics.PixelFormat format) { switch (format) { case SiliconStudio.Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm: case SiliconStudio.Xenko.Graphics.PixelFormat.B8G8R8A8_UNorm: case SiliconStudio.Xenko.Graphics.PixelFormat.ATC_RGB: case SiliconStudio.Xenko.Graphics.PixelFormat.ATC_RGBA_Explicit: case SiliconStudio.Xenko.Graphics.PixelFormat.ATC_RGBA_Interpolated: return(true); default: return(false); } }
/// <summary> /// Retrieves the native format from <see cref="SiliconStudio.Xenko.Graphics.PixelFormat"/>. /// </summary> /// <param name="format">The format.</param> /// <returns>the corresponding <see cref="Format"/> format</returns> private Format RetrieveNativeFormat(SiliconStudio.Xenko.Graphics.PixelFormat format) { switch (format) { case SiliconStudio.Xenko.Graphics.PixelFormat.R8G8B8A8_UNorm: case SiliconStudio.Xenko.Graphics.PixelFormat.B8G8R8A8_UNorm: return(Format.ATI_TC_FORMAT_ARGB_8888); case SiliconStudio.Xenko.Graphics.PixelFormat.ATC_RGB: return(Format.ATI_TC_FORMAT_ATC_RGB); case SiliconStudio.Xenko.Graphics.PixelFormat.ATC_RGBA_Explicit: return(Format.ATI_TC_FORMAT_ATC_RGBA_Explicit); case SiliconStudio.Xenko.Graphics.PixelFormat.ATC_RGBA_Interpolated: return(Format.ATI_TC_FORMAT_ATC_RGBA_Interpolated); default: throw new TextureToolsException("UnHandled compression format by ATI texture."); } }
/// <summary> /// Converts a <see cref="Format"/> to a a WIC <see cref="WIC.PixelFormat"/>. /// </summary> /// <param name="format">A <see cref="Format"/></param> /// <param name="guid">A WIC <see cref="WIC.PixelFormat"/> Guid.</param> /// <returns>True if conversion succeed, false otherwise.</returns> private static bool ToWIC(Format format, out Guid guid) { for (int i = 0; i < WICToDXGIFormats.Length; ++i) { if (WICToDXGIFormats[i].Format == format) { guid = WICToDXGIFormats[i].WIC; return(true); } } // Special cases switch (format) { case Format.R8G8B8A8_UNorm_SRgb: guid = SharpDX.WIC.PixelFormat.Format32bppRGBA; return(true); case Format.D32_Float: guid = SharpDX.WIC.PixelFormat.Format32bppGrayFloat; return(true); case Format.D16_UNorm: guid = SharpDX.WIC.PixelFormat.Format16bppGray; return(true); case Format.B8G8R8A8_UNorm_SRgb: guid = SharpDX.WIC.PixelFormat.Format32bppBGRA; return(true); case Format.B8G8R8X8_UNorm_SRgb: guid = SharpDX.WIC.PixelFormat.Format32bppBGR; return(true); } guid = Guid.Empty; return(false); }
/// <summary> /// Initializes a new instance of the <see cref="CompressingRequest"/> class. /// </summary> /// <param name="format">The compression format.</param> public CompressingRequest(SiliconStudio.Xenko.Graphics.PixelFormat format, TextureQuality quality = TextureQuality.Fast) { this.Format = format; this.Quality = quality; }
/// <summary> /// Initializes a new instance of the <see cref="ConvertingRequest"/> class. /// </summary> /// <param name="format">The destination format.</param> public ConvertingRequest(SiliconStudio.Xenko.Graphics.PixelFormat format) { this.Format = format; }
//------------------------------------------------------------------------------------- // Returns the DXGI format and optionally the WIC pixel Guid to convert to //------------------------------------------------------------------------------------- private static Format DetermineFormat(Guid pixelFormat, WICFlags flags, out Guid pixelFormatOut) { Format format = ToDXGI(pixelFormat); pixelFormatOut = Guid.Empty; if (format == Format.None) { for (int i = 0; i < WICConvertTable.Length; ++i) { if (WICConvertTable[i].source == pixelFormat) { pixelFormatOut = WICConvertTable[i].target; format = ToDXGI(WICConvertTable[i].target); Debug.Assert(format != Format.None); break; } } } // Handle special cases based on flags switch (format) { case Format.B8G8R8A8_UNorm: // BGRA case Format.B8G8R8X8_UNorm: // BGRX if ((flags & WICFlags.ForceRgb) != 0) { format = Format.R8G8B8A8_UNorm; pixelFormatOut = WIC.PixelFormat.Format32bppRGBA; } break; case Format.R10G10B10_Xr_Bias_A2_UNorm: if ((flags & WICFlags.NoX2Bias) != 0) { format = Format.R10G10B10A2_UNorm; pixelFormatOut = WIC.PixelFormat.Format32bppRGBA1010102; } break; case Format.B5G5R5A1_UNorm: case Format.B5G6R5_UNorm: if ((flags & WICFlags.No16Bpp) != 0) { format = Format.R8G8B8A8_UNorm; pixelFormatOut = WIC.PixelFormat.Format32bppRGBA; } break; case Format.R1_UNorm: if ((flags & WICFlags.FlagsAllowMono) == 0) { // By default we want to promote a black & white to greyscale since R1 is not a generally supported D3D format format = Format.R8_UNorm; pixelFormatOut = WIC.PixelFormat.Format8bppGray; } break; } return(format); }
public WICTranslate(Guid wic, Format format) { this.WIC = wic; this.Format = format; }
/// <summary> /// Converts a <see cref="Format"/> to a a WIC <see cref="WIC.PixelFormat"/>. /// </summary> /// <param name="format">A <see cref="Format"/></param> /// <param name="guid">A WIC <see cref="WIC.PixelFormat"/> Guid.</param> /// <returns>True if conversion succeed, false otherwise.</returns> private static bool ToWIC(Format format, out Guid guid) { for (int i = 0; i < WICToDXGIFormats.Length; ++i) { if (WICToDXGIFormats[i].Format == format) { guid = WICToDXGIFormats[i].WIC; return true; } } // Special cases switch (format) { case Format.R8G8B8A8_UNorm_SRgb: guid = SharpDX.WIC.PixelFormat.Format32bppRGBA; return true; case Format.D32_Float: guid = SharpDX.WIC.PixelFormat.Format32bppGrayFloat; return true; case Format.D16_UNorm: guid = SharpDX.WIC.PixelFormat.Format16bppGray; return true; case Format.B8G8R8A8_UNorm_SRgb: guid = SharpDX.WIC.PixelFormat.Format32bppBGRA; return true; case Format.B8G8R8X8_UNorm_SRgb: guid = SharpDX.WIC.PixelFormat.Format32bppBGR; return true; } guid = Guid.Empty; return false; }