Esempio n. 1
0
        public static IBitmapTransform ApplyTransform(Aurigma.GraphicsMill.Bitmap bitmap, System.Windows.Forms.UserControl propertyPage)
        {
            ITransformPropertyPage tpp = (ITransformPropertyPage)propertyPage;

            tpp.Bitmap = bitmap;

            TransformDialog dialog = new TransformDialog();

            dialog.SuspendLayout();
            dialog.ClientSize     = new System.Drawing.Size(propertyPage.Width + 118, propertyPage.Height + 16);
            propertyPage.Location = new System.Drawing.Point(8, 8);
            propertyPage.TabIndex = 0;
            dialog.Controls.Add(propertyPage);

            dialog.buttonOK.Left     = propertyPage.Width + 24;
            dialog.buttonCancel.Left = propertyPage.Width + 24;
            dialog.ResumeLayout(false);

            dialog.Text = tpp.Title;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                return(tpp.Transform);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Crops image
 /// </summary>
 private static void Crop()
 {
     using (var bitmap = new Bitmap("../../../../_Input/Chicago.jpg"))
     {
         bitmap.Transforms.Crop(230, 170, 320, 240);
         bitmap.Save("../../../../_Output/Crop.jpg");
     }
 }
Esempio n. 3
0
        private void UpdatePreview()
        {
            //Paper bitmap initializing
            int width;
            int height;

            width  = 0;
            height = 0;
            CalculatePaperImageDimensions(ref width, ref height);
            System.Drawing.Size fittedSize = FitDimensions(width, height, BitmapViewer1.Width - 20, BitmapViewer1.Height - 20);

            if (BitmapViewer1.Bitmap != null)
            {
                BitmapViewer1.Bitmap.Dispose();
            }

            BitmapViewer1.Bitmap = new Aurigma.GraphicsMill.Bitmap(fittedSize.Width, fittedSize.Height, PixelFormat.Format24bppRgb, RgbColor.White);

            //Scale coefficients
            _previewScaleX = Convert.ToSingle(width) / Convert.ToSingle(fittedSize.Width);
            _previewScaleY = Convert.ToSingle(height) / Convert.ToSingle(fittedSize.Height);

            //Image rubberband initializing
            Aurigma.GraphicsMill.Bitmap previewImage = new Aurigma.GraphicsMill.Bitmap();
            Resize resizeTransform = new Resize();

            resizeTransform.Width      = fittedSize.Width;
            resizeTransform.Height     = fittedSize.Height;
            resizeTransform.ResizeMode = Aurigma.GraphicsMill.Transforms.ResizeMode.Fit;
            previewImage = resizeTransform.Apply(_originalImage);
            ImageRubberband rubberband = new ImageRubberband(previewImage);

            BitmapViewer1.Rubberband     = rubberband;
            rubberband.RectangleChanged += new Aurigma.GraphicsMill.WinControls.RectangleEventHandler(this.RubberbandRectangleChanged);

            //Setting image size
            int imageActualWidth;
            int imageActualHeight;

            imageActualWidth  = Convert.ToInt32(Convert.ToSingle(_originalImage.Width) / Convert.ToSingle(_originalImage.DpiX) * Convert.ToSingle(_printerResolutionX));
            imageActualHeight = Convert.ToInt32(Convert.ToSingle(_originalImage.Height) / Convert.ToSingle(_originalImage.DpiY) * Convert.ToSingle(_printerResolutionY));

            int previewImageWidth;
            int previewImageHeight;

            previewImageWidth  = Convert.ToInt32(Convert.ToSingle(imageActualWidth) / Convert.ToSingle(_previewScaleX));
            previewImageHeight = Convert.ToInt32(Convert.ToSingle(imageActualHeight) / Convert.ToSingle(_previewScaleY));

            System.Drawing.Size tmp = FitDimensions(previewImageWidth, previewImageHeight, fittedSize.Width, fittedSize.Height);
            previewImageWidth    = tmp.Width;
            previewImageHeight   = tmp.Height;
            rubberband.Rectangle = new System.Drawing.Rectangle((fittedSize.Width - previewImageWidth) / 2, (fittedSize.Height - previewImageHeight) / 2, previewImageWidth, previewImageHeight);

            //Initializing coordinates & size editboxes
            UpdateSizeAndPositionFromPreview();
        }
    private static LabColor RgbToLabColor(RgbColor color)
    {
        using (var bitmap = new Aurigma.GraphicsMill.Bitmap(1, 1, PixelFormat.Format24bppRgb, color))
        {
            bitmap.ColorProfile = ColorProfile.FromSrgb();

            bitmap.ColorManagement.Convert(PixelFormat.Format24bppLab);

            return((LabColor)bitmap.GetPixel(0, 0));
        }
    }
Esempio n. 5
0
        public PrintImageDialog(Aurigma.GraphicsMill.Bitmap printImage)
        {
            if (printImage == null)
            {
                throw (new ArgumentNullException("printImage"));
            }

            //This call is required by the Windows Form Designer.
            InitializeComponent();

            //Add any initialization after the InitializeComponent() call
            _originalImage = printImage;
            UpdatePreview();
        }
    /// <summary>
    /// Tints using alpha channel
    /// </summary>
    private static void TintUsingAlpha(RgbColor color)
    {
        using (var bitmap = new Bitmap("../../../../_Input/Chicago.jpg"))
        {
            using (var result = new Aurigma.GraphicsMill.Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format24bppRgb, color))
            {
                bitmap.ColorManagement.Convert(PixelFormat.Format8bppGrayscale);
                bitmap.Transforms.Invert();

                result.Channels.SetAlpha(bitmap);
                result.Channels.RemoveAlpha(RgbColor.White);

                result.Save("../../../../_Output/TintUsingAlpha_" + color.ToString() + ".jpg");
            }
        }
    }
