/// <summary> /// Create new writeable bitmap. /// </summary> /// <param name="size">The size of the bitmap in device pixels.</param> /// <param name="dpi">The DPI of the bitmap.</param> /// <param name="format">The pixel format.</param> /// <param name="alphaFormat">The alpha format.</param> public WriteableBitmapImpl(PixelSize size, Vector dpi, PixelFormat format, AlphaFormat alphaFormat) { PixelSize = size; Dpi = dpi; SKColorType colorType = format.ToSkColorType(); SKAlphaType alphaType = alphaFormat.ToSkAlphaType(); var runtimePlatform = AvaloniaLocator.Current?.GetService <IRuntimePlatform>(); if (runtimePlatform != null) { _bitmap = new SKBitmap(); var nfo = new SKImageInfo(size.Width, size.Height, colorType, alphaType); var blob = runtimePlatform.AllocBlob(nfo.BytesSize); _bitmap.InstallPixels(nfo, blob.Address, nfo.RowBytes, s_releaseDelegate, blob); } else { _bitmap = new SKBitmap(size.Width, size.Height, colorType, alphaType); } _bitmap.Erase(SKColor.Empty); }
private static void CheckTextureFormat(Game game, string textureUrl, AlphaFormat expectedFormat) { var expectedPixelFormat = PlaformAndAlphaToPixelFormats[Tuple.Create(Platform.Type, expectedFormat)]; var texture = game.Asset.Load<Texture>(textureUrl); Assert.AreEqual(expectedPixelFormat, texture.Format); game.Asset.Unload(texture); }
public ImportParameters(TextureConvertParameters textureParameters) { var asset = textureParameters.Texture; // Compute SRgb usage // If Texture is in auto mode, use the global settings, else use the settings overridden by the texture asset. IsSRgb = textureParameters.Texture.ColorSpace.ToColorSpace(textureParameters.ColorSpace, asset.Hint) == ColorSpace.Linear; DesiredSize = new Size2((int)asset.Width, (int)asset.Height); IsSizeInPercentage = asset.IsSizeInPercentage; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = asset.Hint; GenerateMipmaps = asset.GenerateMipmaps; if (asset.Alpha != AlphaFormat.None) { PremultiplyAlpha = asset.PremultiplyAlpha; } ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = textureParameters.TextureQuality; GraphicsPlatform = textureParameters.GraphicsPlatform; GraphicsProfile = textureParameters.GraphicsProfile; Platform = textureParameters.Platform; }
public ImportParameters(TextureConvertParameters textureParameters) { var asset = textureParameters.Texture; // Compute SRgb usage // If Texture is in auto mode, use the global settings, else use the settings overridden by the texture asset. IsSRgb = textureParameters.Texture.Type.IsSRgb(textureParameters.ColorSpace); DesiredSize = new Size2((int)asset.Width, (int)asset.Height); IsSizeInPercentage = asset.IsSizeInPercentage; ShouldCompress = asset.IsCompressed; DesiredAlpha = asset.Type.Alpha; TextureHint = asset.Type.Hint; InvertY = (asset.Type.Hint == TextureHint.NormalMap) ? ((NormapMapTextureType)asset.Type).InvertY : false; GenerateMipmaps = asset.GenerateMipmaps; if (asset.Type.Alpha != AlphaFormat.None) { PremultiplyAlpha = asset.Type.PremultiplyAlpha; } ColorKeyColor = asset.Type.ColorKeyColor; ColorKeyEnabled = asset.Type.ColorKeyEnabled; TextureQuality = textureParameters.TextureQuality; GraphicsPlatform = textureParameters.GraphicsPlatform; GraphicsProfile = textureParameters.GraphicsProfile; Platform = textureParameters.Platform; }
/// <summary> /// Determines if alpha channel should be separated from a given texture's attribute and graphics profile /// </summary> /// <param name="alphaFormat">Alpha format for a texture</param> /// <param name="textureFormat">Texture format</param> /// <param name="platform">Platform</param> /// <param name="graphicsProfile">Level of graphics</param> /// <returns></returns> public static bool ShouldSeparateAlpha(AlphaFormat alphaFormat, TextureFormat textureFormat, PlatformType platform, GraphicsProfile graphicsProfile) { if (alphaFormat != AlphaFormat.None && textureFormat == TextureFormat.Compressed && platform == PlatformType.Android) { switch (graphicsProfile) { case GraphicsProfile.Level_9_1: case GraphicsProfile.Level_9_2: case GraphicsProfile.Level_9_3: // Android with OpenGLES < 3.0 require alpha splitting if the image is compressed since ETC1 compresses only RGB return(true); case GraphicsProfile.Level_10_0: case GraphicsProfile.Level_10_1: case GraphicsProfile.Level_11_0: case GraphicsProfile.Level_11_1: case GraphicsProfile.Level_11_2: // Since OpenGLES 3.0, ETC2 RGBA is used instead of ETC1 RGB so alpha is compressed along with RGB; therefore, no need to split alpha return(false); default: throw new ArgumentOutOfRangeException("graphicsProfile"); } } return(false); }
/// <summary> /// Initializes a new instance of the <see cref="T:DesktopSprites.Interop.Win32.BLENDFUNCTION"/> structure. /// </summary> /// <param name="blendOp">The source blend operation.</param> /// <param name="sourceConstantAlpha">Specifies an alpha transparency value to be used on the entire source bitmap. The /// <see cref="P:DesktopSprites.Interop.Win32.BLENDFUNCTION.SourceConstantAlpha"/> value is combined with any per-pixel /// alpha values in the source bitmap. If you set <see cref="P:DesktopSprites.Win32.BLENDFUNCTION.SourceConstantAlpha"/> to 0, it /// is assumed that your image is transparent. Set the <see cref="P:DesktopSprites.Win32.BLENDFUNCTION.SourceConstantAlpha"/> /// value to 255 (opaque) when you only want to use per-pixel alpha values.</param> /// <param name="alphaFormat">This member controls the way the source and destination bitmaps are interpreted.</param> public BLENDFUNCTION(BlendOp blendOp, byte sourceConstantAlpha, AlphaFormat alphaFormat) { BlendOp = blendOp; BlendFlags = 0; SourceConstantAlpha = sourceConstantAlpha; AlphaFormat = alphaFormat; }
public IWriteableBitmapImpl CreateWriteableBitmap( PixelSize size, Vector dpi, PixelFormat format, AlphaFormat alphaFormat) { throw new NotImplementedException(); }
/* * Sets the alpha format of the texture. This indicates the type of alpha * information the texture will contain, such as none, binary, or smooth. * Older texture objects don't seem to have this option, so calling this * function won't affect them. * \param[in] format The new alpha format for the texture. */ public void SetAlphaFormat(AlphaFormat format) { if (src_tex != null) { src_tex.SetAlphaFormat(format); } //Just silently fail for now. Not sure where this data may or may not be stored in the old style image objects. }
private static void CheckTextureFormat(Game game, string textureUrl, AlphaFormat expectedFormat) { var expectedPixelFormat = PlaformAndAlphaToPixelFormats[Tuple.Create(Platform.Type, expectedFormat)]; var texture = game.Content.Load <Texture>(textureUrl); Assert.Equal(expectedPixelFormat, texture.Format); game.Content.Unload(texture); }
//Constructor public FormatPrefs() { unchecked { pixelLayout = (PixelLayout)0; useMipmaps = MipMapFormat.MIP_FMT_DEFAULT; alphaFormat = AlphaFormat.ALPHA_DEFAULT; } }
public static SKAlphaType ToSkAlphaType(this AlphaFormat fmt) { return(fmt switch { AlphaFormat.Premul => SKAlphaType.Premul, AlphaFormat.Unpremul => SKAlphaType.Unpremul, AlphaFormat.Opaque => SKAlphaType.Opaque, _ => throw new ArgumentException($"Unknown alpha format: {fmt}") });
public NiSourceTexture(NiFile niFile) : base(niFile) { useExternal = niFile.Reader.ReadByte(); FileName = niFile.Reader.ReadLengthPrefixedString(); pixelLayout = (PixelLayout)niFile.Reader.ReadInt32(); useMipMaps = (MipMapFormat)niFile.Reader.ReadInt32(); alphaFormat = (AlphaFormat)niFile.Reader.ReadInt32(); isStatic = niFile.Reader.ReadByte(); }
public IBitmapImpl LoadBitmap( PixelFormat format, AlphaFormat alphaFormat, IntPtr data, PixelSize size, Vector dpi, int stride) { throw new NotImplementedException(); }
public ImportParameters(SpriteSheetAssetCompiler.SpriteSheetParameters spriteSheetParameters) { var asset = spriteSheetParameters.SheetAsset; IsSRgb = asset.SRgb; DesiredSize = new Size2(100, 100); IsSizeInPercentage = true; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = TextureHint.Color; GenerateMipmaps = asset.GenerateMipmaps; PremultiplyAlpha = asset.PremultiplyAlpha; ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = spriteSheetParameters.TextureQuality; GraphicsPlatform = spriteSheetParameters.GraphicsPlatform; GraphicsProfile = spriteSheetParameters.GraphicsProfile; Platform = spriteSheetParameters.Platform; }
public ImportParameters(TextureConvertParameters textureParameters) { var asset = textureParameters.Texture; IsSRgb = asset.SRgb; DesiredSize = new Size2((int)asset.Width, (int)asset.Height); IsSizeInPercentage = asset.IsSizeInPercentage; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = asset.Hint; GenerateMipmaps = asset.GenerateMipmaps; PremultiplyAlpha = asset.PremultiplyAlpha; ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = textureParameters.TextureQuality; GraphicsPlatform = textureParameters.GraphicsPlatform; GraphicsProfile = textureParameters.GraphicsProfile; Platform = textureParameters.Platform; }
public ImportParameters(SpriteSheetAssetCompiler.SpriteSheetParameters spriteSheetParameters) { var asset = spriteSheetParameters.SheetAsset; IsSRgb = asset.SRgb; DesiredSize = new Size2(100, 100); IsSizeInPercentage = true; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = TextureHint.Color; GenerateMipmaps = asset.GenerateMipmaps; PremultiplyAlpha = asset.PremultiplyAlpha; ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = spriteSheetParameters.TextureQuality; GraphicsPlatform = spriteSheetParameters.GraphicsPlatform; GraphicsProfile = spriteSheetParameters.GraphicsProfile; Platform = spriteSheetParameters.Platform; }
public ImportParameters(TextureConvertParameters textureParameters) { var asset = textureParameters.Texture; IsSRgb = asset.SRgb; DesiredSize = new Size2((int)asset.Width, (int)asset.Height); IsSizeInPercentage = asset.IsSizeInPercentage; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = asset.Hint; GenerateMipmaps = asset.GenerateMipmaps; PremultiplyAlpha = asset.PremultiplyAlpha; ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = textureParameters.TextureQuality; GraphicsPlatform = textureParameters.GraphicsPlatform; GraphicsProfile = textureParameters.GraphicsProfile; Platform = textureParameters.Platform; }
public NiSourceTexture(NIFReader file, BinaryReader reader) : base(file, reader) { IsStatic = true; UseExternal = reader.ReadBoolean(); if (UseExternal) { FileName = new NiString(reader); } if (!UseExternal) { reader.ReadByte(); InternalTexture = new NiRef <ATextureRenderData>(reader); } PixelLayout = (PixelLayout)reader.ReadUInt32(); UseMipmaps = (MipMapFormat)reader.ReadUInt32(); AlphaFormat = (AlphaFormat)reader.ReadUInt32(); IsStatic = reader.ReadBoolean(); Unknown = reader.ReadUInt32(); }
public ImportParameters(SpriteSheetAssetCompiler.SpriteSheetParameters spriteSheetParameters) { var asset = spriteSheetParameters.SheetAsset; // Compute SRgb usage // If Texture is in auto mode, use the global settings, else use the settings overridden by the texture asset. IsSRgb = asset.ColorSpace.ToColorSpace(spriteSheetParameters.ColorSpace, TextureHint.Color) == ColorSpace.Linear; DesiredSize = new Size2(100, 100); IsSizeInPercentage = true; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = TextureHint.Color; GenerateMipmaps = asset.GenerateMipmaps; PremultiplyAlpha = asset.PremultiplyAlpha; ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = spriteSheetParameters.TextureQuality; GraphicsPlatform = spriteSheetParameters.GraphicsPlatform; GraphicsProfile = spriteSheetParameters.GraphicsProfile; Platform = spriteSheetParameters.Platform; }
public ImportParameters(TextureConvertParameters textureParameters) { var asset = textureParameters.Texture; // Compute SRgb usage // If Texture is in auto mode, use the global settings, else use the settings overridden by the texture asset. IsSRgb = textureParameters.Texture.ColorSpace.ToColorSpace(textureParameters.ColorSpace, asset.Hint) == ColorSpace.Linear; DesiredSize = new Size2((int)asset.Width, (int)asset.Height); IsSizeInPercentage = asset.IsSizeInPercentage; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = asset.Hint; GenerateMipmaps = asset.GenerateMipmaps; PremultiplyAlpha = asset.PremultiplyAlpha; ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = textureParameters.TextureQuality; GraphicsPlatform = textureParameters.GraphicsPlatform; GraphicsProfile = textureParameters.GraphicsProfile; Platform = textureParameters.Platform; }
/// <summary> /// Create immutable bitmap from given pixel data copy. /// </summary> /// <param name="size">Size of the bitmap.</param> /// <param name="dpi">DPI of the bitmap.</param> /// <param name="stride">Stride of data pixels.</param> /// <param name="format">Format of data pixels.</param> /// <param name="alphaFormat">Alpha format of data pixels.</param> /// <param name="data">Data pixels.</param> public ImmutableBitmap(PixelSize size, Vector dpi, int stride, PixelFormat format, AlphaFormat alphaFormat, IntPtr data) { var imageInfo = new SKImageInfo(size.Width, size.Height, format.ToSkColorType(), alphaFormat.ToSkAlphaType()); _image = SKImage.FromPixelCopy(imageInfo, data, stride); if (_image == null) { throw new ArgumentException("Unable to create bitmap from provided data"); } PixelSize = size; Dpi = dpi; }
private static void CheckSpriteTransparencies(Game game, string spriteSheetName, AlphaFormat alphaFormat) { var expectedPixelFormat = PlaformAndAlphaToPixelFormats[Tuple.Create(Platform.Type, alphaFormat)]; var spriteSheet = game.Content.Load <SpriteSheet>(spriteSheetName); // check the textures pixel format foreach (var texture in spriteSheet.Sprites.Select(s => s.Texture)) { Assert.Equal(expectedPixelFormat, texture.Format); } for (int i = 0; i < spriteSheet.Sprites.Count; i++) { var sprite = spriteSheet.Sprites[i]; Assert.Equal(i != 0 && alphaFormat != AlphaFormat.None, sprite.IsTransparent); // except sprite 0 all sprites have transparency expect if the texture alpha is 0 } game.Content.Unload(spriteSheet); }
/// <summary> /// Initializes a new instance of the <see cref="Bitmap"/> class. /// </summary> /// <param name="format">The pixel format.</param> /// <param name="alphaFormat">The alpha format.</param> /// <param name="data">The pointer to the source bytes.</param> /// <param name="size">The size of the bitmap in device pixels.</param> /// <param name="dpi">The DPI of the bitmap.</param> /// <param name="stride">The number of bytes per row.</param> public Bitmap(PixelFormat format, AlphaFormat alphaFormat, IntPtr data, PixelSize size, Vector dpi, int stride) { PlatformImpl = RefCountable.Create(AvaloniaLocator.Current.GetService <IPlatformRenderInterface>() .LoadBitmap(format, alphaFormat, data, size, dpi, stride)); }
/// <summary> /// Initializes a new instance of the <see cref="Bitmap"/> class. /// </summary> /// <param name="format">The pixel format.</param> /// <param name="alphaFormat">The alpha format.</param> /// <param name="data">The pointer to the source bytes.</param> /// <param name="size">The size of the bitmap in device pixels.</param> /// <param name="dpi">The DPI of the bitmap.</param> /// <param name="stride">The number of bytes per row.</param> public Bitmap(PixelFormat format, AlphaFormat alphaFormat, IntPtr data, PixelSize size, Vector dpi, int stride) { PlatformImpl = RefCountable.Create(GetFactory().LoadBitmap(format, alphaFormat, data, size, dpi, stride)); }
/// <summary> /// Determine the output format of the texture depending on the platform and asset properties. /// </summary> /// <param name="textureFormat">The desired texture output format type</param> /// <param name="alphaFormat">The alpha format desired in output</param> /// <param name="platform">The platform type</param> /// <param name="graphicsPlatform">The graphics platform</param> /// <param name="graphicsProfile">The graphics profile</param> /// <param name="imageSize">The texture output size</param> /// <param name="inputImageFormat">The pixel format of the input image</param> /// <returns>The pixel format to use as output</returns> public static PixelFormat DetermineOutputFormat(TextureFormat textureFormat, AlphaFormat alphaFormat, PlatformType platform, GraphicsPlatform graphicsPlatform, GraphicsProfile graphicsProfile, Int2 imageSize, PixelFormat inputImageFormat) { PixelFormat outputFormat; switch (textureFormat) { case TextureFormat.Compressed: switch (platform) { case PlatformType.Android: switch (graphicsProfile) { case GraphicsProfile.Level_9_1: case GraphicsProfile.Level_9_2: case GraphicsProfile.Level_9_3: outputFormat = alphaFormat == AlphaFormat.None ? PixelFormat.ETC1 : PixelFormat.R8G8B8A8_UNorm; break; case GraphicsProfile.Level_10_0: case GraphicsProfile.Level_10_1: case GraphicsProfile.Level_11_0: case GraphicsProfile.Level_11_1: case GraphicsProfile.Level_11_2: // GLES3.0 starting from Level_10_0, this profile enables ETC2 compression on Android outputFormat = alphaFormat == AlphaFormat.None ? PixelFormat.ETC1 : PixelFormat.ETC2_RGBA; break; default: throw new ArgumentOutOfRangeException("graphicsProfile"); } break; case PlatformType.iOS: // PVRTC works only for square POT textures if (SupportPVRTC(imageSize)) { switch (alphaFormat) { case AlphaFormat.None: // DXT1 handles 1-bit alpha channel outputFormat = PixelFormat.PVRTC_4bpp_RGB; break; case AlphaFormat.Mask: // DXT1 handles 1-bit alpha channel // TODO: Not sure about the equivalent here? outputFormat = PixelFormat.PVRTC_4bpp_RGBA; break; case AlphaFormat.Explicit: case AlphaFormat.Interpolated: // DXT3 is good at sharp alpha transitions // TODO: Not sure about the equivalent here? outputFormat = PixelFormat.PVRTC_4bpp_RGBA; break; default: throw new ArgumentOutOfRangeException(); } } else { outputFormat = PixelFormat.R8G8B8A8_UNorm; } break; case PlatformType.Windows: case PlatformType.WindowsPhone: case PlatformType.WindowsStore: switch (graphicsPlatform) { case GraphicsPlatform.Direct3D11: switch (alphaFormat) { case AlphaFormat.None: case AlphaFormat.Mask: // DXT1 handles 1-bit alpha channel outputFormat = PixelFormat.BC1_UNorm; break; case AlphaFormat.Explicit: // DXT3 is good at sharp alpha transitions outputFormat = PixelFormat.BC2_UNorm; break; case AlphaFormat.Interpolated: // DXT5 is good at alpha gradients outputFormat = PixelFormat.BC3_UNorm; break; default: throw new ArgumentOutOfRangeException(); } break; case GraphicsPlatform.OpenGLES: // OpenGLES on Windows switch (graphicsProfile) { case GraphicsProfile.Level_9_1: case GraphicsProfile.Level_9_2: case GraphicsProfile.Level_9_3: outputFormat = alphaFormat == AlphaFormat.None ? PixelFormat.ETC1 : PixelFormat.R8G8B8A8_UNorm; break; case GraphicsProfile.Level_10_0: case GraphicsProfile.Level_10_1: case GraphicsProfile.Level_11_0: case GraphicsProfile.Level_11_1: case GraphicsProfile.Level_11_2: // GLES3.0 starting from Level_10_0, this profile enables ETC2 compression on Android outputFormat = alphaFormat == AlphaFormat.None ? PixelFormat.ETC1 : PixelFormat.ETC2_RGBA; break; default: throw new ArgumentOutOfRangeException("graphicsProfile"); } break; default: // OpenGL on Windows // TODO: Need to handle OpenGL Desktop compression outputFormat = PixelFormat.R8G8B8A8_UNorm; break; } break; default: throw new NotSupportedException("Platform " + platform + " is not supported by TextureTool"); } break; case TextureFormat.HighColor: if (alphaFormat == AlphaFormat.None) { outputFormat = PixelFormat.B5G6R5_UNorm; } else if (alphaFormat == AlphaFormat.Mask) { outputFormat = PixelFormat.B5G5R5A1_UNorm; } else { throw new NotImplementedException("This alpha format requires a TrueColor texture format."); } break; case TextureFormat.TrueColor: outputFormat = PixelFormat.R8G8B8A8_UNorm; break; //case TextureFormat.Custom: // throw new NotSupportedException(); // break; case TextureFormat.AsIs: outputFormat = inputImageFormat; break; default: throw new ArgumentOutOfRangeException(); } return(outputFormat); }
/// <summary> /// Determines if alpha channel should be separated from a given texture's attribute and graphics profile /// </summary> /// <param name="alphaFormat">Alpha format for a texture</param> /// <param name="textureFormat">Texture format</param> /// <param name="platform">Platform</param> /// <param name="graphicsProfile">Level of graphics</param> /// <returns></returns> public static bool ShouldSeparateAlpha(AlphaFormat alphaFormat, TextureFormat textureFormat, PlatformType platform, GraphicsProfile graphicsProfile) { if (alphaFormat != AlphaFormat.None && textureFormat == TextureFormat.Compressed && platform == PlatformType.Android) { switch (graphicsProfile) { case GraphicsProfile.Level_9_1: case GraphicsProfile.Level_9_2: case GraphicsProfile.Level_9_3: // Android with OpenGLES < 3.0 require alpha splitting if the image is compressed since ETC1 compresses only RGB return true; case GraphicsProfile.Level_10_0: case GraphicsProfile.Level_10_1: case GraphicsProfile.Level_11_0: case GraphicsProfile.Level_11_1: case GraphicsProfile.Level_11_2: // Since OpenGLES 3.0, ETC2 RGBA is used instead of ETC1 RGB so alpha is compressed along with RGB; therefore, no need to split alpha return false; default: throw new ArgumentOutOfRangeException("graphicsProfile"); } } return false; }
/// <inheritdoc /> public IBitmapImpl LoadBitmap(PixelFormat format, AlphaFormat alphaFormat, IntPtr data, PixelSize size, Vector dpi, int stride) { return(new WicBitmapImpl(format, alphaFormat, data, size, dpi, stride)); }
public NiFormatPrefs(BinaryReader reader, NiFile niFile) : base(reader, niFile) { Pixel = (PixelLayout)reader.ReadUInt32(); MipMap = (MipMapFormat)reader.ReadUInt32(); Alpha = (AlphaFormat)reader.ReadUInt32(); }
/// <inheritdoc /> public IWriteableBitmapImpl CreateWriteableBitmap(PixelSize size, Vector dpi, PixelFormat format, AlphaFormat alphaFormat) { return(new WriteableBitmapImpl(size, dpi, format, alphaFormat)); }
/// <inheritdoc /> public IBitmapImpl LoadBitmap(PixelFormat format, AlphaFormat alphaFormat, IntPtr data, PixelSize size, Vector dpi, int stride) { return(new ImmutableBitmap(size, dpi, stride, format, alphaFormat, data)); }
public ImportParameters(SpriteSheetAssetCompiler.SpriteSheetParameters spriteSheetParameters) { var asset = spriteSheetParameters.SheetAsset; // Compute SRgb usage // If Texture is in auto mode, use the global settings, else use the settings overridden by the texture asset. IsSRgb = asset.ColorSpace.ToColorSpace(spriteSheetParameters.ColorSpace, TextureHint.Color) == ColorSpace.Linear; DesiredSize = new Size2(100, 100); IsSizeInPercentage = true; DesiredFormat = asset.Format; DesiredAlpha = asset.Alpha; TextureHint = TextureHint.Color; GenerateMipmaps = asset.GenerateMipmaps; PremultiplyAlpha = asset.PremultiplyAlpha; ColorKeyColor = asset.ColorKeyColor; ColorKeyEnabled = asset.ColorKeyEnabled; TextureQuality = spriteSheetParameters.TextureQuality; GraphicsPlatform = spriteSheetParameters.GraphicsPlatform; GraphicsProfile = spriteSheetParameters.GraphicsProfile; Platform = spriteSheetParameters.Platform; }
/// <summary> /// Initializes a new instance of the <see cref="T:DesktopSprites.Interop.Win32.BLENDFUNCTION"/> structure. /// </summary> /// <param name="blendOp">The source blend operation.</param> /// <param name="sourceConstantAlpha">Specifies an alpha transparency value to be used on the entire source bitmap. The /// <see cref="P:DesktopSprites.Interop.Win32.BLENDFUNCTION.SourceConstantAlpha"/> value is combined with any per-pixel /// alpha values in the source bitmap. If you set <see cref="P:DesktopSprites.Win32.BLENDFUNCTION.SourceConstantAlpha"/> to 0, it /// is assumed that your image is transparent. Set the <see cref="P:DesktopSprites.Win32.BLENDFUNCTION.SourceConstantAlpha"/> /// value to 255 (opaque) when you only want to use per-pixel alpha values.</param> /// <param name="alphaFormat">This member controls the way the source and destination bitmaps are interpreted.</param> public BLENDFUNCTION(BlendOp blendOp, byte sourceConstantAlpha, AlphaFormat alphaFormat) { BlendOp = blendOp; BlendFlags = 0; SourceConstantAlpha = sourceConstantAlpha; AlphaFormat = alphaFormat; }
public IWriteableBitmapImpl CreateWriteableBitmap(PixelSize size, Vector dpi, PixelFormat format, AlphaFormat alphaFormat) { return(new HeadlessBitmapStub(size, dpi)); }
private static void CheckSpriteTransparencies(Game game, string spriteSheetName, AlphaFormat alphaFormat) { var expectedPixelFormat = PlaformAndAlphaToPixelFormats[Tuple.Create(Platform.Type, alphaFormat)]; var spriteSheet = game.Asset.Load<SpriteSheet>(spriteSheetName); // check the textures pixel format foreach (var texture in spriteSheet.Sprites.Select(s => s.Texture)) Assert.AreEqual(expectedPixelFormat, texture.Format); for (int i = 0; i < spriteSheet.Sprites.Count; i++) { var sprite = spriteSheet.Sprites[i]; Assert.AreEqual(i!=0 && alphaFormat != AlphaFormat.None, sprite.IsTransparent); // except sprite 0 all sprites have transparency expect if the texture alpha is 0 } game.Asset.Unload(spriteSheet); }
public IBitmapImpl LoadBitmap(PixelFormat format, AlphaFormat alphaFormat, IntPtr data, PixelSize size, Vector dpi, int stride) { return(new HeadlessBitmapStub(new Size(1, 1), new Vector(96, 96))); }
/// <summary> /// Initializes a new instance of the <see cref="WriteableBitmap"/> class. /// </summary> /// <param name="size">The size of the bitmap in device pixels.</param> /// <param name="dpi">The DPI of the bitmap.</param> /// <param name="format">The pixel format (optional).</param> /// <param name="alphaFormat">The alpha format (optional).</param> /// <returns>An <see cref="IWriteableBitmapImpl"/>.</returns> public WriteableBitmap(PixelSize size, Vector dpi, PixelFormat format, AlphaFormat alphaFormat) : base(CreatePlatformImpl(size, dpi, format, alphaFormat)) { }