Esempio n. 1
0
        public void Test()
        {
            Map <RectCoord> map = CreateMap();
            MapChangeRecorder <RectCoord> mapChangeRecorder = new MapChangeRecorder <RectCoord>();

            map.Subscribe(mapChangeRecorder);

            map.Add(new RectCoord(1, 1), new MapNode()
            {
                Landform = new NodeLandformInfo()
                {
                    TypeID = "111",
                    Angle  = 111,
                },
            });

            map.Remove(new RectCoord(0, 0));

            map[new RectCoord(1, 1)] = new MapNode()
            {
                Landform = new NodeLandformInfo()
                {
                    TypeID = "11",
                    Angle  = 11,
                },
            };

            var archiveMap = mapChangeRecorder.GetArchiveMap(map);

            Map <RectCoord> map2 = CreateMap();

            MapChangeRecorder <RectCoord> .AddArchived(map2, archiveMap);

            Contrast.AreSame <RectCoord, MapNode>(map, map2);
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (FileId != null)
         {
             hashCode = hashCode * 59 + FileId.GetHashCode();
         }
         if (PageRange != null)
         {
             hashCode = hashCode * 59 + PageRange.GetHashCode();
         }
         hashCode = hashCode * 59 + RoiLeft.GetHashCode();
         hashCode = hashCode * 59 + RoiTop.GetHashCode();
         hashCode = hashCode * 59 + RoiWidth.GetHashCode();
         hashCode = hashCode * 59 + RoiHeight.GetHashCode();
         hashCode = hashCode * 59 + GammaCorrection.GetHashCode();
         hashCode = hashCode * 59 + Brightness.GetHashCode();
         hashCode = hashCode * 59 + Contrast.GetHashCode();
         hashCode = hashCode * 59 + Saturation.GetHashCode();
         hashCode = hashCode * 59 + AutoContrastEnhancement.GetHashCode();
         hashCode = hashCode * 59 + ContrastHistogramStretch.GetHashCode();
         return(hashCode);
     }
 }
Esempio n. 3
0
			public Panos_1(String SVGPanos1String)
			{
				int tempInt;
				String[] valuesString = SVGPanos1String.Split(' ');
				if (int.TryParse(valuesString[0], out tempInt))
					family = (Family)tempInt;
				if (int.TryParse(valuesString[1], out tempInt))
					serifStyle = (Serif_Style)tempInt;
				if (int.TryParse(valuesString[2], out tempInt))
					weight = (Weight)tempInt;
				if (int.TryParse(valuesString[3], out tempInt))
					proportion = (Proportion)tempInt;
				if (int.TryParse(valuesString[4], out tempInt))
					contrast = (Contrast)tempInt;
				if (int.TryParse(valuesString[5], out tempInt))
					strokeVariation = (Stroke_Variation)tempInt;
				if (int.TryParse(valuesString[6], out tempInt))
					armStyle = (Arm_Style)tempInt;
				if (int.TryParse(valuesString[7], out tempInt))
					letterform = (Letterform)tempInt;
				if (int.TryParse(valuesString[8], out tempInt))
					midline = (Midline)tempInt;
				if (int.TryParse(valuesString[0], out tempInt))
					xHeight = (XHeight)tempInt;
			}
Esempio n. 4
0
        public override long GetDistance(Bitmap img, Bitmap selfImg, int type)
        {
            long result;

            byte[] pixels1;
            byte[] pixels2;
            var    watch = System.Diagnostics.Stopwatch.StartNew();

            if (type == 0)
            {
                pixels1 = ColorHistogram.Histogram(img);
                watch.Stop();
                pixels2 = ColorHistogram.Histogram(selfImg);
                Console.WriteLine("Hpropio: " + watch.ElapsedMilliseconds);
                watch  = System.Diagnostics.Stopwatch.StartNew();
                result = DarwinDistance(pixels1, pixels2);
                watch.Stop();
                Console.WriteLine("Casas" + watch.ElapsedMilliseconds);
            }
            else
            {
                pixels1 = Contrast.ContrastHistogram(img);
                watch.Stop();
                pixels2 = Contrast.ContrastHistogram(selfImg);
                Console.WriteLine("Hpropio: " + watch.ElapsedMilliseconds);
                watch  = System.Diagnostics.Stopwatch.StartNew();
                result = DarwinDistance(pixels1, pixels2);
                Console.WriteLine("Darwin: " + watch.ElapsedMilliseconds);
            }
            return(result);
        }
Esempio n. 5
0
        public void Save(Stream s)
        {
            XmlWriter w = null;

            try
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent           = true;
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                w = XmlWriter.Create(s, settings);
                w.WriteStartElement("ColorMap");
                w.WriteAttributeString("Type", Type.ToString());
                w.WriteAttributeString("Bias", Bias.ToString());
                w.WriteAttributeString("Contrast", Contrast.ToString());
                SaveCore(w);
                w.WriteEndElement();
            }
            finally
            {
                if (w != null)
                {
                    w.Close();
                }
            }
        }
        /// <summary>
        /// Returns true if ImageAdjustParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of ImageAdjustParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ImageAdjustParameters input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     FileId == input.FileId ||
                     (FileId != null &&
                      FileId.Equals(input.FileId))
                     ) &&
                 (
                     PageRange == input.PageRange ||
                     (PageRange != null &&
                      PageRange.Equals(input.PageRange))
                 ) &&
                 (
                     RoiLeft == input.RoiLeft ||
                     RoiLeft.Equals(input.RoiLeft)
                 ) &&
                 (
                     RoiTop == input.RoiTop ||
                     RoiTop.Equals(input.RoiTop)
                 ) &&
                 (
                     RoiWidth == input.RoiWidth ||
                     RoiWidth.Equals(input.RoiWidth)
                 ) &&
                 (
                     RoiHeight == input.RoiHeight ||
                     RoiHeight.Equals(input.RoiHeight)
                 ) &&
                 (
                     GammaCorrection == input.GammaCorrection ||
                     GammaCorrection.Equals(input.GammaCorrection)
                 ) &&
                 (
                     Brightness == input.Brightness ||
                     Brightness.Equals(input.Brightness)
                 ) &&
                 (
                     Contrast == input.Contrast ||
                     Contrast.Equals(input.Contrast)
                 ) &&
                 (
                     Saturation == input.Saturation ||
                     Saturation.Equals(input.Saturation)
                 ) &&
                 (
                     AutoContrastEnhancement == input.AutoContrastEnhancement ||
                     AutoContrastEnhancement.Equals(input.AutoContrastEnhancement)
                 ) &&
                 (
                     ContrastHistogramStretch == input.ContrastHistogramStretch ||
                     ContrastHistogramStretch.Equals(input.ContrastHistogramStretch)
                 ));
        }
Esempio n. 7
0
 public PicBACWindow(BitmapSource bs)
 {
     InitializeComponent();
     this.bs             = bs;
     Content.DataContext = picBACControl;
     Brightness.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     Contrast.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
 }
Esempio n. 8
0
 /// <summary>
 /// Adjusts contrast using memory-friendly Pipeline API
 /// </summary>
 private static void ContrastMemoryFriendly()
 {
     using (var reader = ImageReader.Create("../../../../_Input/Chicago.jpg"))
         using (var contrast = new Contrast(0.2f))
             using (var writer = ImageWriter.Create("../../../../_Output/ContrastMemoryFriendly.jpg"))
             {
                 Pipeline.Run(reader + contrast + writer);
             }
 }
        private static DataRow ReadOneTxtLineToDataRow(DataRow inRow, ArrayList inConList, ArrayList inSrcList)
        {
            try
            {
                string text1 = "";
                for (int num1 = 0; num1 < inConList.Count; num1++)
                {
                    Contrast contrast1 = inConList[num1] as Contrast;
                    text1 = "";
                    if (contrast1.SrcOp.Count == 1)
                    {
                        if ((contrast1.SrcOp[0] as Operand).Type == OperandType.Value)
                        {
                            text1 = (contrast1.SrcOp[0] as Operand).Value;
                        }
                        if ((contrast1.SrcOp[0] as Operand).Type == OperandType.Index)
                        {
                            text1 = inSrcList[(contrast1.SrcOp[0] as Operand).Index] as string;
                        }
                        switch (uncTxt.TestDestDataType(text1, contrast1.DestOp.DataType, contrast1.DestOp.Name))
                        {
                        case 1:
                            inRow[contrast1.DestOp.Name] = text1;
                            break;

                        case -1:
                            return(null);
                        }
                    }
                    else
                    {
                        for (int num3 = 0; num3 < contrast1.SrcOp.Count; num3++)
                        {
                            if ((contrast1.SrcOp[num3] as Operand).Type == OperandType.Value)
                            {
                                text1 = text1 + (contrast1.SrcOp[num3] as Operand).Value;
                            }
                            if ((contrast1.SrcOp[num3] as Operand).Type == OperandType.Index)
                            {
                                text1 = text1 + inSrcList[(contrast1.SrcOp[num3] as Operand).Index];
                            }
                        }
                        if (uncTxt.TestDestDataType(text1, contrast1.DestOp.DataType, contrast1.DestOp.Name) == 1)
                        {
                            inRow[contrast1.DestOp.Name] = text1;
                        }
                    }
                }
                return(inRow);
            }
            catch (Exception exception1)
            {
                ErrorLog.SaveLog("转换一行文本数据至DataRow", exception1);
                return(null);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <param name="image">The current image to process</param>
        /// <param name="newImage">The new Image to return</param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image TransformImage(ImageFactory factory, Image image, Image newImage)
        {
            using (Graphics graphics = Graphics.FromImage(newImage))
            {
                using (ImageAttributes attributes = new ImageAttributes())
                {
                    attributes.SetColorMatrix(this.Matrix);

                    Rectangle rectangle = new Rectangle(0, 0, image.Width, image.Height);

                    graphics.DrawImage(image, rectangle, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes);

                    // Overlay the image with some semi-transparent colors to finish the effect.
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddRectangle(rectangle);

                        // Paint a burgundy rectangle with a transparency of ~30% over the image.
                        // Paint a blue rectangle with a transparency of 20% over the image.
                        using (SolidBrush brush = new SolidBrush(Color.FromArgb(77, 38, 14, 28)))
                        {
                            Region oldClip = graphics.Clip;
                            graphics.Clip = new Region(rectangle);
                            graphics.FillRectangle(brush, rectangle);

                            // Fill the blue.
                            brush.Color = Color.FromArgb(51, 29, 32, 59);
                            graphics.FillRectangle(brush, rectangle);
                            graphics.Clip = oldClip;
                        }
                    }
                }
            }

            // Add brightness and contrast to finish the effect.
            factory.Update(newImage);
            Brightness brightness = new Brightness {
                DynamicParameter = 5
            };

            newImage = (Bitmap)brightness.ProcessImage(factory);

            factory.Update(newImage);
            Contrast contrast = new Contrast {
                DynamicParameter = 85
            };

            newImage = (Bitmap)contrast.ProcessImage(factory);

            // Reassign the image.
            image.Dispose();
            image = newImage;

            return(image);
        }
Esempio n. 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[,] data = { { 1, 2, 4 }, { 4, 3, 5 }, { 5, 3, 6 } };
            RS_Lib.Contrast ct = new Contrast(data);
            textBox1.Text = ct.GetImageContrast().ToString();

            byte[,] ttt = new byte[7, 7] {
                { 0, 1, 2, 3, 0, 1, 2 }, { 1, 2, 3, 0, 1, 2, 3 }, { 2, 3, 0, 1, 2, 3, 0 }, { 3, 0, 1, 2, 3, 0, 1 }, { 0, 1, 2, 3, 0, 1, 2 }, { 1, 2, 3, 0, 1, 2, 3 }, { 2, 3, 0, 1, 2, 3, 0 }
            };
            GLCM g = new GLCM(ttt, 1, 0);
        }
Esempio n. 12
0
        private void ContrastCal()
        {
            SolidBrush darkmoduleBrush  = qrCodeImgControl1.DarkBrush as SolidBrush;
            SolidBrush lightmoduleBrush = qrCodeImgControl1.LightBrush as SolidBrush;
            Color      darkmodule       = darkmoduleBrush == null ? _darkModule : darkmoduleBrush.Color;
            Color      lightmodule      = lightmoduleBrush == null ? _lightModule : lightmoduleBrush.Color;

            Contrast ctrast = ColorContrast.GetContrast(new FormColor(lightmodule), new FormColor(darkmodule));

            label1.Text = ctrast.Ratio.ToString();
        }
Esempio n. 13
0
        private Bitmap changeContrast(Image image, int contrast) // Изменение контраста
        {
            var factory = new ImageFactory(preserveExifData: true);

            factory.Load(bitmap);
            Contrast contrast1 = new Contrast {
                DynamicParameter = contrast
            };

            return((Bitmap)contrast1.ProcessImage(factory));
        }
        public void TestContrastRegex()
        {
            const string Querystring = "contrast=56";
            const int    Expected    = 56;

            Contrast contrast = new Contrast();

            contrast.MatchRegexIndex(Querystring);

            int actual = contrast.DynamicParameter;

            Assert.AreEqual(Expected, actual);
        }
Esempio n. 15
0
        private async void btnNegative_Click(object sender, EventArgs e)
        {
            btnNegative.Enabled = false;
            Bitmap resultImg = await Task.Run(() => Contrast.Negative(state.Image));

            state.Edit(resultImg);
            pictureViewer2.Image = state.Image;
            await pictureViewer2.HistogramView();

            await pictureViewer2.GrayBandView();

            btnNegative.Enabled = true;
        }
        public void ApplyHistogramEqualizationTest()
        {
            var pixelArrayTestValuesResult = new ushort[, ] {
                { 0, 21845 }, { 43690, 65535 }
            };
            var image = new UShortArrayAsImage(new ushort[, ] {
                { 0, 20001 }, { 40001, 65535 }
            });

            image = Contrast.ApplyHistogramEqualization(image);

            CollectionAssert.AreEqual(pixelArrayTestValuesResult, image.PixelArray);
        }
        public void ApplyHistogramEqualizationTestBlackImage()
        {
            var pixelArrayTestValuesResult = new ushort[, ] {
                { 0, 0 }, { 0, 0 }
            };
            var image = new UShortArrayAsImage(new ushort[, ] {
                { 0, 0 }, { 0, 0 }
            });

            image = Contrast.ApplyHistogramEqualization(image);

            CollectionAssert.AreEqual(pixelArrayTestValuesResult, image.PixelArray);
        }
Esempio n. 18
0
        public void TestInvalidParameter()
        {
            var contrast = Contrast.CreateContrast();

            try
            {
                contrast.AddParameter(Model.Tools.Common.ParameterName.Brightness, new Parameter <Double>(150));
                Assert.Fail("The Parameter Name is not valid");
            }
            catch (Exception e)
            {
                Assert.True(true);
            }
        }
Esempio n. 19
0
        public void TestOutOfRangeParameter()
        {
            var contrast = Contrast.CreateContrast();

            contrast.AddParameter(Model.Tools.Common.ParameterName.Contrast, new Parameter <Double>(256));
            try
            {
                contrast.ApplyTool(_input);
                Assert.Fail("Should be between -255 and 255");
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }
        }
Esempio n. 20
0
        public void TestRepeatedParameter()
        {
            var contrast = Contrast.CreateContrast();

            contrast.AddParameter(Model.Tools.Common.ParameterName.Contrast, new Parameter <Double>(30));
            try
            {
                contrast.AddParameter(Model.Tools.Common.ParameterName.Contrast, new Parameter <Double>(100));
                Assert.Fail("You need to remove the parameter first");
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }
        }
Esempio n. 21
0
        public void TestDoubleParameter()
        {
            var contrast = Contrast.CreateContrast();

            contrast.AddParameter(Model.Tools.Common.ParameterName.Contrast, new Parameter <Double>(150.5));
            try
            {
                contrast.ApplyTool(_input);
                Assert.Fail("Should be an int");
            }
            catch (Exception)
            {
                Assert.IsTrue(true);
            }
        }
Esempio n. 22
0
        public void UpdateMessageAddress(string messageaddress)
        {
            MessageAddress = messageaddress;

            FileSelector.UpdateMessageAddress(MessageAddress);
            Brightness.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Brightness)));
            Contrast.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Contrast)));
            Invert.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Invert)));
            Hue.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Hue)));
            Saturation.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Saturation)));
            Luminosity.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Luminosity)));
            Keying.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Keying)));
            Scale.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Scale)));
            Rotate.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Rotate)));
            Pan.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Pan)));
            Tilt.UpdateMessageAddress(String.Format("{0}{1}/", MessageAddress, nameof(Tilt)));
        }
Esempio n. 23
0
            public Panos_1(String SVGPanos1String)
            {
                int tempInt;

                String[] valuesString = SVGPanos1String.Split(' ');
                if (int.TryParse(valuesString[0], out tempInt))
                {
                    family = (Family)tempInt;
                }
                if (int.TryParse(valuesString[1], out tempInt))
                {
                    serifStyle = (Serif_Style)tempInt;
                }
                if (int.TryParse(valuesString[2], out tempInt))
                {
                    weight = (Weight)tempInt;
                }
                if (int.TryParse(valuesString[3], out tempInt))
                {
                    proportion = (Proportion)tempInt;
                }
                if (int.TryParse(valuesString[4], out tempInt))
                {
                    contrast = (Contrast)tempInt;
                }
                if (int.TryParse(valuesString[5], out tempInt))
                {
                    strokeVariation = (Stroke_Variation)tempInt;
                }
                if (int.TryParse(valuesString[6], out tempInt))
                {
                    armStyle = (Arm_Style)tempInt;
                }
                if (int.TryParse(valuesString[7], out tempInt))
                {
                    letterform = (Letterform)tempInt;
                }
                if (int.TryParse(valuesString[8], out tempInt))
                {
                    midline = (Midline)tempInt;
                }
                if (int.TryParse(valuesString[0], out tempInt))
                {
                    xHeight = (XHeight)tempInt;
                }
            }
        /// <summary>
        /// Changes the contrast of the current image.
        /// </summary>
        /// <param name="percentage">
        /// The percentage by which to alter the images contrast.
        /// Any integer between -100 and 100.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Contrast(int percentage)
        {
            if (this.ShouldProcess)
            {
                // Sanitize the input.
                if (percentage > 100 || percentage < -100)
                {
                    percentage = 0;
                }

                Contrast contrast = new Contrast {
                    DynamicParameter = percentage
                };
                this.CurrentImageFormat.ApplyProcessor(contrast.ProcessImage, this);
            }

            return(this);
        }
 private bool ReadExpContrast()
 {
     try
     {
         this.strDelimited = Config.Intance().EleContrast.Attributes["Delimited"].Value;
         this.alInsert.Clear();
         XmlNodeList list1 = Config.Intance().EleDestination.SelectSingleNode("DestTable").ChildNodes;
         for (int num1 = 0; num1 < list1.Count; num1++)
         {
             Contrast contrast1 = new Contrast();
             contrast1.SrcOp           = new ArrayList();
             contrast1.DestOp.Name     = list1[num1].Attributes["Name"].Value;
             contrast1.DestOp.Index    = Convert.ToInt32(list1[num1].Attributes["Index"].Value);
             contrast1.DestOp.DataType = uncTxt.GetDataType(list1[num1].Attributes["Type"].Value);
             contrast1.DestOp.Value    = list1[num1].Attributes["Default"].Value;
             this.alInsert.Add(contrast1);
         }
         list1 = Config.Intance().EleContrast.ChildNodes;
         for (int num2 = 0; num2 < list1.Count; num2++)
         {
             string text1 = list1[num2].Attributes["DestField"].Value;
             for (int num3 = 0; num3 < this.alInsert.Count; num3++)
             {
                 if (((this.alInsert[num3] as Contrast).DestOp.Name == text1) && (list1[num2].Attributes["SourceField"].Value != ""))
                 {
                     Operand operand1 = new Operand();
                     operand1.Name = list1[num2].Attributes["SourceField"].Value;
                     (this.alInsert[num3] as Contrast).SrcOp.Add(operand1);
                 }
             }
         }
         return(true);
     }
     catch (Exception exception1)
     {
         ErrorLog.SaveLog("读取导出转换规则", exception1);
         return(false);
     }
 }
Esempio n. 26
0
        public void WriteConfigFile(XmlTextWriter xmlWriter)
        {
            if (DeviceName.Length < 1)
            {
                DeviceName = "Settings " + DateTime.Now;
            }

            xmlWriter.WriteStartElement("CameraSettings");

            Settings.WriteElement(xmlWriter, "DeviceName", DeviceName);
            Settings.WriteElement(xmlWriter, "DeviceNumber", DeviceNumber.ToString());
            Settings.WriteElement(xmlWriter, "DeviceMode", DeviceMode.ToString());

            Settings.WriteElement(xmlWriter, "Brightness", Brightness.ToString());
            Settings.WriteElement(xmlWriter, "BrightnessAuto", BrightnessAuto.ToString());

            Settings.WriteElement(xmlWriter, "Contrast", Contrast.ToString());
            Settings.WriteElement(xmlWriter, "ContrastAuto", ContrastAuto.ToString());

            Settings.WriteElement(xmlWriter, "Saturation", Saturation.ToString());
            Settings.WriteElement(xmlWriter, "SaturationAuto", SaturationAuto.ToString());

            Settings.WriteElement(xmlWriter, "Sharpness", Sharpness.ToString());
            Settings.WriteElement(xmlWriter, "SharpnessAuto", SharpnessAuto.ToString());

            Settings.WriteElement(xmlWriter, "Zoom", Zoom.ToString());
            Settings.WriteElement(xmlWriter, "ZoomAuto", ZoomAuto.ToString());

            Settings.WriteElement(xmlWriter, "Focus", Focus.ToString());
            Settings.WriteElement(xmlWriter, "FocusAuto", FocusAuto.ToString());

            Settings.WriteElement(xmlWriter, "Exposure", Exposure.ToString());
            Settings.WriteElement(xmlWriter, "ExposureAuto", ExposureAuto.ToString());

            Settings.WriteElement(xmlWriter, "FlipImage", FlipImage.ToString());

            xmlWriter.WriteEndElement();
        }
Esempio n. 27
0
        /// <summary>
        /// config the snapshot
        /// </summary>
        /// <param name="wb">WhiteBalance</param>
        /// <param name="ev">explosure value</param>
        /// <param name="contrast">Contrast</param>
        /// <param name="ce">ColorEffect</param>
        /// <param name="sharp">Sharpness</param>
        /// <returns>True if succeed</returns>
        public bool ConfigSnapshot(WhiteBalance wb, EV ev, Contrast contrast, ColorEffect ce, Sharpness sharp)
        {
            byte[] writeBuffer = new byte[5];

            writeBuffer[0] = (byte)wb;
            writeBuffer[1] = (byte)ev;
            writeBuffer[2] = (byte)contrast;
            writeBuffer[3] = (byte)ce;
            writeBuffer[4] = (byte)sharp;

            CreatCommand(5, CMD_SNAPSHOT_CONFIG);
            CreatCommand(writeBuffer);

            SendCommand(id_cmd);
            SendCommand(para_cmd);

            if (!ReceiveACK(CMD_SNAPSHOT_CONFIG, 100))
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Alters the contrast component of the image.
        /// </summary>
        /// <param name="source">The image this method extends.</param>
        /// <param name="amount">The new contrast of the image. Must be between -100 and 100.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
        /// <returns>The <see cref="Image"/>.</returns>
        public static Image Contrast(this Image source, int amount, Rectangle rectangle, ProgressEventHandler progressHandler = null)
        {
            Contrast processor = new Contrast(amount);
            processor.OnProgress += progressHandler;

            try
            {
                return source.Process(rectangle, processor);
            }
            finally
            {
                processor.OnProgress -= progressHandler;
            }
        }
Esempio n. 29
0
        Tag CreateSpecificTag(TagInfo info, string numberValue)
        {
            try
            {
                if (info.IsGps)
                {
                    switch (info.Name.ToLower())
                    {
                    case "gpslatituderef":
                        return(new Tag <GpsLatitudeRef> {
                            TypedValue = GpsLatitudeRef.FromKey(numberValue)
                        });

                    case "gpslongituderef":
                        return(new Tag <GpsLongitudeRef> {
                            TypedValue = GpsLongitudeRef.FromKey(numberValue)
                        });

                    case "gpsaltituderef":
                        return(new Tag <GpsAltitudeRef> {
                            TypedValue = GpsAltitudeRef.FromKey(byte.Parse(numberValue))
                        });

                    case "gpsstatus":
                        return(new Tag <GpsStatus> {
                            TypedValue = GpsStatus.FromKey(numberValue)
                        });

                    case "gpsmeasuremode":
                        return(new Tag <GpsMeasureMode> {
                            TypedValue = GpsMeasureMode.FromKey(numberValue)
                        });

                    case "gpsspeedref":
                        return(new Tag <GpsSpeedRef> {
                            TypedValue = GpsSpeedRef.FromKey(numberValue)
                        });

                    case "gpstrackref":
                        return(new Tag <GpsTrackRef> {
                            TypedValue = GpsTrackRef.FromKey(numberValue)
                        });

                    case "gpsimgdirectionref":
                        return(new Tag <GpsImgDirectionRef> {
                            TypedValue = GpsImgDirectionRef.FromKey(numberValue)
                        });

                    case "gpsdestlatituderef":
                        return(new Tag <GpsDestLatitudeRef> {
                            TypedValue = GpsDestLatitudeRef.FromKey(numberValue)
                        });

                    case "gpsdestlongituderef":
                        return(new Tag <GpsDestLongitudeRef> {
                            TypedValue = GpsDestLongitudeRef.FromKey(numberValue)
                        });

                    case "gpsdestbearingref":
                        return(new Tag <GpsDestBearingRef> {
                            TypedValue = GpsDestBearingRef.FromKey(numberValue)
                        });

                    case "gpsdestdistanceref":
                        return(new Tag <GpsDestDistanceRef> {
                            TypedValue = GpsDestDistanceRef.FromKey(numberValue)
                        });

                    case "gpsdifferential":
                        return(new Tag <GpsDifferential> {
                            TypedValue = GpsDifferential.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                if (info.IsNikon)
                {
                    switch (info.Name.ToLower())
                    {
                    case "colorspace":
                        return(new Tag <NikonColorSpace> {
                            TypedValue = NikonColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "vibrationreduction":
                        return(new Tag <NikonVibrationReduction> {
                            TypedValue = NikonVibrationReduction.FromKey(byte.Parse(numberValue))
                        });

                    case "vrmode":
                        return(new Tag <NikonVRMode> {
                            TypedValue = NikonVRMode.FromKey(byte.Parse(numberValue))
                        });

                    case "imageauthentication":
                        return(new Tag <NikonImageAuthentication> {
                            TypedValue = NikonImageAuthentication.FromKey(byte.Parse(numberValue))
                        });

                    case "actived-lighting":
                        return(new Tag <NikonActiveDLighting> {
                            TypedValue = NikonActiveDLighting.FromKey(ushort.Parse(numberValue))
                        });

                    case "picturecontroladjust":
                        return(new Tag <NikonPictureControlAdjust> {
                            TypedValue = NikonPictureControlAdjust.FromKey(byte.Parse(numberValue))
                        });

                    case "filtereffect":
                        return(new Tag <NikonFilterEffect> {
                            TypedValue = NikonFilterEffect.FromKey(byte.Parse(numberValue))
                        });

                    case "toningeffect":
                        return(new Tag <NikonToningEffect> {
                            TypedValue = NikonToningEffect.FromKey(byte.Parse(numberValue))
                        });

                    case "daylightsavings":
                        return(new Tag <NikonDaylightSavings> {
                            TypedValue = NikonDaylightSavings.FromKey(byte.Parse(numberValue))
                        });

                    case "datedisplayformat":
                        return(new Tag <NikonDateDisplayFormat> {
                            TypedValue = NikonDateDisplayFormat.FromKey(byte.Parse(numberValue))
                        });

                    case "isoexpansion":
                        return(new Tag <NikonIsoExpansion> {
                            TypedValue = NikonIsoExpansion.FromKey(ushort.Parse(numberValue))
                        });

                    case "isoexpansion2":
                        return(new Tag <NikonIsoExpansion2> {
                            TypedValue = NikonIsoExpansion2.FromKey(ushort.Parse(numberValue))
                        });

                    case "vignettecontrol":
                        return(new Tag <NikonVignetteControl> {
                            TypedValue = NikonVignetteControl.FromKey(ushort.Parse(numberValue))
                        });

                    case "autodistortioncontrol":
                        return(new Tag <NikonAutoDistortionControl> {
                            TypedValue = NikonAutoDistortionControl.FromKey(byte.Parse(numberValue))
                        });

                    case "hdr":
                        return(new Tag <NikonHdr> {
                            TypedValue = NikonHdr.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrlevel":
                        return(new Tag <NikonHdrLevel> {
                            TypedValue = NikonHdrLevel.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrsmoothing":
                        return(new Tag <NikonHdrSmoothing> {
                            TypedValue = NikonHdrSmoothing.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrlevel2":
                        return(new Tag <NikonHdrLevel2> {
                            TypedValue = NikonHdrLevel2.FromKey(byte.Parse(numberValue))
                        });

                    case "textencoding":
                        return(new Tag <NikonTextEncoding> {
                            TypedValue = NikonTextEncoding.FromKey(byte.Parse(numberValue))
                        });

                    case "flashmode":
                        return(new Tag <NikonFlashMode> {
                            TypedValue = NikonFlashMode.FromKey(byte.Parse(numberValue))
                        });

                    case "afareamode":
                        return(new Tag <NikonAfAreaMode> {
                            TypedValue = NikonAfAreaMode.FromKey(byte.Parse(numberValue))
                        });

                    case "afpoint":
                        return(new Tag <NikonAfPoint> {
                            TypedValue = NikonAfPoint.FromKey(byte.Parse(numberValue))
                        });

                    case "afpointsinfocus":
                        return(new Tag <NikonAfPointsInFocus> {
                            TypedValue = NikonAfPointsInFocus.FromKey(ushort.Parse(numberValue))
                        });

                    case "nefcompression":
                        return(new Tag <NikonNefCompression> {
                            TypedValue = NikonNefCompression.FromKey(ushort.Parse(numberValue))
                        });

                    case "retouchhistory":
                        return(new Tag <NikonRetouchHistory> {
                            TypedValue = NikonRetouchHistory.FromKey(ushort.Parse(numberValue))
                        });

                    case "flashsource":
                        return(new Tag <NikonFlashSource> {
                            TypedValue = NikonFlashSource.FromKey(byte.Parse(numberValue))
                        });

                    case "flashcolorfilter":
                        return(new Tag <NikonFlashColorFilter> {
                            TypedValue = NikonFlashColorFilter.FromKey(byte.Parse(numberValue))
                        });

                    case "highisonoisereduction":
                        return(new Tag <NikonHighIsoNoiseReduction> {
                            TypedValue = NikonHighIsoNoiseReduction.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                if (info.IsExif)
                {
                    switch (info.Name.ToLower())
                    {
                    case "interopindex":
                        return(new Tag <InteropIndex> {
                            TypedValue = InteropIndex.FromKey(numberValue)
                        });

                    case "subfiletype":
                        return(new Tag <SubfileType> {
                            TypedValue = SubfileType.FromKey(uint.Parse(numberValue))
                        });

                    case "oldsubfiletype":
                        return(new Tag <OldSubfileType> {
                            TypedValue = OldSubfileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "compression":
                        return(new Tag <Compression> {
                            TypedValue = Compression.FromKey(ushort.Parse(numberValue))
                        });

                    case "photometricinterpretation":
                        return(new Tag <PhotometricInterpretation> {
                            TypedValue = PhotometricInterpretation.FromKey(ushort.Parse(numberValue))
                        });

                    case "thresholding":
                        return(new Tag <Thresholding> {
                            TypedValue = Thresholding.FromKey(ushort.Parse(numberValue))
                        });

                    case "fillorder":
                        return(new Tag <FillOrder> {
                            TypedValue = FillOrder.FromKey(ushort.Parse(numberValue))
                        });

                    case "orientation":
                        return(new Tag <Orientation> {
                            TypedValue = Orientation.FromKey(ushort.Parse(numberValue))
                        });

                    case "planarconfiguration":
                        return(new Tag <PlanarConfiguration> {
                            TypedValue = PlanarConfiguration.FromKey(ushort.Parse(numberValue))
                        });

                    case "grayresponseunit":
                        return(new Tag <GrayResponseUnit> {
                            TypedValue = GrayResponseUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "resolutionunit":
                        return(new Tag <ResolutionUnit> {
                            TypedValue = ResolutionUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "predictor":
                        return(new Tag <Predictor> {
                            TypedValue = Predictor.FromKey(ushort.Parse(numberValue))
                        });

                    case "cleanfaxdata":
                        return(new Tag <CleanFaxData> {
                            TypedValue = CleanFaxData.FromKey(ushort.Parse(numberValue))
                        });

                    case "inkset":
                        return(new Tag <InkSet> {
                            TypedValue = InkSet.FromKey(ushort.Parse(numberValue))
                        });

                    case "extrasamples":
                        return(new Tag <ExtraSamples> {
                            TypedValue = ExtraSamples.FromKey(ushort.Parse(numberValue))
                        });

                    case "sampleformat":
                        return(new Tag <SampleFormat> {
                            TypedValue = SampleFormat.FromKey(ushort.Parse(numberValue))
                        });

                    case "indexed":
                        return(new Tag <Indexed> {
                            TypedValue = Indexed.FromKey(ushort.Parse(numberValue))
                        });

                    case "opiproxy":
                        return(new Tag <OpiProxy> {
                            TypedValue = OpiProxy.FromKey(ushort.Parse(numberValue))
                        });

                    case "profiletype":
                        return(new Tag <ProfileType> {
                            TypedValue = ProfileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "faxprofile":
                        return(new Tag <FaxProfile> {
                            TypedValue = FaxProfile.FromKey(ushort.Parse(numberValue))
                        });

                    case "jpegproc":
                        return(new Tag <JpegProc> {
                            TypedValue = JpegProc.FromKey(ushort.Parse(numberValue))
                        });

                    case "ycbcrsubsampling":
                        return(new Tag <YCbCrSubSampling> {
                            TypedValue = YCbCrSubSampling.FromKey(numberValue)
                        });

                    case "ycbcrpositioning":
                        return(new Tag <YCbCrPositioning> {
                            TypedValue = YCbCrPositioning.FromKey(ushort.Parse(numberValue))
                        });

                    case "sonyrawfiletype":
                        return(new Tag <SonyRawFileType> {
                            TypedValue = SonyRawFileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "rasterpadding":
                        return(new Tag <RasterPadding> {
                            TypedValue = RasterPadding.FromKey(ushort.Parse(numberValue))
                        });

                    case "imagecolorindicator":
                        return(new Tag <ImageColorIndicator> {
                            TypedValue = ImageColorIndicator.FromKey(ushort.Parse(numberValue))
                        });

                    case "backgroundcolorindicator":
                        return(new Tag <BackgroundColorIndicator> {
                            TypedValue = BackgroundColorIndicator.FromKey(ushort.Parse(numberValue))
                        });

                    case "hcusage":
                        return(new Tag <HCUsage> {
                            TypedValue = HCUsage.FromKey(ushort.Parse(numberValue))
                        });

                    case "exposureprogram":
                        return(new Tag <ExposureProgram> {
                            TypedValue = ExposureProgram.FromKey(ushort.Parse(numberValue))
                        });

                    case "sensitivitytype":
                        return(new Tag <SensitivityType> {
                            TypedValue = SensitivityType.FromKey(ushort.Parse(numberValue))
                        });

                    case "componentsconfiguration":
                        return(new Tag <ComponentsConfiguration> {
                            TypedValue = ComponentsConfiguration.FromKey(ushort.Parse(numberValue))
                        });

                    case "meteringmode":
                        return(new Tag <MeteringMode> {
                            TypedValue = MeteringMode.FromKey(ushort.Parse(numberValue))
                        });

                    case "lightsource":
                    case "calibrationilluminant1":
                    case "calibrationilluminant2":
                        return(new Tag <LightSource> {
                            TypedValue = LightSource.FromKey(ushort.Parse(numberValue))
                        });

                    case "flash":
                        return(new Tag <FlashValue> {
                            TypedValue = FlashValue.FromKey(ushort.Parse(numberValue))
                        });

                    case "focalplaneresolutionunit":
                        return(new Tag <FocalPlaneResolutionUnit> {
                            TypedValue = FocalPlaneResolutionUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "securityclassification":
                        return(new Tag <SecurityClassification> {
                            TypedValue = SecurityClassification.FromKey(numberValue)
                        });

                    case "sensingmethod":
                        return(new Tag <SensingMethod> {
                            TypedValue = SensingMethod.FromKey(ushort.Parse(numberValue))
                        });

                    case "colorspace":
                        return(new Tag <ColorSpace> {
                            TypedValue = ColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "filesource":
                        return(new Tag <FileSource> {
                            TypedValue = FileSource.FromKey(ushort.Parse(numberValue))
                        });

                    case "scenetype":
                        return(new Tag <SceneType> {
                            TypedValue = SceneType.FromKey(ushort.Parse(numberValue))
                        });

                    case "customrendered":
                        return(new Tag <CustomRendered> {
                            TypedValue = CustomRendered.FromKey(ushort.Parse(numberValue))
                        });

                    case "exposuremode":
                        return(new Tag <ExposureMode> {
                            TypedValue = ExposureMode.FromKey(ushort.Parse(numberValue))
                        });

                    case "whitebalance":
                        return(new Tag <WhiteBalance> {
                            TypedValue = WhiteBalance.FromKey(ushort.Parse(numberValue))
                        });

                    case "scenecapturetype":
                        return(new Tag <SceneCaptureType> {
                            TypedValue = SceneCaptureType.FromKey(ushort.Parse(numberValue))
                        });

                    case "gaincontrol":
                        return(new Tag <GainControl> {
                            TypedValue = GainControl.FromKey(ushort.Parse(numberValue))
                        });

                    case "contrast":
                        return(new Tag <Contrast> {
                            TypedValue = Contrast.FromKey(ushort.Parse(numberValue))
                        });

                    case "saturation":
                        return(new Tag <Saturation> {
                            TypedValue = Saturation.FromKey(ushort.Parse(numberValue))
                        });

                    case "sharpness":
                        return(new Tag <Sharpness> {
                            TypedValue = Sharpness.FromKey(ushort.Parse(numberValue))
                        });

                    case "subjectdistancerange":
                        return(new Tag <SubjectDistanceRange> {
                            TypedValue = SubjectDistanceRange.FromKey(ushort.Parse(numberValue))
                        });

                    case "pixelformat":
                        return(new Tag <PixelFormat> {
                            TypedValue = PixelFormat.FromKey(ushort.Parse(numberValue))
                        });

                    case "transformation":
                        return(new Tag <Transformation> {
                            TypedValue = Transformation.FromKey(ushort.Parse(numberValue))
                        });

                    case "uncompressed":
                        return(new Tag <Uncompressed> {
                            TypedValue = Uncompressed.FromKey(ushort.Parse(numberValue))
                        });

                    case "imagedatadiscard":
                        return(new Tag <ImageDataDiscard> {
                            TypedValue = ImageDataDiscard.FromKey(ushort.Parse(numberValue))
                        });

                    case "alphadatadiscard":
                        return(new Tag <AlphaDataDiscard> {
                            TypedValue = AlphaDataDiscard.FromKey(ushort.Parse(numberValue))
                        });

                    case "usptooriginalcontenttype":
                        return(new Tag <USPTOOriginalContentType> {
                            TypedValue = USPTOOriginalContentType.FromKey(ushort.Parse(numberValue))
                        });

                    case "cfalayout":
                        return(new Tag <CFALayout> {
                            TypedValue = CFALayout.FromKey(ushort.Parse(numberValue))
                        });

                    case "makernotesafety":
                        return(new Tag <MakerNoteSafety> {
                            TypedValue = MakerNoteSafety.FromKey(ushort.Parse(numberValue))
                        });

                    case "profileembedpolicy":
                        return(new Tag <ProfileEmbedPolicy> {
                            TypedValue = ProfileEmbedPolicy.FromKey(ushort.Parse(numberValue))
                        });

                    case "previewcolorspace":
                        return(new Tag <PreviewColorSpace> {
                            TypedValue = PreviewColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "profilehuesatmapencoding":
                        return(new Tag <ProfileHueSatMapEncoding> {
                            TypedValue = ProfileHueSatMapEncoding.FromKey(ushort.Parse(numberValue))
                        });

                    case "profilelooktableencoding":
                        return(new Tag <ProfileLookTableEncoding> {
                            TypedValue = ProfileLookTableEncoding.FromKey(ushort.Parse(numberValue))
                        });

                    case "defaultblackrender":
                        return(new Tag <DefaultBlackRender> {
                            TypedValue = DefaultBlackRender.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                // ---- VALUE TAG ----
                if (string.IsNullOrEmpty(info.ValueType))
                {
                    return(new Tag());
                }

                switch (info.ValueType.ToLower())
                {
                case "int8u":
                    return(new Tag <byte> {
                        TypedValue = byte.Parse(numberValue)
                    });

                case "int8s":
                    return(new Tag <sbyte> {
                        TypedValue = sbyte.Parse(numberValue)
                    });

                case "int16u":
                    return(new Tag <ushort> {
                        TypedValue = ushort.Parse(numberValue)
                    });

                case "int16s":
                    return(new Tag <short> {
                        TypedValue = short.Parse(numberValue)
                    });

                case "int32u":
                    return(new Tag <uint> {
                        TypedValue = uint.Parse(numberValue)
                    });

                case "integer":
                case "int32s":
                    return(new Tag <int> {
                        TypedValue = int.Parse(numberValue)
                    });

                case "int64u":
                    return(new Tag <ulong> {
                        TypedValue = ulong.Parse(numberValue)
                    });

                case "int64s":
                    return(new Tag <long> {
                        TypedValue = long.Parse(numberValue)
                    });

                case "float":
                case "rational32s":
                case "rational32u":
                    return(new Tag <float> {
                        TypedValue = float.Parse(numberValue)
                    });

                case "double":
                case "rational":
                case "rational64s":
                case "rational64u":
                case "real":
                    return(new Tag <double> {
                        TypedValue = double.Parse(numberValue)
                    });

                case "boolean":
                    return(new Tag <bool> {
                        TypedValue = bool.Parse(numberValue)
                    });
                }
            }
            catch
            {
                if (!Quiet)
                {
                    Console.WriteLine($"error converting {info.TableName}::{info.Id} with name {info.Name}.  Expected type: {info.ValueType} but got value: {numberValue}");
                }
            }

            return(new Tag());
        }
Esempio n. 30
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            IGH_Goo goo   = null;
            Image   image = new Image();

            if (!DA.GetData(0, ref goo))
            {
                return;
            }
            if (!goo.TryGetImage(ref image))
            {
                return;
            }

            int mode = 0;

            DA.GetData(1, ref mode);

            double numVal = 0.5;

            DA.GetData(2, ref numVal);

            Filter filter = new Filter();

            switch ((FilterModes)mode)
            {
            case FilterModes.GrayWorld:
                SetParameter(2);
                filter = new GrayWorld();
                break;

            case FilterModes.Histogram:
                SetParameter(2);
                filter = new Histogram();
                break;

            case FilterModes.Invert:
                SetParameter(2);
                filter = new Invert();
                break;

            case FilterModes.Stretch:
                SetParameter(2);
                filter = new Stretch();
                break;

            case FilterModes.WhitePatch:
                SetParameter(2);
                filter = new WhitePatch();
                break;

            case FilterModes.Sepia:
                SetParameter(2);
                filter = new Sepia();
                break;

            case FilterModes.RGChromacity:
                SetParameter(2);
                filter = new RGChromacity();
                break;

            case FilterModes.Brightness:
                SetParameter(2, "V", "Adjust Value", "[0-1] Unitized adjustment value");
                filter = new Brightness(numVal);
                break;

            case FilterModes.Contrast:
                SetParameter(2, "V", "Factor Value", "[0-1] Unitized adjustment value");
                filter = new Contrast(numVal);
                break;

            case FilterModes.Gamma:
                SetParameter(2, "V", "Gamma Value", "[0-1] Unitized adjustment value");
                filter = new Gamma(numVal);
                break;

            case FilterModes.Hue:
                SetParameter(2, "V", "Hue Value", "[0-1] Unitized adjustment value");
                filter = new Hue(numVal);
                break;

            case FilterModes.Saturation:
                SetParameter(2, "V", "Adjust Value", "[0-1] Unitized adjustment value");
                filter = new Saturation(numVal);
                break;
            }

            message = ((FilterModes)mode).ToString();
            UpdateMessage();

            image.Filters.Add(filter);

            DA.SetData(0, image);
            DA.SetData(1, filter);
        }
Esempio n. 31
0
        public static void ProcessImage(IProcessorItem item)
        {
            using (ImageReader reader = ImageReader.Create(item.Source))
            using (var contrast = new Contrast(item.Correction.Contrast))
            using (var levels = new Levels(item.Correction.Black, item.Correction.White, item.Correction.Shadow, item.Correction.Midpoint, item.Correction.Highlight, HistogramMode.Luminosity))
            using (var color = new ChannelBalance())
            using (var rotate = new Rotate(item.Correction.Rotate))
            using (var saturation = new AdjustHsl(0f, item.Correction.Saturation, 0f))
            using (var writer = new JpegWriter(Path.ChangeExtension(item.Destination, "jpg"), 99))
            {
                color.Addends = new float[3]
                {
                    item.Correction.Blue,
                    item.Correction.Green,
                    item.Correction.Red
                };
                color.Multipliers = new float[3]
                {
                    1f,
                    1f,
                    1f
                };

                writer.UseSubsampling = false;

                Pipeline.Run(reader + contrast + levels + color + rotate + saturation + writer);
            }
        }
Esempio n. 32
0
 private void AreEqual(IReadOnlyList <Texture2D> t1, IReadOnlyList <Texture2D> t2)
 {
     Contrast.AreSame(t1, t2, (v1, v2) => v1.width == v2.width && v1.height == v2.height);
 }
 public static bool ToDisplayContrast(string value, out Contrast output)
 {
     return(DisplayContrastDictionary.TryGetKey(value, out output));
 }
Esempio n. 34
0
        /// <summary>
        /// Contrast algorithm.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contrast_Click(object sender, RoutedEventArgs e) {
            if (m_data.M_inputFilename == string.Empty || m_data.M_bitmap == null) {
                MessageBox.Show("Open image first!", "ArgumentsNull", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try {
                Contrast contrastWindow = new Contrast(m_data, m_vm);
                contrastWindow.Owner = this;
                contrastWindow.Show();
            } catch (FileNotFoundException ex) {
                MessageBox.Show(ex.Message, "FileNotFoundException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (ArgumentException ex) {
                MessageBox.Show(ex.Message, "ArgumentException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (InvalidOperationException ex) {
                MessageBox.Show(ex.Message, "InvalidOperationException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (IndexOutOfRangeException ex) {
                MessageBox.Show(ex.Message, "IndexOutOfRangeException", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }