public FeatherAlphaBlendDialog(RasterImage TempSrcImage, RasterImage TempMaskImage) { InitializeComponent(); _FeatherAlphaBlendCommand = new FeatherAlphaBlendCommand(); //Set command default values _RectX = 0; _RectY = 0; _RectWidth = (int)(TempMaskImage.Width); _RectHeight = (int)(TempMaskImage.Height); _numX.Maximum = TempMaskImage.Width; _numY.Maximum = TempMaskImage.Height; _numWidth.Maximum = TempMaskImage.Width; _numHeight.Maximum = TempMaskImage.Height; _XP1 = (int)(TempSrcImage.Width / 2); _YP1 = (int)(TempSrcImage.Height / 2); _numX1.Maximum = TempMaskImage.Width; _numY1.Maximum = TempMaskImage.Height; _XP2 = 0; _YP2 = 0; _numX2.Maximum = TempMaskImage.Width; _numY2.Maximum = TempMaskImage.Height; InitializeUI(); }
private void Watermark() { int?left = null; int?top = null; try { left = Convert.ToInt32(xmlActionProfile.SelectSingleNode("//root/actionProfile[@ID='" + strActionProfile + "']/action[@ID='watermark']/left").InnerText.Trim()); top = Convert.ToInt32(xmlActionProfile.SelectSingleNode("//root/actionProfile[@ID='" + strActionProfile + "']/action[@ID='watermark']/top").InnerText.Trim()); } catch { } string watermarkFile = xmlActionProfile.SelectSingleNode("//root/actionProfile[@ID='" + strActionProfile + "']/action[@ID='watermark']/watermarkFile").InnerText.Trim(); Leadtools.RasterImage watermark = rasterCodecs.Load(ApplicationPath + watermarkFile); Rectangle destinationRectangle; if (left.HasValue && top.HasValue) { destinationRectangle = new Rectangle(left.Value, top.Value, watermark.Width, watermark.Height); } else { left = Math.Max(0, (img.Width - watermark.Width) / 2); top = Math.Max(0, (img.Height - watermark.Height) / 2); destinationRectangle = new Rectangle(left.Value, top.Value, watermark.Width, watermark.Height); } // Jpg + png + png mask RasterImage watermarkMask = watermark.CreateAlphaImage(); FeatherAlphaBlendCommand command = new FeatherAlphaBlendCommand(watermark, new Point(0, 0), destinationRectangle, watermarkMask, new Point(0, 0)); command.Run(img); // Jpg + jpg // CombineFastCommand combine = new CombineFastCommand(); // combine.DestinationImage = img; // combine.DestinationRectangle = new Rectangle(left, top, watermark.Width, watermark.Height); // combine.SourcePoint = new Point(0, 0); // combine.Flags = CombineFastCommandFlags.SourceCopy; // combine.Run(watermark); watermark.Dispose(); }