Files
UVtools/UVtools.Core/Extensions/DrawingExtensions.cs
T
Tiago Conceição f1dea71c60 v2.4.7
* (Add) Computed used material milliliters for each layer, it will dynamic change if pixels are added or subtracted
* (Add) Computed used material milliliters for whole model, it will dynamic change if pixels are added or subtracted
* (Improvement) Round cost, material ml and grams from 2 to 3 decimals
* (Improvement) Operation profiles: Allow to save and get a custom layer range instead of pre-defined ranges
* **(Improvement)** PhotonWorkshop files: (#149)
   * Fill in the display width, height and MaxZ values for the printers
   * Fill in the xy pixel size values for the printers
   * Change ResinType to PriceCurrencyDec and Add PriceCurrencySymbol
   * Change Offset1 on header to PrintTime
   * Change Offset1 on layer table as NonZeroPixelCount, the number of white pixels on the layer
   * Fix LayerPositionZ to calculate the correct value based on each layer height and fix internal layer layer height which was been set to position z
   * Force PerLayerOverride to be always 1 after save the file
* (Fix) Actions - Remove and clone layers was selecting all layer range instead of the current layer
* (Fix) Redo last action was not getting back the layer range on some cases
2021-02-17 05:26:53 +00:00

25 lines
826 B
C#

using System;
using System.Drawing;
namespace UVtools.Core.Extensions
{
public static class DrawingExtensions
{
public static Color FactorColor(this Color color, byte pixelColor, byte min = 0, byte max = byte.MaxValue) =>
FactorColor(color, pixelColor / 255f, min, max);
public static Color FactorColor(this Color color, float factor, byte min = 0, byte max = byte.MaxValue)
{
byte r = (byte)(color.R == 0 ? 0 :
Math.Min(Math.Max(min, color.R * factor), max));
byte g = (byte)(color.G == 0 ? 0 :
Math.Min(Math.Max(min, color.G * factor), max));
byte b = (byte)(color.B == 0 ? 0 :
Math.Min(Math.Max(min, color.B * factor), max));
return Color.FromArgb(r, g, b);
}
}
}