private void btnUploadPrint_Click(object sender, RoutedEventArgs e) { int jobID = Convert.ToInt32(cmbJobID.SelectedValue); string SampleFilePath = jobClass.getSampleImagePath(jobID); Microsoft.Win32.OpenFileDialog open = new Microsoft.Win32.OpenFileDialog(); if (open.ShowDialog() == true) { Aurigma.GraphicsMill.Bitmap SampleBitmap = new Bitmap(SampleFilePath); Aurigma.GraphicsMill.Bitmap PrintedOutCome = new Bitmap(open.FileName); if (SampleBitmap.PixelFormat.IsRgb) { SampleBitmap.ColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb(); SampleBitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms; SampleBitmap.ColorManagement.DestinationProfile = new Aurigma.GraphicsMill.ColorProfile(@"C:\windows\system32\spool\drivers\color\EuroscaleCoated.icc"); SampleBitmap.ColorManagement.Convert(Aurigma.GraphicsMill.ColorSpace.Cmyk, SampleBitmap.HasAlpha, SampleBitmap.PixelFormat.IsExtended); } if (PrintedOutCome.PixelFormat.IsRgb) { PrintedOutCome.ColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb(); PrintedOutCome.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms; PrintedOutCome.ColorManagement.DestinationProfile = new Aurigma.GraphicsMill.ColorProfile(@"C:\windows\system32\spool\drivers\color\EuroscaleCoated.icc"); PrintedOutCome.ColorManagement.Convert(Aurigma.GraphicsMill.ColorSpace.Cmyk, PrintedOutCome.HasAlpha, PrintedOutCome.PixelFormat.IsExtended); } string selectedChannel = cmbCurrentColour.SelectedValue.ToString(); Aurigma.GraphicsMill.Bitmap selectedColourSampleBitmap = new Bitmap(SampleBitmap); Aurigma.GraphicsMill.Bitmap selectedColourPrintedOutCome = new Bitmap(PrintedOutCome); if (selectedChannel == "Cyan") { selectedColourSampleBitmap = SampleBitmap.Channels[Aurigma.GraphicsMill.Channel.Cyan]; selectedColourPrintedOutCome = PrintedOutCome.Channels[Aurigma.GraphicsMill.Channel.Cyan]; } else if (selectedChannel == "Magenta") { selectedColourSampleBitmap = SampleBitmap.Channels[Aurigma.GraphicsMill.Channel.Magenta]; selectedColourPrintedOutCome = PrintedOutCome.Channels[Aurigma.GraphicsMill.Channel.Magenta]; } else if (selectedChannel == "Yellow") { selectedColourSampleBitmap = SampleBitmap.Channels[Aurigma.GraphicsMill.Channel.Yellow]; selectedColourPrintedOutCome = PrintedOutCome.Channels[Aurigma.GraphicsMill.Channel.Yellow]; } else if (selectedChannel == "Black") { selectedColourSampleBitmap = SampleBitmap.Channels[Aurigma.GraphicsMill.Channel.Black]; selectedColourPrintedOutCome = PrintedOutCome.Channels[Aurigma.GraphicsMill.Channel.Black]; } //Ink valve values System.Drawing.Bitmap bmpSelectedColourFromSample = new System.Drawing.Bitmap((System.Drawing.Bitmap)selectedColourSampleBitmap); System.Drawing.Bitmap bmpSelectedColourFromPrintedOutCome = new System.Drawing.Bitmap((System.Drawing.Bitmap)selectedColourPrintedOutCome); System.Drawing.Bitmap bmpResultAfterDifferentiate = new Difference(bmpSelectedColourFromSample).Apply(bmpSelectedColourFromPrintedOutCome); bmpResultAfterDifferentiate.Save("bmpResultAfterDifferentiate.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); System.Drawing.Bitmap bmpInvertedResult = new Invert().Apply(new System.Drawing.Bitmap("bmpResultAfterDifferentiate.jpg")); bmpInvertedResult.Save("bmpInvertedResult.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); Bitmap bmpForCropping = new Bitmap(bmpInvertedResult); int partWidth = bmpForCropping.Width / 12; int partHeight = bmpForCropping.Height; System.Windows.Controls.Image[] imgArr = new System.Windows.Controls.Image[12]; imgArr[0] = image15; imgArr[1] = image16; imgArr[2] = image17; imgArr[3] = image18; imgArr[4] = image19; imgArr[5] = image20; imgArr[6] = image21; imgArr[7] = image22; imgArr[8] = image23; imgArr[9] = image24; imgArr[10] = image25; imgArr[11] = image26; Label[] lblArr = new Label[12]; lblArr[0] = lblValve101; lblArr[1] = lblValve102; lblArr[2] = lblValve103; lblArr[3] = lblValve104; lblArr[4] = lblValve105; lblArr[5] = lblValve106; lblArr[6] = lblValve107; lblArr[7] = lblValve108; lblArr[8] = lblValve109; lblArr[9] = lblValve110; lblArr[10] = lblValve111; lblArr[11] = lblValve112; int startingPoint = 0; Aurigma.GraphicsMill.Histogram histogram; for (int i = 0; i < 12; i++) { System.Drawing.Rectangle rect = new System.Drawing.Rectangle(startingPoint, 0, partWidth, partHeight); Bitmap croppedPart = new Bitmap(bmpForCropping); croppedPart.Transforms.Crop(rect); BitmapImage croppedBitmap = ConvertAurigmaImageToBitmapImage(croppedPart); imgArr[i].Source = croppedBitmap; startingPoint += partWidth; histogram = croppedPart.Statistics.GetSumHistogram(); double histoValue = Convert.ToDouble(histogram.Mean); double calcValue = (255 - histoValue) / (255); double precentageValue = calcValue * 100; lblArr[i].Content = precentageValue.ToString("0.00") + " %"; } } }