internal static LCMSEnums.ConvertProfileStatus ConvertToProfile( LCMSProfileHandle inputProfile, LCMSProfileHandle outputProfile, RenderingIntent renderingIntent, LCMSEnums.TransformFlags flags, ref LCMSStructs.BitmapData input, ref LCMSStructs.BitmapData output ) { if (IntPtr.Size == 8) { return(LCMS_64.ConvertToProfile( inputProfile, outputProfile, renderingIntent, flags, ref input, ref output )); } else { return(LCMS_86.ConvertToProfile( inputProfile, outputProfile, renderingIntent, flags, ref input, ref output )); } }
internal static extern LCMSEnums.ConvertProfileStatus ConvertToProfile( LCMSProfileHandle inputProfile, LCMSProfileHandle outputProfile, RenderingIntent renderingIntent, LCMSEnums.TransformFlags flags, [In()] ref LCMSStructs.BitmapData input, [In()] ref LCMSStructs.BitmapData output );
internal static extern LCMSTransformHandleX64 CreateProofingTransformBGRA8( LCMSProfileHandle input, LCMSProfileHandle display, RenderingIntent displayIntent, LCMSProfileHandle proofing, RenderingIntent proofingIntent, LCMSEnums.TransformFlags flags );
internal static LCMSTransformHandle CreateProofingTransformBGRA8( LCMSProfileHandle input, LCMSProfileHandle display, RenderingIntent displayIntent, LCMSProfileHandle proofing, RenderingIntent proofingIntent, bool checkGamut, Color gamutWarningColor, bool blackPointCompensation ) { LCMSEnums.TransformFlags flags = LCMSEnums.TransformFlags.None; if (checkGamut) { flags |= LCMSEnums.TransformFlags.GamutCheck; SetGamutWarningColor(gamutWarningColor); } else { flags |= LCMSEnums.TransformFlags.SoftProofing; } if (UseBlackPointCompensation(blackPointCompensation, proofingIntent)) { flags |= LCMSEnums.TransformFlags.BlackPointCompensation; } if (IntPtr.Size == 8) { return(LCMS_64.CreateProofingTransformBGRA8( input, display, displayIntent, proofing, proofingIntent, flags )); } else { return(LCMS_86.CreateProofingTransformBGRA8( input, display, displayIntent, proofing, proofingIntent, flags )); } }
/// <summary> /// Converts the image to the specified output color profile. /// </summary> /// <param name="inputProfilePath">The path of the input color profile.</param> /// <param name="outputProfilePath">The path of the output color profile.</param> /// <param name="intent">The rendering intent to use for the conversion.</param> /// <param name="blackPointCompensation"><c>true</c> if black point compensation should be used; otherwise, <c>false</c>.</param> /// <param name="source">The source image to convert.</param> /// <param name="destination">The destination image to place the converted pixels.</param> /// <exception cref="LCMSException"> /// The input profile could not be opened. /// -or- /// The output profile could not be opened. /// -or- /// The color transform could not be created. /// -or- /// The source and destination images are not the same size. /// </exception> internal static void ConvertToColorProfile( string inputProfilePath, string outputProfilePath, RenderingIntent intent, bool blackPointCompensation, Surface source, WriteableBitmap destination ) { using (LCMSProfileHandle inputProfile = LCMSHelper.OpenColorProfile(inputProfilePath)) { if (inputProfile.IsInvalid) { throw new LCMSException(Resources.OpenSourceProfileError); } using (LCMSProfileHandle outputProfile = LCMSHelper.OpenColorProfile(outputProfilePath)) { if (outputProfile.IsInvalid) { throw new LCMSException(Resources.OpenDestiniationProfileError); } LCMSStructs.BitmapData sourceBitmapData = new LCMSStructs.BitmapData { width = (uint)source.Width, height = (uint)source.Height, format = LCMSEnums.BitmapFormat.Bgra8, stride = (uint)source.Stride, scan0 = source.Scan0.Pointer }; LCMSStructs.BitmapData destinationBitmapData = new LCMSStructs.BitmapData { width = (uint)destination.PixelWidth, height = (uint)destination.PixelHeight, format = BitmapFormatFromWICPixelFormat(destination.Format), stride = (uint)destination.BackBufferStride, scan0 = destination.BackBuffer }; LCMSEnums.TransformFlags flags = LCMSEnums.TransformFlags.None; if (LCMSHelper.UseBlackPointCompensation(blackPointCompensation, intent)) { flags |= LCMSEnums.TransformFlags.BlackPointCompensation; } LCMSEnums.ConvertProfileStatus status = LCMSHelper.ConvertToProfile( inputProfile, outputProfile, intent, flags, ref sourceBitmapData, ref destinationBitmapData ); if (status != LCMSEnums.ConvertProfileStatus.Ok) { switch (status) { case LCMSEnums.ConvertProfileStatus.InvalidParameter: throw new LCMSException(Resources.ConvertProfileInvalidParameter); case LCMSEnums.ConvertProfileStatus.DifferentImageDimensions: throw new LCMSException(Resources.DifferentImageDimensions); case LCMSEnums.ConvertProfileStatus.CreateTransformFailed: throw new LCMSException(Resources.CreateTransformError); default: break; } } } } }