mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 11:40:40 -07:00
Fix for bug 1444, the WuQuantizer doesn't work if the colors are already less than 256 so we just create a 8bpp image from the source.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2451 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
e30939093a
commit
2730ac5540
4 changed files with 57 additions and 14 deletions
|
@ -1199,20 +1199,21 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="backgroundColor">The color to fill with, or Color.Empty to take the default depending on the pixel format</param>
|
||||
/// <param name="horizontalResolution"></param>
|
||||
/// <param name="verticalResolution"></param>
|
||||
/// <returns></returns>
|
||||
/// <returns>Bitmap</returns>
|
||||
public static Bitmap CreateEmpty(int width, int height, PixelFormat format, Color backgroundColor, float horizontalResolution, float verticalResolution) {
|
||||
// Create a new "clean" image
|
||||
Bitmap newImage = new Bitmap(width, height, format);
|
||||
newImage.SetResolution(horizontalResolution, verticalResolution);
|
||||
|
||||
using (Graphics graphics = Graphics.FromImage(newImage)) {
|
||||
// Make sure the background color is what we want (transparent or white, depending on the pixel format)
|
||||
if (!Color.Empty.Equals(backgroundColor)) {
|
||||
graphics.Clear(backgroundColor);
|
||||
} else if (Image.IsAlphaPixelFormat(format)) {
|
||||
graphics.Clear(Color.Transparent);
|
||||
} else {
|
||||
graphics.Clear(Color.White);
|
||||
if (format != PixelFormat.Format8bppIndexed) {
|
||||
using (Graphics graphics = Graphics.FromImage(newImage)) {
|
||||
// Make sure the background color is what we want (transparent or white, depending on the pixel format)
|
||||
if (!Color.Empty.Equals(backgroundColor)) {
|
||||
graphics.Clear(backgroundColor);
|
||||
} else if (Image.IsAlphaPixelFormat(format)) {
|
||||
graphics.Clear(Color.Transparent);
|
||||
} else {
|
||||
graphics.Clear(Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newImage;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue