diff --git a/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs b/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs index 3e2069f9cc5..1eb77991529 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Bitmap.cs @@ -5,7 +5,6 @@ using System.Drawing.Imaging; #if NET9_0_OR_GREATER using System.Drawing.Imaging.Effects; -using System.Runtime.Versioning; #endif using System.IO; using System.Runtime.CompilerServices; @@ -440,7 +439,6 @@ public void ApplyEffect(Effect effect, Rectangle area = default) /// is complete. /// /// - [RequiresPreviewFeatures] public void ConvertFormat( PixelFormat format, DitherType ditherType, @@ -485,7 +483,6 @@ public void ConvertFormat( /// The new pixel format. is not supported. /// /// - [RequiresPreviewFeatures] public void ConvertFormat(PixelFormat format) { PixelFormat currentFormat = PixelFormat; diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs index 909372d91ed..e5e56d04e1a 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if NET9_0_OR_GREATER -using System.Runtime.Versioning; -#endif - namespace System.Drawing.Imaging; /// @@ -38,17 +34,17 @@ private ColorPalette(int flags, Color[] entries) /// /// Create a custom color palette. /// - /// Color entries for the palette. - public ColorPalette(params Color[] entries) : this(0, entries) + /// Color entries for the palette. + public ColorPalette(params Color[] customColors) : this(0, customColors) { } /// /// Create a standard color palette. /// - public ColorPalette(PaletteType paletteType) + public ColorPalette(PaletteType fixedPaletteType) { - ColorPalette palette = InitializePalette(paletteType, 0, useTransparentColor: false, bitmap: null); + ColorPalette palette = InitializePalette(fixedPaletteType, 0, useTransparentColor: false, bitmap: null); _flags = palette.Flags; _entries = palette.Entries; } @@ -57,9 +53,8 @@ public ColorPalette(PaletteType paletteType) /// Create an optimal color palette based on the colors in a given bitmap. /// /// - [RequiresPreviewFeatures] - public static ColorPalette CreateOptimalPalette(int colorCount, bool useTransparentColor, Bitmap bitmap) => - InitializePalette((PaletteType)GdiPlus.PaletteType.PaletteTypeOptimal, colorCount, useTransparentColor, bitmap); + public static ColorPalette CreateOptimalPalette(int colors, bool useTransparentColor, Bitmap bitmap) => + InitializePalette((PaletteType)GdiPlus.PaletteType.PaletteTypeOptimal, colors, useTransparentColor, bitmap); #endif // Memory layout is: @@ -91,13 +86,13 @@ internal BufferScope ConvertToBuffer() /// /// Initializes a standard, optimal, or custom color palette. /// - /// The palette type. + /// The palette type. /// /// The number of colors you want to have in an optimal palette based on a the specified bitmap. /// /// to include the transparent color in the palette. internal static ColorPalette InitializePalette( - PaletteType paletteType, + PaletteType fixedPaletteType, int colorCount, bool useTransparentColor, IPointer? bitmap) @@ -109,7 +104,7 @@ internal static ColorPalette InitializePalette( { PInvoke.GdipInitializePalette( (GdiPlus.ColorPalette*)b, - (GdiPlus.PaletteType)paletteType, + (GdiPlus.PaletteType)fixedPaletteType, colorCount, useTransparentColor, bitmap is null ? null : bitmap.Pointer).ThrowIfFailed(); diff --git a/src/System.Drawing.Common/src/System/Drawing/Imaging/PaletteType.cs b/src/System.Drawing.Common/src/System/Drawing/Imaging/PaletteType.cs index 1b5ce8077a1..1997338faa9 100644 --- a/src/System.Drawing.Common/src/System/Drawing/Imaging/PaletteType.cs +++ b/src/System.Drawing.Common/src/System/Drawing/Imaging/PaletteType.cs @@ -18,7 +18,7 @@ public enum PaletteType /// /// A palette that has two colors. This palette type is suitable for bitmaps that store 1 bit per pixel. /// - FixedBW = GdiPlus.PaletteType.PaletteTypeFixedBW, + FixedBlackAndWhite = GdiPlus.PaletteType.PaletteTypeFixedBW, /// /// A palette based on two intensities each (off or full) for the red, green, and blue channels. Also contains the diff --git a/src/System.Drawing.Common/tests/System/Drawing/BitmapTests.cs b/src/System.Drawing.Common/tests/System/Drawing/BitmapTests.cs index 2ba3c9ea706..fdd4377c77a 100644 --- a/src/System.Drawing.Common/tests/System/Drawing/BitmapTests.cs +++ b/src/System.Drawing.Common/tests/System/Drawing/BitmapTests.cs @@ -1638,8 +1638,8 @@ public void SaveToRestrictiveStream(bool canRead, bool canSeek) // Format16bppGrayScale is not supported for conversion { PixelFormat.Format16bppGrayScale, DitherType.None, PaletteType.FixedHalftone256 }, { PixelFormat.Format16bppGrayScale, DitherType.ErrorDiffusion, PaletteType.FixedHalftone8 }, - { PixelFormat.Format16bppGrayScale, DitherType.None, PaletteType.FixedBW }, - { PixelFormat.Format16bppGrayScale, DitherType.Solid, PaletteType.FixedBW }, + { PixelFormat.Format16bppGrayScale, DitherType.None, PaletteType.FixedBlackAndWhite }, + { PixelFormat.Format16bppGrayScale, DitherType.Solid, PaletteType.FixedBlackAndWhite }, { PixelFormat.Format16bppRgb565, (DitherType)(-1), PaletteType.FixedHalftone256 }, { PixelFormat.Format16bppRgb565, (DitherType)(-1), (PaletteType)(-1) }, };