コード例 #1
0
 /// <summary>
 /// Multiplies the Color's Saturation, and Luminance or Brightness by the arguments;
 /// and optionally specifies the output Alpha.
 /// </summary>
 /// <param name="color">The color to transform.</param>
 /// <param name="colorTransformMode">Transform mode.</param>
 /// <param name="saturationTransform">The transformation multiplier.</param>
 /// <param name="brightnessTransform">The transformation multiplier.</param>
 /// <param name="outputAlpha">Can optionally specify the Alpha to directly
 /// set on the output. If null, then the input <paramref name="color"/>
 /// Alpha is used.</param>
 /// <returns>RGB Color.</returns>
 public static Color TransformSaturationAndValue(
     Color color,
     ColorTransformMode colorTransformMode,
     double saturationTransform,
     double brightnessTransform,
     byte?outputAlpha = null)
 {
     double[] hsl = colorTransformMode == ColorTransformMode.Hsl
                                 ? SimpleColorTransforms.RgbToHsl(color)
                                 : SimpleColorTransforms.RgbToHsb(color);
     if ((SystemMath.Abs(hsl[1]) < SimpleColorTransforms.tolerance) &&
         (saturationTransform > 1D))
     {
         hsl[1] = saturationTransform - 1D;
     }
     else
     {
         hsl[1] *= saturationTransform;
     }
     if ((SystemMath.Abs(hsl[2]) < SimpleColorTransforms.tolerance) &&
         (brightnessTransform > 1D))
     {
         hsl[2] = brightnessTransform - 1D;
     }
     else
     {
         hsl[2] *= brightnessTransform;
     }
     return(colorTransformMode == ColorTransformMode.Hsl
                                 ? SimpleColorTransforms.HslToRgb(hsl[0], hsl[1], hsl[2], outputAlpha ?? color.A)
                                 : SimpleColorTransforms.HsbToRgb(hsl[0], hsl[1], hsl[2], outputAlpha ?? color.A));
 }
コード例 #2
0
 private static extern IntPtr CreateMultiProfileTransform(
     [In] IntPtr[] profiles,
     uint nProfiles,
     [In] uint[] intents,
     uint nIntents,
     ColorTransformMode flags,
     uint indexPreferredCmm);
コード例 #3
0
 /// <summary>
 /// Multiplies the Color's Luminance or Brightness by the argument;
 /// and optionally specifies the output Alpha.
 /// </summary>
 /// <param name="color">The color to transform.</param>
 /// <param name="colorTransformMode">Transform mode.</param>
 /// <param name="brightnessTransform">The transformation multiplier.</param>
 /// <param name="outputAlpha">Can optionally specify the Alpha to directly
 /// set on the output. If null, then the input <paramref name="color"/>
 /// Alpha is used.</param>
 public static Color TransformBrightness(Color color, ColorTransformMode colorTransformMode, double brightnessTransform, byte?outputAlpha = null)
 {
     double[] hsl = colorTransformMode == ColorTransformMode.Hsl? ColorUtil.RgBtoHsl(color): ColorUtil.RgBtoHsb(color);
     if ((Math.Abs(hsl[2]) < ColorUtil.tolerance) && (brightnessTransform > 1D))
     {
         hsl[2] = brightnessTransform - 1D;
     }
     else
     {
         hsl[2] *= brightnessTransform;
     }
     return(colorTransformMode == ColorTransformMode.Hsl
                                 ? ColorUtil.HsLtoRgb(hsl[0], hsl[1], hsl[2], outputAlpha ?? color.A)
                                 : ColorUtil.HsBtoRgb(hsl[0], hsl[1], hsl[2], outputAlpha ?? color.A));
 }
コード例 #4
0
            internal static IntPtr CreateColorTransform(ref LogColorSpace colorSpace, IntPtr hDestProfile, IntPtr hTargetProfile, ColorTransformMode transformMode)
            {
                var hTransform = _CreateColorTransform(ref colorSpace, hDestProfile, hTargetProfile, transformMode);

                if (hTransform == IntPtr.Zero)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }
                return(hTransform);
            }
コード例 #5
0
 private static extern IntPtr _CreateColorTransform(
     [In] ref LogColorSpace pLogColorSpace,
     [In] IntPtr hDestProfile,
     [In] IntPtr hTargetProfile,
     [In] ColorTransformMode dwFlags);