Example #1
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);
        }