Esempio n. 7
0
        private static BitmapImage ConvertAurigmaImageToBitmapImage(Aurigma.GraphicsMill.Bitmap selectedChannelBitmap)
        {
            System.Drawing.Bitmap bmp    = (System.Drawing.Bitmap)selectedChannelBitmap;
            BitmapImage           bmpimg = new BitmapImage();

            using (MemoryStream memstr = new MemoryStream())
            {
                bmp.Save(memstr, System.Drawing.Imaging.ImageFormat.Jpeg);
                memstr.Position = 0;
                bmpimg.BeginInit();
                bmpimg.StreamSource = memstr;
                bmpimg.CacheOption  = BitmapCacheOption.OnLoad;
                bmpimg.EndInit();
            }
            return(bmpimg);
        }
Esempio n. 8
0
        private void Compare()
        {
            outputMessage.Text = "";

            //FileLoc overload
            //bool verdict = MovementDetection.CheckForMovement(@"C:\Users\Brian\Desktop\Movement Examples\0709_09_MOVEMENT_EXAMPLE.jpg");

            //Bitmap overload
            //bool verdict = MovementDetection.CheckForMovement(largeImage);

            //Aurigma overload
            Aurigma.GraphicsMill.Bitmap aurigmaBitmap = new Aurigma.GraphicsMill.Bitmap(analyzeBitmap);
            bool verdict = MovementDetection.CheckForMovement(aurigmaBitmap);

            AnnounceVerdict(verdict);
        }
Esempio n. 9
0
    /// <summary>
    /// Writes EXIF and IPTC metadata
    /// </summary>
    private static void WriteExifIptc()
    {
        using (var bitmap = new Aurigma.GraphicsMill.Bitmap("../../../../_Input/Chicago.jpg"))
        {
            var settings = new Aurigma.GraphicsMill.Codecs.JpegSettings(70);

            var exif = new Aurigma.GraphicsMill.Codecs.ExifDictionary();
            exif[Aurigma.GraphicsMill.Codecs.ExifDictionary.Software] = "Aurigma Graphics Mill";
            settings.Exif = exif;

            var iptc = new Aurigma.GraphicsMill.Codecs.IptcDictionary();
            iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.Keyword] = "mountain";
            iptc[Aurigma.GraphicsMill.Codecs.IptcDictionary.City]    = "Olympia";
            settings.Iptc = iptc;

            bitmap.Save("../../../../_Output/WriteExifIptc.jpg", settings);
        }
    }
        public static DialogResult ShowEncoderDialog(Aurigma.GraphicsMill.Bitmap bitmap, System.Windows.Forms.UserControl propertyPage, WriterSettings encoderOptions)
        {
            IEncoderPropertyPage tpp = (IEncoderPropertyPage)propertyPage;

            tpp.Bitmap         = bitmap;
            tpp.EncoderOptions = encoderOptions;

            EncoderOptionsDialog dialog = new EncoderOptionsDialog();

            dialog.SuspendLayout();
            dialog.ClientSize     = new System.Drawing.Size(propertyPage.Width + 118, Math.Max(propertyPage.Height + 16, dialog.buttonCancel.Location.Y + dialog.buttonCancel.Size.Height + 8));
            propertyPage.Location = new System.Drawing.Point(8, 8);
            dialog.Controls.Add(propertyPage);

            dialog.buttonOK.Left     = propertyPage.Width + 24;
            dialog.buttonCancel.Left = propertyPage.Width + 24;
            dialog.ResumeLayout(false);

            dialog.Text = tpp.Title;

            return(dialog.ShowDialog());
        }
