Exemple #1
0
 public FormSourceBitmap(IObjectLabel label)
     : this()
 {
     ResourceService.Resources.LoadControlResources(this, ImageTransformations.Utils.ControlUtilites.Resources);
     panelBmp.Top  = 0;
     panelBmp.Left = 0;
     this.label    = label;
     bitmap        = label.Object as AbstractBitmap;
     UpdateFormUI();
     performer = BitmapIndicator.Indicators.LabelIndicator.Create(
         new Label[] { labelX, labelY }, new Label[] { labelR, labelG, labelB }, bitmap.GetBitmap(), panelBmp);
     if (bitmap is SourceImage)
     {
         openFileDialogBmp.Filter = "Image files |*.bmp;*.jpg;*.jpeg;*.gif";
     }
     if (label is ImageProviderLabel)
     {
         il = label as ImageProviderLabel;
         toolStripButtonScale.Visible = true;
         toolStripButtonScale.Checked = il.IsScaled;
     }
 }
Exemple #2
0
        /// <summary>
        /// Realiza el proceso de corte de un bitmap dado.
        /// </summary>
        /// <param name="image">Bitmap</param>
        /// <param name="x">Indice de inicio X</param>
        /// <param name="y">Indice de inicio Y</param>
        /// <param name="width">Ancho a recortar</param>
        /// <param name="height">Alto a recortar</param>
        /// <returns></returns>
        public static Bitmap Apply(AbstractBitmap image, int x, int y, int width, int height)
        {
            Accord.Imaging.Filters.Crop crop = new Accord.Imaging.Filters.Crop(new Rectangle(x, y, width, height));

            return(crop.Apply(image._image));
        }
Exemple #3
0
        /// <summary>
        /// Se realiza:
        /// <para>1. Se posiciona la marca de agua de acuerdo a los <see cref="TissotIndicatrix"/> (Top, Bottom y del 1 - 8)</para>
        /// <para>2. Se realiza la deformación <see cref="Fisheye.Convert(FisheyeBitmap)"/></para>
        /// <para>3. Se realiza la deformación <see cref="Fisheye.ToLandscape(FisheyeBitmap)"/></para>
        /// <para>4. Se posiciona la marca de agua de acuerdo a los <see cref="TissotIndicatrix"/> de la posición del centro (9 - 12)</para>
        /// </summary>
        public void Prepare()
        {
            int            size = 0;
            AbstractBitmap img  = null;

            foreach (var indicatrix in _indicatrixes.Where(i => i.Position != Position.Center))
            {
                // Se conserva la relacion aspecto de acuerdo al ancho de la imagen

                if (_imageWatermark.Width > _imageWatermark.Height)
                {
                    size = (indicatrix.MaxWidth * _imageWatermark.Height) / _imageWatermark.Width;

                    img = Resize.Apply(_imageWatermark, indicatrix.MaxWidth, size);
                }
                else
                {
                    size = (indicatrix.MaxHeight * _imageWatermark.Width) / _imageWatermark.Height;

                    img = Resize.Apply(_imageWatermark, size, indicatrix.MaxHeight);
                }

                img = Rotate.Apply(img, indicatrix.Angle);

                var posX = indicatrix.X - (img.Width / 2);
                var posY = indicatrix.Y - (img.Height / 2);

                if (indicatrix.Position == Position.Top)
                {
                    this._topFisheye.InsertImageUnmanaged(img, posX, posY);
                }
                else
                {
                    img._image.RotateFlip(RotateFlipType.RotateNoneFlipXY);

                    this._bottomFisheye.InsertImageUnmanaged(img, posX, posY);
                }
            }

            // Se realiza la deformación fisheye

            var feTop    = Fisheye.Convert(this._topFisheye);
            var feBottom = Fisheye.Convert(this._bottomFisheye);

            // Se deforman los fisheye a landscape

            feBottom = Fisheye.ToLandscape(feBottom);

            feTop = Fisheye.ToLandscape(feTop);
            feTop._image.RotateFlip(RotateFlipType.RotateNoneFlipXY);

            // Se insertan en el bitmap "watermak"

            _waterMark.InsertImageUnmanaged(feTop, 0, 0);
            _waterMark.InsertImageUnmanaged(feBottom, 0, feBottom.Height);

            // Se insertan aquellos indicatrix que pertenezcan al centro de la imagen

            foreach (var indicatrix in _indicatrixes.Where(i => i.Position == Position.Center))
            {
                if (_imageWatermark.Width > _imageWatermark.Height)
                {
                    size = (indicatrix.MaxWidth * _imageWatermark.Height) / _imageWatermark.Width;

                    img = Resize.Apply(_imageWatermark, indicatrix.MaxWidth, size) as WatermarkBitmap;
                }
                else
                {
                    size = (indicatrix.MaxHeight * _imageWatermark.Width) / _imageWatermark.Height;

                    img = Resize.Apply(_imageWatermark, size, indicatrix.MaxHeight) as WatermarkBitmap;
                }

                _waterMark.InsertImageUnmanaged(img, indicatrix.X - img.Width / 2, indicatrix.Y - img.Height / 2);
            }

            //_waterMark.Save(@"C:\Users\Euler\Pictures\WMpreared2.png", ImageFormat.Png);
        }