forked from dotnet/winforms
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change implements Bitmap.ConvertFormat (see dotnet#8827). Until we get through API review some of the methods are under `[RequiresPreviewFeatures]`.
- Loading branch information
1 parent
27713b2
commit 8a8e48e
Showing
8 changed files
with
367 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/System.Drawing.Common/src/System/Drawing/Imaging/DitherType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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 | ||
|
||
namespace System.Drawing.Imaging; | ||
|
||
/// <summary> | ||
/// Algorithm for dithering images with a reduced color palette. | ||
/// </summary> | ||
public enum DitherType | ||
{ | ||
/// <summary> | ||
/// No dithering is performed. Pixels in the source bitmap are mapped to the nearest color in the palette specified | ||
/// by the palette parameter of the <see cref="Bitmap.ConvertFormat(PixelFormat, DitherType, PaletteType, ColorPalette?, float)"/> | ||
/// method. This algorithm can be used with any palette other than <see cref="PaletteType.Custom"/>. | ||
/// </summary> | ||
None = GdiPlus.DitherType.DitherTypeNone, | ||
|
||
/// <summary> | ||
/// No dithering is performed. Pixels in the source bitmap are mapped to the nearest color in the palette specified | ||
/// by the palette parameter of the <see cref="Bitmap.ConvertFormat(PixelFormat, DitherType, PaletteType, ColorPalette?, float)"/> | ||
/// method. This algorithm can be used with any palette. | ||
/// </summary> | ||
Solid = GdiPlus.DitherType.DitherTypeSolid, | ||
|
||
/// <summary> | ||
/// You can use this algorithm to perform dithering based on the colors in one of the standard fixed palettes. You | ||
/// can also use this algorithm to convert a bitmap to a 16-bits-per-pixel format that has no palette. | ||
/// </summary> | ||
Ordered4x4 = GdiPlus.DitherType.DitherTypeOrdered4x4, | ||
|
||
/// <summary> | ||
/// Dithering is performed using the colors in one of the standard fixed palettes. | ||
/// </summary> | ||
Ordered8x8 = GdiPlus.DitherType.DitherTypeOrdered8x8, | ||
|
||
/// <summary> | ||
/// Dithering is performed using the colors in one of the standard fixed palettes. | ||
/// </summary> | ||
Ordered16x16 = GdiPlus.DitherType.DitherTypeOrdered16x16, | ||
|
||
/// <summary> | ||
/// Dithering is performed using the colors in one of the standard fixed palettes. | ||
/// </summary> | ||
Spiral4x4 = GdiPlus.DitherType.DitherTypeSpiral4x4, | ||
|
||
/// <summary> | ||
/// Dithering is performed using the colors in one of the standard fixed palettes. | ||
/// </summary> | ||
Spiral8x8 = GdiPlus.DitherType.DitherTypeSpiral8x8, | ||
|
||
/// <summary> | ||
/// Dithering is performed using the colors in one of the standard fixed palettes. | ||
/// </summary> | ||
DualSpiral4x4 = GdiPlus.DitherType.DitherTypeDualSpiral4x4, | ||
|
||
/// <summary> | ||
/// Dithering is performed using the colors in one of the standard fixed palettes. | ||
/// </summary> | ||
DualSpiral8x8 = GdiPlus.DitherType.DitherTypeDualSpiral8x8, | ||
|
||
/// <summary> | ||
/// Dithering is performed based on the palette specified by the palette parameter of the | ||
/// <see cref="Bitmap.ConvertFormat(PixelFormat, DitherType, PaletteType, ColorPalette?, float)"/> method. | ||
/// This algorithm can be used with any palette. | ||
/// </summary> | ||
ErrorDiffusion = GdiPlus.DitherType.DitherTypeErrorDiffusion | ||
} | ||
#endif |
20 changes: 11 additions & 9 deletions
20
src/System.Drawing.Common/src/System/Drawing/Imaging/PaletteFlags.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace System.Drawing.Imaging; | ||
|
||
/// <summary> | ||
/// Specifies the type of color data in the system palette. The data can be color data with alpha, grayscale only, | ||
/// or halftone data. | ||
/// Specifies the type of color data in the system palette. The data can be color data with alpha, grayscale only, | ||
/// or halftone data. | ||
/// </summary> | ||
[Flags] | ||
public enum PaletteFlags | ||
{ | ||
/// <summary> | ||
/// Specifies alpha data. | ||
/// Specifies alpha data. | ||
/// </summary> | ||
HasAlpha = 0x0001, | ||
HasAlpha = GdiPlus.PaletteFlags.PaletteFlagsHasAlpha, | ||
|
||
/// <summary> | ||
/// Specifies grayscale data. | ||
/// Specifies grayscale data. | ||
/// </summary> | ||
GrayScale = 0x0002, | ||
GrayScale = GdiPlus.PaletteFlags.PaletteFlagsGrayScale, | ||
|
||
/// <summary> | ||
/// Specifies halftone data. | ||
/// Specifies halftone data. | ||
/// </summary> | ||
Halftone = 0x0004 | ||
Halftone = GdiPlus.PaletteFlags.PaletteFlagsHalftone | ||
} |
78 changes: 78 additions & 0 deletions
78
src/System.Drawing.Common/src/System/Drawing/Imaging/PaletteType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// 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 | ||
|
||
namespace System.Drawing.Imaging; | ||
|
||
/// <summary> | ||
/// Color palette types. | ||
/// </summary> | ||
public enum PaletteType | ||
{ | ||
/// <summary> | ||
/// An arbitrary custom palette specified by the caller. | ||
/// </summary> | ||
Custom = GdiPlus.PaletteType.PaletteTypeCustom, | ||
|
||
/// <summary> | ||
/// A palette that has two colors. This palette type is suitable for bitmaps that store 1 bit per pixel. | ||
/// </summary> | ||
FixedBW = GdiPlus.PaletteType.PaletteTypeFixedBW, | ||
|
||
/// <summary> | ||
/// A palette based on two intensities each (off or full) for the red, green, and blue channels. Also contains the | ||
/// 16 colors of the system palette. Because all eight of the on/off combinations of red, green, and blue are | ||
/// already in the system palette, this palette is the same as the system palette. This palette type is suitable | ||
/// for bitmaps that store 4 bits per pixel. | ||
/// </summary> | ||
FixedHalftone8 = GdiPlus.PaletteType.PaletteTypeFixedHalftone8, | ||
|
||
/// <summary> | ||
/// A palette based on three intensities each for the red, green, and blue channels. Also contains the 16 colors of | ||
/// the system palette. Eight of the 16 system palette colors are among the 27 three-intensity combinations of red, | ||
/// green, and blue, so the total number of colors in the palette is 35. If the palette also includes the transparent | ||
/// color, the total number of colors is 36. | ||
/// </summary> | ||
FixedHalftone27 = GdiPlus.PaletteType.PaletteTypeFixedHalftone27, | ||
|
||
/// <summary> | ||
/// A palette based on four intensities each for the red, green, and blue channels. Also contains the 16 colors of | ||
/// the system palette. Eight of the 16 system palette colors are among the 64 four-intensity combinations of red, | ||
/// green, and blue, so the total number of colors in the palette is 72. If the palette also includes the transparent | ||
/// color, the total number of colors is 73. | ||
/// </summary> | ||
FixedHalftone64 = GdiPlus.PaletteType.PaletteTypeFixedHalftone64, | ||
|
||
/// <summary> | ||
/// A palette based on five intensities each for the red, green, and blue channels. Also contains the 16 colors of | ||
/// the system palette. Eight of the 16 system palette colors are among the 125 five-intensity combinations of red, | ||
/// green, and blue, so the total number of colors in the palette is 133. If the palette also includes the transparent | ||
/// color, the total number of colors is 134. | ||
/// </summary> | ||
FixedHalftone125 = GdiPlus.PaletteType.PaletteTypeFixedHalftone125, | ||
|
||
/// <summary> | ||
/// A palette based on six intensities each for the red, green, and blue channels. Also contains the 16 colors of | ||
/// the system palette. Eight of the 16 system palette colors are among the 216 six-intensity combinations of red, | ||
/// green, and blue, so the total number of colors in the palette is 224. If the palette also includes the transparent | ||
/// color, the total number of colors is 225. This palette is sometimes called the Windows halftone palette or | ||
/// the Web palette. | ||
/// </summary> | ||
FixedHalftone216 = GdiPlus.PaletteType.PaletteTypeFixedHalftone216, | ||
|
||
/// <summary> | ||
/// A palette based on 6 intensities of red, 7 intensities of green, and 6 intensities of blue. The system palette | ||
/// is not included. The total number of colors is 252. If the palette also includes the transparent color, the | ||
/// total number of colors is 253. | ||
/// </summary> | ||
FixedHalftone252 = GdiPlus.PaletteType.PaletteTypeFixedHalftone252, | ||
|
||
/// <summary> | ||
/// A palette based on 8 intensities of red, 8 intensities of green, and 4 intensities of blue. The system palette | ||
/// is not included. The total number of colors is 256. If the transparent color is included in this palette, it | ||
/// must replace one of the RGB combinations. | ||
/// </summary> | ||
FixedHalftone256 = GdiPlus.PaletteType.PaletteTypeFixedHalftone256 | ||
} | ||
#endif |
Oops, something went wrong.