Esempio n. 11
0
        private void LinkLarge_Clicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            outputMessage.Text = "";

            //Get a file
            fileDialog.FileName = "";
            fileDialog.Title    = "Select main image";
            fileDialog.Filter   = "All images|*.jpg; *.bmp; *.png";
            fileDialog.ShowDialog();
            if (fileDialog.FileName.ToString() != "")
            {
                largeFileName       = fileDialog.FileName.ToString();
                largeLabel.Text     = largeFileName;
                largePicBox.Image   = System.Drawing.Image.FromFile(largeFileName);
                largePicBox.Visible = true;
            }

            //Get an area of interest
            Aurigma.GraphicsMill.Bitmap wholeBitmap = new Aurigma.GraphicsMill.Bitmap(largeFileName);
            testPicBox.Image = (System.Drawing.Image)wholeBitmap;
            Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(MovementDetection.FindAreaOfInterest(wholeBitmap));

            //Process area of interest bitmap into B&W we can analyze
            Aurigma.GraphicsMill.Bitmap processedBitmap = MovementDetection.GreyscaleAndThreshold(bitmap);

            //Have to turn it back into 24-bit or the pattern matching won't work
            processedBitmap.ColorManagement.Convert(Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);


            //Store it in global
            analyzeBitmap = new Aurigma.GraphicsMill.Bitmap(processedBitmap);

            //Update GUI image
            largePicBox.Image = (System.Drawing.Image)processedBitmap;

            Compare();
        }
Esempio n. 12
0
        private void SquishImages()
        {
            DirectoryInfo di = new DirectoryInfo(ccFolder);
            FileInfo[] files = di.GetFiles("*_*_*.jpg");

            foreach (var file in files)
            {
                using (var bitmap = new Aurigma.GraphicsMill.Bitmap(file.FullName))
                {
                    bitmap.Transforms.Resize(700, 0);
                    bitmap.Save(Path.Combine(thumbsFolder, file.Name));
                }
            }
        }
Esempio n. 13
0
        private void generateInitiateValveValues()
        {
            int    jobID     = Convert.ToInt32(cmbJobID.SelectedValue);
            string imagePath = jobClass.getSampleImagePath(jobID);

            Aurigma.GraphicsMill.Bitmap bitmap = new Bitmap(imagePath);

            if (bitmap.PixelFormat.IsRgb)
            {
                bitmap.ColorProfile = Aurigma.GraphicsMill.ColorProfile.FromSrgb();
                bitmap.ColorManagement.ColorManagementEngine = Aurigma.GraphicsMill.Transforms.ColorManagementEngine.LittleCms;
                bitmap.ColorManagement.DestinationProfile    = new Aurigma.GraphicsMill.ColorProfile(@"C:\windows\system32\spool\drivers\color\EuroscaleCoated.icc");
                bitmap.ColorManagement.Convert(Aurigma.GraphicsMill.ColorSpace.Cmyk, bitmap.HasAlpha, bitmap.PixelFormat.IsExtended);
            }
            string selectedChannel = cmbCurrentColour.SelectedValue.ToString();

            Aurigma.GraphicsMill.Bitmap selectedChannelBitmap = new Aurigma.GraphicsMill.Bitmap(bitmap);

            if (selectedChannel == "Cyan")
            {
                selectedChannelBitmap = bitmap.Channels[Aurigma.GraphicsMill.Channel.Cyan];
            }
            else if (selectedChannel == "Magenta")
            {
                selectedChannelBitmap = bitmap.Channels[Aurigma.GraphicsMill.Channel.Magenta];
            }
            else if (selectedChannel == "Yellow")
            {
                selectedChannelBitmap = bitmap.Channels[Aurigma.GraphicsMill.Channel.Yellow];
            }
            else if (selectedChannel == "Black")
            {
                selectedChannelBitmap = bitmap.Channels[Aurigma.GraphicsMill.Channel.Black];
            }

            BitmapImage bmpimg = ConvertAurigmaImageToBitmapImage(selectedChannelBitmap);

            imgSelectedChannel.Source = bmpimg;

            int WidthOfTheImage = selectedChannelBitmap.Width;

            int partWidth  = WidthOfTheImage / 12;
            int partHeight = selectedChannelBitmap.Height;

            System.Windows.Controls.Image[] imgArr = new System.Windows.Controls.Image[12];
            imgArr[0]  = image3;
            imgArr[1]  = image4;
            imgArr[2]  = image5;
            imgArr[3]  = image6;
            imgArr[4]  = image7;
            imgArr[5]  = image8;
            imgArr[6]  = image9;
            imgArr[7]  = image10;
            imgArr[8]  = image11;
            imgArr[9]  = image12;
            imgArr[10] = image13;
            imgArr[11] = image14;

            Label[] lblValveArr = new Label[12];
            lblValveArr[0]  = lblValve01;
            lblValveArr[1]  = lblValve02;
            lblValveArr[2]  = lblValve03;
            lblValveArr[3]  = lblValve04;
            lblValveArr[4]  = lblValve05;
            lblValveArr[5]  = lblValve06;
            lblValveArr[6]  = lblValve07;
            lblValveArr[7]  = lblValve08;
            lblValveArr[8]  = lblValve09;
            lblValveArr[9]  = lblValve10;
            lblValveArr[10] = lblValve11;
            lblValveArr[11] = lblValve12;

            Aurigma.GraphicsMill.Histogram histogram;

            int startingPoint = 0;

            for (int i = 0; i < 12; i++)
            {
                System.Drawing.Rectangle    rect        = new System.Drawing.Rectangle(startingPoint, 0, partWidth, partHeight);
                Aurigma.GraphicsMill.Bitmap croppingBmp = new Aurigma.GraphicsMill.Bitmap(selectedChannelBitmap);
                croppingBmp.Transforms.Crop(rect);
                BitmapImage croppedBitmap = ConvertAurigmaImageToBitmapImage(croppingBmp);
                imgArr[i].Source = croppedBitmap;
                startingPoint   += partWidth;

                histogram = croppingBmp.Statistics.GetSumHistogram();

                double histoValue = Convert.ToDouble(histogram.Mean);

                double calcValue = (255 - histoValue) / (255);

                double precentageValue = calcValue * 100;

                lblValveArr[i].Content = precentageValue.ToString("0.00") + " %";
            }
        }
Esempio n. 14
0
        private void CreateThumbs(string scanTargetPath)
        {
            string thisJob = scanTargetPath.Replace(@"\\photoserver\FilmSystem\Orders\", "").Replace(@"\1 - Scanned", "").Replace(@"\5 - Rescanned", "");

            string thumbPath = Path.Combine(scanTargetPath, "0 - Thumbs").Replace(@"\1 - Scanned", "");

            DirectoryInfo di = new DirectoryInfo(scanTargetPath);
            FileInfo[] fileList = di.GetFiles("*_*.jpg");

            using (LoadingMessage lm = new LoadingMessage())
            {
                lm.ChangeMessage("No thumbnails found. Crushing " + fileList.Count() + " images from job " + thisJob + ".");
                lm.StartPosition = FormStartPosition.CenterScreen;
                lm.Show();
                Application.DoEvents();

                foreach (FileInfo file in fileList)
                {
                    using (var bitmap = new Aurigma.GraphicsMill.Bitmap(file.FullName))
                    {
                        bitmap.Transforms.Resize(700, 0);
                        bitmap.Save(Path.Combine(thumbPath, thisJob + "_" + file.Name));
                    }
                }

                CopyThumbs(thumbPath, fileList.Count(), thisJob);

                lm.Close();
            }
        }
Esempio n. 15
0
        protected override TaskOutput Execute(TaskInput input, ITaskContext context)
        {
            foreach (var file in input.Files)
            {
                try
                {
                    IEncoderOptions options = new JpegEncoderOptions(90, false);
                    switch (_convertFormat)
                    {
                    case ConvertFormat.Jpeg:
                        options = new JpegEncoderOptions(90, false);
                        break;

                    case ConvertFormat.Png:
                        options = new PngEncoderOptions();
                        break;

                    case ConvertFormat.Tiff:
                        options = new TiffEncoderOptions(CompressionType.Zip);
                        break;
                    }

                    var isConverted = false;
                    using (var readStream = new FileStream(file.Path, FileMode.Open))
                    {
                        using (var reader = FormatManager.CreateFormatReader(readStream))
                        {
                            if (reader.MediaFormat != options.MediaFormat)
                            {
                                using (var frame = reader.LoadFrame(0))
                                {
                                    using (var resultBitmap = new Bitmap(frame.Width, frame.Height, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb))
                                    {
                                        frame.GetBitmap(resultBitmap);

                                        var conveter = new PixelFormatConverter {
                                            DestinationPixelFormat = Aurigma.GraphicsMill.PixelFormat.Format32bppArgb
                                        };
                                        conveter.ApplyTransform(resultBitmap);

                                        if (resultBitmap.HasAlpha)
                                        {
                                            resultBitmap.Channels.DiscardAlpha(RgbColor.White);
                                        }

                                        resultBitmap.Save(file.Path + ".tmp", options);
                                        isConverted = true;
                                    }
                                }
                            }
                        }
                    }

                    if (isConverted)
                    {
                        File.Delete(file.Path);
                        File.Move(file.Path + ".tmp", file.Path);
                    }
                }
                catch (System.Exception ex)
                {
                    Logger.ErrorException(string.Format("Error while converting file {1} to {0}", _convertFormat, file.Path), ex);
                }
            }
            return(new TaskOutput(input.Files, input.Params));
        }
Esempio n. 16
0
 private void ShowOriginal()
 {
     _processedBitmap = Processor.ProcessBitmap(currentImage, _blankCorrection, display.Width, display.Height);
     display.Image = (Image)_processedBitmap;
     Application.DoEvents();
 }
Esempio n. 17
0
 private void ShowCorrected()
 {
     _processedBitmap = Processor.ProcessBitmap(currentImage, _correctionData, display.Width, display.Height);
     display.Image = (Image)_processedBitmap;
     Application.DoEvents();
 }
Esempio n. 18
0
        private void LoadImage(string path)
        {
            _lastCorrection = new ComplexCorrection(_correctionData);

            SaveIfNecessary();

            originalPic.ImageLocation = path;
            ShrinkWorkingImage(path);
            currentImage = resizedImage;
            _currentBitmap = new Aurigma.GraphicsMill.Bitmap(currentImage);
            GetDataFromFilename(path);
            if (rollingCorrection.Checked)
            {
                hasCC = true;
                KeepOriginalRotation(Path.GetFileNameWithoutExtension(path));
            }
            else if (holdCorrections.Checked)
            {
                hasCC = true;
                KeepOriginalRotation(Path.GetFileNameWithoutExtension(path));

                UpdateTextBoxes();
            }
            else
            {
                DeserializeIt(pvorder, pvroll, pvframe);
            }
            UpdateImageAndCorrections();
            currentRotation = (int)_correctionData.Rotation.Value;
            AdjustHoldRotation();
        }
Esempio n. 19
0
 private void ShrinkWorkingImage(string path)
 {
     using (var bitmap = new Aurigma.GraphicsMill.Bitmap(path))
     using (var resize = new Resize(display.Width, display.Height, ResizeInterpolationMode.High, ResizeMode.Fit))
     using (var result = resize.Apply(bitmap))
     {
         result.Save(resizedImage);
     }
 }
Esempio n. 20
0
 private void ProcessCurrentImage()
 {
     SaveIfNecessary();
     _processedBitmap = Processor.ProcessBitmap(currentImage, _correctionData, display.Width, display.Height);
     display.Image = (Image)_processedBitmap;
     int mode = GetHistMode();
     histogramBox.DrawHistogram(_processedBitmap, mode);
     string thisImage = currentFilename.Text;
     foreach (Thumbnail control in thumbPanel.Controls)
     {
         string thisTag = Path.GetFileNameWithoutExtension(control.Tag.ToString());
         if (thisTag == thisImage)
         {
             control.UpdateThumbnail();
             control.FixSize();
         }
     }
 }
Esempio n. 21
0
        protected override TaskOutput Execute(TaskInput input, ITaskContext context)
        {
            foreach (var taskFile in input.Files)
            {
                var textNote     = taskFile.Params[_textKey];
                var textPosition = taskFile.Params[_positionKey];

                using (var image = new Bitmap(taskFile.Path))
                {
                    if (!image.IsRgb || image.IsIndexed || image.IsGrayScale)
                    {
                        image.ColorManagement.ConvertToContinuous(ColorSpace.Rgb, false, false);
                    }

                    var renderingSize = new Size(image.Width, image.Height);

                    double materialWidth  = (double)renderingSize.Width / 100;
                    double materialHeight = (double)renderingSize.Height / 100;

                    double lineSize = 0;
                    if (textPosition == "Left" || textPosition == "Right")
                    {
                        lineSize       = materialWidth / 15;
                        materialWidth -= lineSize;
                    }
                    else
                    {
                        lineSize        = materialHeight / 15;
                        materialHeight -= lineSize;
                    }

                    int textWidth  = 0;
                    int textHeight = (int)Math.Round(lineSize * image.Height / materialHeight);

                    if (textPosition == "Left" || textPosition == "Right")
                    {
                        textWidth = image.Height;
                    }
                    else
                    {
                        textWidth = image.Width;
                    }

                    using (Bitmap text = new Bitmap(System.Drawing.Color.FromArgb(240, 240, 240), textWidth, textHeight, PixelFormat.Format32bppArgb))
                    {
                        using (Graphics graphics = text.GetGdiplusGraphics())
                        {
                            System.Drawing.Color sourceColor = System.Drawing.Color.White;
                            System.Drawing.Color destColor   = System.Drawing.Color.White;

                            if (textPosition == "Left" || textPosition == "Top")
                            {
                                sourceColor = System.Drawing.Color.FromArgb(200, 200, 200);
                            }
                            else
                            {
                                destColor = System.Drawing.Color.FromArgb(200, 200, 200);
                            }

                            var gradient = new LinearGradientBrush(new Rectangle(0, 0, text.Width, text.Height), sourceColor, destColor, LinearGradientMode.Vertical);
                            graphics.FillRectangle(gradient, 0, 0, text.Width, text.Height);

                            using (var drawFont = new Aurigma.GraphicsMill.Drawing.Font("Trebuchet MS", textHeight / 2))
                            {
                                drawFont.Antialiased = true;
                                drawFont.Unit        = Unit.Point;
                                drawFont.ClearType   = true;

                                using (var drawBrush = new SolidBrush(System.Drawing.Color.Black))
                                {
                                    var drawFormat = new StringFormat();
                                    drawFormat.Alignment     = StringAlignment.Center;
                                    drawFormat.LineAlignment = StringAlignment.Center;

                                    graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                                    graphics.DrawString(textNote, drawFont, drawBrush, new RectangleF(0, 0, textWidth, textHeight), drawFormat);
                                }
                            }
                        }

                        int resultWidth  = image.Width;
                        int resultHeight = image.Height;

                        if (textPosition == "Left" || textPosition == "Right")
                        {
                            text.Transforms.RotateAndFlip(RotateFlipType.Rotate270FlipNone);
                            resultWidth += text.Width;
                        }
                        else
                        {
                            resultHeight += text.Height;
                        }

                        using (var result = new Bitmap(resultWidth, resultHeight, PixelFormat.Format32bppArgb))
                        {
                            switch (textPosition)
                            {
                            case "Left":
                                text.Draw(result, 0, 0, CombineMode.AlphaOverlapped, 1.0f);
                                image.Draw(result, text.Width, 0, CombineMode.AlphaOverlapped, 1.0f);
                                break;

                            case "Right":
                                text.Draw(result, image.Width, 0, CombineMode.AlphaOverlapped, 1.0f);
                                image.Draw(result, 0, 0, CombineMode.AlphaOverlapped, 1.0f);
                                break;

                            case "Top":
                                text.Draw(result, 0, 0, CombineMode.AlphaOverlapped, 1.0f);
                                image.Draw(result, 0, text.Height, CombineMode.AlphaOverlapped, 1.0f);
                                break;

                            default:
                                text.Draw(result, 0, image.Height, CombineMode.AlphaOverlapped, 1.0f);
                                image.Draw(result, 0, 0, CombineMode.AlphaOverlapped, 1.0f);
                                break;
                            }

                            var pngEncoder = new PngEncoderOptions();
                            result.Save(taskFile.Path, pngEncoder);
                        }
                    }
                }
            }
            return(new TaskOutput(input.Files, input.Params));
        }
Esempio n. 22
0
 private void FixMainImage(Thumbnail thisThumb)
 {
     string path = Path.Combine(thumbsFolder, thisThumb.Tag.ToString());
     originalPic.ImageLocation = path;
     ShrinkWorkingImage(path);
     currentImage = resizedImage;
     _currentBitmap = new Aurigma.GraphicsMill.Bitmap(currentImage);
     UpdateImageAndCorrections();
 }