public FaceImageControl( FaceImage Face, FaceImageListControl FaceControlParent )
        {
            this.Face = Face;
            this.FaceControlParent = FaceControlParent;
            InitializeComponent();

            SetBounds( 0, 0, Face.Face.Width, Face.Face.Height );

            List<MenuItem> menuitems = new List<MenuItem>();

            MenuItem mi;
            mi = new MenuItem( "Edit URL" );
            mi.Click += new EventHandler( mi_EditURL_Click );
            menuitems.Add( mi );

            mi = new MenuItem( "Edit Name" );
            mi.Click += new EventHandler( mi_EditName_Click );
            menuitems.Add( mi );

            mi = new MenuItem( "Delete" );
            mi.Click += new EventHandler( mi_Delete_Click );
            menuitems.Add( mi );

            RightClickMenuItems = menuitems.ToArray();
            RightClickMenu = new System.Windows.Forms.ContextMenu( RightClickMenuItems );

            ImageAttrs = new System.Drawing.Imaging.ImageAttributes();
            ColorMatrix = new System.Drawing.Imaging.ColorMatrix();
        }
Example #2
0
        internal static Image RGBToBGR(this Image bmp)
        {
            Image newBmp;
            if ((bmp.PixelFormat & Imaging.PixelFormat.Indexed) != 0)
            {
                newBmp = new Bitmap(bmp.Width, bmp.Height, Imaging.PixelFormat.Format32bppArgb);
            }
            else
            {
                newBmp = bmp;
            }
        
            try
            {
                System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
                System.Drawing.Imaging.ColorMatrix cm = new System.Drawing.Imaging.ColorMatrix(rgbtobgr);

                ia.SetColorMatrix(cm);
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(newBmp))
                {
                    g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, System.Drawing.GraphicsUnit.Pixel, ia);
                }
            }
            finally
            {
                if (newBmp != bmp)
                {
                    bmp.Dispose();
                }
            }
            
            return newBmp;
        }
Example #3
0
        internal static Image RGBToBGR(this Image bmp)
        {
            Image newBmp;
            if ((bmp.PixelFormat & Imaging.PixelFormat.Indexed) != 0)
            {
                newBmp = new Bitmap(bmp.Width, bmp.Height, Imaging.PixelFormat.Format32bppArgb);
            }
            else
            {
                // Need to clone so the call to Clear() below doesn't clear the source before trying to draw it to the target.
                newBmp = (Image)bmp.Clone();
            }

            try
            {
                System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
                System.Drawing.Imaging.ColorMatrix cm = new System.Drawing.Imaging.ColorMatrix(rgbtobgr);

                ia.SetColorMatrix(cm);
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(newBmp))
                {
                    g.Clear(Color.Transparent);
                    g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, System.Drawing.GraphicsUnit.Pixel, ia);
                }
            }
            finally
            {
                if (newBmp != bmp)
                {
                    bmp.Dispose();
                }
            }

            return newBmp;
        }
Example #4
0
        public static Bitmap MakeGrayscale(Bitmap original)
        {
            using (var gr = Graphics.FromImage(original))
            {
                //var grayMatrix = new[]
                //                      {
                //                          new float[] { 0.299f, 0.299f, 0.299f, 0, 0 },
                //                          new float[] { 0.587f, 0.587f, 0.587f, 0, 0 },
                //                          new float[] { 0.114f, 0.114f, 0.114f, 0, 0 },
                //                          new float[] { 0, 0, 0, 1, 0 },
                //                          new float[] { 0, 0, 0, 0, 1 }
                //                      };

                var grayMatrix = new[]
                                     {
                                         new float[] { 1.5f, 1.5f, 1.5f, 0, 0 },
                                         new float[] { 1.5f, 1.5f, 1.5f, 0, 0 },
                                         new float[] { 1.5f, 1.5f, 1.5f, 0, 0 },
                                         new float[] { 0, 0, 0, 1, 0 },
                                         new float[] { -1, -1, -1, 0, 1 }
                                     };

                var ia = new System.Drawing.Imaging.ImageAttributes();
                ia.SetColorMatrix(new System.Drawing.Imaging.ColorMatrix(grayMatrix));
                ia.SetThreshold(0.7f); // Change this threshold as needed
                var rc = new Rectangle(0, 0, original.Width, original.Height);
                gr.DrawImage(original, rc, 0, 0, original.Width, original.Height, GraphicsUnit.Pixel, ia);
            }

            return original;
        }
Example #5
0
        internal static void RGBToBGR(this Image bmp)
        {
            System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
            System.Drawing.Imaging.ColorMatrix cm = new System.Drawing.Imaging.ColorMatrix(rgbtobgr);

            ia.SetColorMatrix(cm);
            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp))
            {
                g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, System.Drawing.GraphicsUnit.Pixel, ia);
            }
        }
Example #6
0
 public static Image SetImgOpacity(Image imgPic, float imgOpac)
 {
     Bitmap bmpPic = new Bitmap(imgPic.Width, imgPic.Height);
     Graphics gfxPic = Graphics.FromImage(bmpPic);
     System.Drawing.Imaging.ColorMatrix cmxPic = new System.Drawing.Imaging.ColorMatrix();
     cmxPic.Matrix33 = imgOpac;
     System.Drawing.Imaging.ImageAttributes iaPic = new System.Drawing.Imaging.ImageAttributes();
     iaPic.SetColorMatrix(cmxPic, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);
     gfxPic.DrawImage(imgPic, new Rectangle(0, 0, bmpPic.Width, bmpPic.Height), 0, 0, imgPic.Width, imgPic.Height, GraphicsUnit.Pixel, iaPic);
     gfxPic.Dispose();
     return bmpPic;
 }
Example #7
0
 private static void Init()
 {
     float[][] matrix = { 
     new   float[]   {0.299f,   0.299f,   0.299f,   0,   0},                
     new   float[]   {0.587f,   0.587f,   0.587f,   0,   0},                
     new   float[]   {0.114f,   0.114f,   0.114f,   0,   0},                
     new   float[]   {0,   0,   0,   1,   0},                  
     new   float[]   {0,   0,   0,   0,   1}
     };
     cm = new System.Drawing.Imaging.ColorMatrix(matrix);
     toGray = new System.Drawing.Imaging.ImageAttributes();
     toGray.SetColorMatrix(cm);
 }
Example #8
0
        public static Bitmap ReplaceColourInBitmap(Bitmap source, System.Drawing.Imaging.ColorMap[] remap)
        {
            Bitmap newmap = new Bitmap(source.Width, source.Height);

            System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
            ia.SetRemapTable(remap, System.Drawing.Imaging.ColorAdjustType.Bitmap);

            using (Graphics gr = Graphics.FromImage(newmap))
            {
                gr.DrawImage(source, new Rectangle(0, 0, source.Width, source.Height), 0, 0, source.Width, source.Height, GraphicsUnit.Pixel, ia);
            }

            return newmap;
        }
 public static System.Drawing.Bitmap ConvertSepiaTone(System.Drawing.Bitmap Image)
 {
     System.Drawing.Bitmap TempBitmap = Image;
     System.Drawing.Bitmap NewBitmap = new System.Drawing.Bitmap(TempBitmap.Width, TempBitmap.Height);
     System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap);
     float[][] FloatColorMatrix ={
             new float[] {.393f, .349f, .272f, 0, 0},
             new float[] {.769f, .686f, .534f, 0, 0},
             new float[] {.189f, .168f, .131f, 0, 0},
             new float[] {0, 0, 0, 1, 0},
             new float[] {0, 0, 0, 0, 1}
         };
     System.Drawing.Imaging.ColorMatrix NewColorMatrix = new System.Drawing.Imaging.ColorMatrix(FloatColorMatrix);
     System.Drawing.Imaging.ImageAttributes Attributes = new System.Drawing.Imaging.ImageAttributes();
     Attributes.SetColorMatrix(NewColorMatrix);
     NewGraphics.DrawImage(TempBitmap, new System.Drawing.Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, System.Drawing.GraphicsUnit.Pixel, Attributes);
     NewGraphics.Dispose();
     return NewBitmap;
 }
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;
            graphics.SmoothingMode = SmoothingMode.HighQuality;
            graphics.CompositingQuality = CompositingQuality.GammaCorrected;
            SolidBrush br = new SolidBrush(c);
            graphics.FillEllipse(br, 0, 0, radius * 2, radius * 2);
            br.Dispose();
            if (overlay != null)
            {
                TextureBrush br2 = new TextureBrush(overlay);

                //SolidBrush br2 = new SolidBrush(Color.FromArgb(1, 255, 255, 255));
                //graphics.FillEllipse(br2, 0, 0, radius * 2, radius * 2);
                //br2.Dispose();

                System.Drawing.Imaging.ImageAttributes attr = new System.Drawing.Imaging.ImageAttributes();

                graphics.DrawImage(overlay, new Rectangle(0, 0, radius*2, radius*2), 0, 0, overlay.Width, overlay.Height, GraphicsUnit.Pixel, attr);
            }
        }
        public static System.Drawing.Bitmap ConvertBlackAndWhite(System.Drawing.Image TempImage)
        {
            System.Drawing.Imaging.ImageFormat ImageFormat = TempImage.RawFormat;
            System.Drawing.Bitmap TempBitmap = new System.Drawing.Bitmap(TempImage, TempImage.Width, TempImage.Height);

            System.Drawing.Bitmap NewBitmap = new System.Drawing.Bitmap(TempBitmap.Width, TempBitmap.Height);
            System.Drawing.Graphics NewGraphics = System.Drawing.Graphics.FromImage(NewBitmap);
            float[][] FloatColorMatrix ={
                    new float[] {.3f, .3f, .3f, 0, 0},
                    new float[] {.59f, .59f, .59f, 0, 0},
                    new float[] {.11f, .11f, .11f, 0, 0},
                    new float[] {0, 0, 0, 1, 0},
                    new float[] {0, 0, 0, 0, 1}
                };

            System.Drawing.Imaging.ColorMatrix NewColorMatrix = new System.Drawing.Imaging.ColorMatrix(FloatColorMatrix);
            System.Drawing.Imaging.ImageAttributes Attributes = new System.Drawing.Imaging.ImageAttributes();
            Attributes.SetColorMatrix(NewColorMatrix);
            NewGraphics.DrawImage(TempBitmap, new System.Drawing.Rectangle(0, 0, TempBitmap.Width, TempBitmap.Height), 0, 0, TempBitmap.Width, TempBitmap.Height, System.Drawing.GraphicsUnit.Pixel, Attributes);
            NewGraphics.Dispose();
            return NewBitmap;
            //NewBitmap.Save(NewFileName, ImageFormat);
        }
Example #12
0
        /// <summary>
        /// Generates a thumbnail 
        /// </summary>
        /// <param name="tgen">The 
        /// <see cref="Microsoft.Expression.Encoder.ThumbnailGenerator"/>
        /// to use to generate the thumbnail.</param>
        /// <param name="time">The time of the thumbnail.</param>
        /// <param name="thumbWidth">Width of the thumbnail.</param>
        /// <param name="thumbHeight">Height of the thumbnail.</param>
        /// <param name="srcRect">The source rect to use when clipping the thumbnail.</param>
        /// <returns>A <see cref="System.Drawing.Bitmap"/>.</returns>
        /// <remarks>
        /// Generates the thumbnail at the orignal source size and then resizes it.
        /// </remarks>
        public static System.Drawing.Bitmap GenerateThumbnail(MSEEncoder.ThumbnailGenerator tgen,
            TimeSpan time,
            int thumbWidth,
            int thumbHeight,
            System.Drawing.Rectangle srcRect)
        {
            System.Drawing.Bitmap resized = new System.Drawing.Bitmap (thumbWidth, thumbHeight);

            System.Drawing.Bitmap original = null;
            int counter = 0;

            while (original == null)
                {
                try
                    {
                    original = tgen.CreateThumbnail (time);
                    }
                catch (MSEEncoder.UnableToCreateThumbnailException)
                    {
                    THelper.Error ("Unable to create thumbnail at time {0}",
                                    time.ToString (@"h\:mm\:ss\.ffff"));
                    time += new TimeSpan (0, 0, 0, 0, 50);
                    THelper.Error (" Trying time {0}",
                                    time.ToString (@"h\:mm\:ss\.ffff"));
                    counter++;
                    if (counter > 20)
                        throw;
                    }
                }

            using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage (resized))
                {
                // No alpha channel usage
                graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                //graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                //graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

                // Affects image resizing
                graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                // Affects anti-aliasing of filled edges
                //graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                using (System.Drawing.Imaging.ImageAttributes att =
                            new System.Drawing.Imaging.ImageAttributes ())
                    {
                    att.SetWrapMode (System.Drawing.Drawing2D.WrapMode.TileFlipXY);
                    graphics.DrawImage (original,
                                        new System.Drawing.Rectangle (0, 0, thumbWidth, thumbHeight),
                                        srcRect.X, srcRect.Y,
                                        srcRect.Width, srcRect.Height,
                                        System.Drawing.GraphicsUnit.Pixel,
                                        att);
                    }
                }
            original.Dispose();

            return resized;
        }
Example #13
0
        /// <summary>
        /// Generates a thumbnail OBSOLETE
        /// </summary>
        /// <param name="mediaItem">The <see cref="Microsoft.Expression.Encoder.MediaItem"/>
        /// to use to generate the thumbnail.</param>
        /// <param name="time">The time of the thumbnail.</param>
        /// <param name="thumbWidth">Width of the thumbnail.</param>
        /// <param name="thumbHeight">Height of the thumbnail.</param>
        /// <param name="srcRect">The source rect to use when clipping the thumbnail.</param>
        /// <returns>A <see cref="System.Drawing.Bitmap"/>.</returns>
        /// <remarks>
        /// Generates the thumbnail at the orignal source size and then resizes it.
        /// </remarks>
        public static System.Drawing.Bitmap GenerateThumbnail(MSEEncoder.MediaItem mediaItem, 
            TimeSpan time,
            int thumbWidth,
            int thumbHeight,
            System.Drawing.Rectangle srcRect)
        {
            System.Drawing.Bitmap resized = new System.Drawing.Bitmap (thumbWidth, thumbHeight);

            using (System.Drawing.Bitmap original =
                        mediaItem.MainMediaFile.GetThumbnail (time, mediaItem.OriginalVideoSize)) {
                using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage (resized)) {
                    // No alpha channel usage
                    graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                    //graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                    //graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

                    // Affects image resizing
                    graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                    // Affects anti-aliasing of filled edges
                    //graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                    using (System.Drawing.Imaging.ImageAttributes att =
                              new System.Drawing.Imaging.ImageAttributes ()) {
                        att.SetWrapMode (System.Drawing.Drawing2D.WrapMode.TileFlipXY);
                        graphics.DrawImage (original,
                                            new System.Drawing.Rectangle(0, 0, thumbWidth, thumbHeight),
                                            srcRect.X, srcRect.Y,
                                            srcRect.Width, srcRect.Height,
                                            System.Drawing.GraphicsUnit.Pixel,
                                            att);
                        }
                    }
                }

            return resized;
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.Drawing.Imaging.ImageAttributes imageAttributes1 = new System.Drawing.Imaging.ImageAttributes();
     System.Drawing.Imaging.ImageAttributes imageAttributes2 = new System.Drawing.Imaging.ImageAttributes();
     System.Drawing.Imaging.ImageAttributes imageAttributes3 = new System.Drawing.Imaging.ImageAttributes();
     System.Drawing.Imaging.ImageAttributes imageAttributes4 = new System.Drawing.Imaging.ImageAttributes();
     this._editButtonsUpdateTimer = new System.Windows.Forms.Timer(this.components);
     this._handleMessageTimer     = new System.Windows.Forms.Timer(this.components);
     this.settingsLauncherHelper1 = new SIL.Windows.Forms.SettingProtection.SettingsProtectionHelper(this.components);
     this._L10NSharpExtender      = new L10NSharp.UI.L10NSharpExtender(this.components);
     this._splitContainer1        = new Bloom.ToPalaso.BetterSplitContainer(this.components);
     this._splitContainer2        = new Bloom.ToPalaso.BetterSplitContainer(this.components);
     this._topBarPanel            = new System.Windows.Forms.Panel();
     this._undoButton             = new SIL.Windows.Forms.Widgets.BitmapButton();
     this._cutButton                = new SIL.Windows.Forms.Widgets.BitmapButton();
     this._pasteButton              = new SIL.Windows.Forms.Widgets.BitmapButton();
     this._copyButton               = new SIL.Windows.Forms.Widgets.BitmapButton();
     this._menusToolStrip           = new System.Windows.Forms.ToolStrip();
     this._contentLanguagesDropdown = new System.Windows.Forms.ToolStripDropDownButton();
     this._layoutChoices            = new System.Windows.Forms.ToolStripDropDownButton();
     this._browser1 = new Bloom.Browser();
     this._splitTemplateAndSource = new Bloom.ToPalaso.BetterSplitContainer(this.components);
     this._betterToolTip1         = new Bloom.ToPalaso.BetterToolTip(this.components);
     ((System.ComponentModel.ISupportInitialize)(this._L10NSharpExtender)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this._splitContainer1)).BeginInit();
     this._splitContainer1.Panel2.SuspendLayout();
     this._splitContainer1.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this._splitContainer2)).BeginInit();
     this._splitContainer2.Panel1.SuspendLayout();
     this._splitContainer2.Panel2.SuspendLayout();
     this._splitContainer2.SuspendLayout();
     this._topBarPanel.SuspendLayout();
     this._menusToolStrip.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this._splitTemplateAndSource)).BeginInit();
     this._splitTemplateAndSource.SuspendLayout();
     this.SuspendLayout();
     //
     // _editButtonsUpdateTimer
     //
     this._editButtonsUpdateTimer.Tick += new System.EventHandler(this._editButtonsUpdateTimer_Tick);
     //
     // _handleMessageTimer
     //
     this._handleMessageTimer.Tick += new System.EventHandler(this._handleMessageTimer_Tick);
     //
     // _L10NSharpExtender
     //
     this._L10NSharpExtender.LocalizationManagerId = "Bloom";
     this._L10NSharpExtender.PrefixForNewItems     = null;
     //
     // _splitContainer1
     //
     this._splitContainer1.BackColor  = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
     this._splitContainer1.Dock       = System.Windows.Forms.DockStyle.Fill;
     this._splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
     this._L10NSharpExtender.SetLocalizableToolTip(this._splitContainer1, null);
     this._L10NSharpExtender.SetLocalizationComment(this._splitContainer1, null);
     this._L10NSharpExtender.SetLocalizingId(this._splitContainer1, "EditTab._splitContainer1");
     this._splitContainer1.Location = new System.Drawing.Point(0, 0);
     this._splitContainer1.Margin   = new System.Windows.Forms.Padding(4);
     this._splitContainer1.Name     = "_splitContainer1";
     //
     // _splitContainer1.Panel1
     //
     this._splitContainer1.Panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
     //
     // _splitContainer1.Panel2
     //
     this._splitContainer1.Panel2.Controls.Add(this._splitContainer2);
     this._splitContainer1.Size             = new System.Drawing.Size(1200, 561);
     this._splitContainer1.SplitterDistance = 200;
     this._splitContainer1.SplitterWidth    = 10;
     this._splitContainer1.TabIndex         = 0;
     this._splitContainer1.TabStop          = false;
     //
     // _splitContainer2
     //
     this._splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
     this._L10NSharpExtender.SetLocalizableToolTip(this._splitContainer2, null);
     this._L10NSharpExtender.SetLocalizationComment(this._splitContainer2, null);
     this._L10NSharpExtender.SetLocalizingId(this._splitContainer2, "EditTab._splitContainer2");
     this._splitContainer2.Location = new System.Drawing.Point(0, 0);
     this._splitContainer2.Margin   = new System.Windows.Forms.Padding(4);
     this._splitContainer2.Name     = "_splitContainer2";
     //
     // _splitContainer2.Panel1
     //
     this._splitContainer2.Panel1.Controls.Add(this._topBarPanel);
     this._splitContainer2.Panel1.Controls.Add(this._browser1);
     //
     // _splitContainer2.Panel2
     //
     this._splitContainer2.Panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(63)))), ((int)(((byte)(64)))));
     this._splitContainer2.Panel2.Controls.Add(this._splitTemplateAndSource);
     this._splitContainer2.Size             = new System.Drawing.Size(990, 561);
     this._splitContainer2.SplitterDistance = 826;
     this._splitContainer2.SplitterWidth    = 10;
     this._splitContainer2.TabIndex         = 0;
     this._splitContainer2.TabStop          = false;
     //
     // _topBarPanel
     //
     this._topBarPanel.Controls.Add(this._undoButton);
     this._topBarPanel.Controls.Add(this._cutButton);
     this._topBarPanel.Controls.Add(this._pasteButton);
     this._topBarPanel.Controls.Add(this._copyButton);
     this._topBarPanel.Controls.Add(this._menusToolStrip);
     this._topBarPanel.Location = new System.Drawing.Point(97, 225);
     this._topBarPanel.Name     = "_topBarPanel";
     this._topBarPanel.Size     = new System.Drawing.Size(384, 66);
     this._topBarPanel.TabIndex = 3;
     //
     // _undoButton
     //
     this._undoButton.BackColor                 = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(102)))), ((int)(((byte)(143)))));
     this._undoButton.BorderColor               = System.Drawing.Color.Transparent;
     this._undoButton.DisabledTextColor         = System.Drawing.Color.FromArgb(((int)(((byte)(114)))), ((int)(((byte)(74)))), ((int)(((byte)(106)))));
     this._undoButton.FlatAppearance.BorderSize = 0;
     this._undoButton.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this._undoButton.FocusRectangleEnabled     = true;
     this._undoButton.Font                       = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this._undoButton.ForeColor                  = System.Drawing.Color.FromArgb(((int)(((byte)(49)))), ((int)(((byte)(32)))), ((int)(((byte)(46)))));
     this._undoButton.Image                      = null;
     this._undoButton.ImageAlign                 = System.Drawing.ContentAlignment.TopCenter;
     this._undoButton.ImageAttributes            = imageAttributes1;
     this._undoButton.ImageBorderColor           = System.Drawing.Color.Transparent;
     this._undoButton.ImageBorderEnabled         = false;
     this._undoButton.ImageDropShadow            = false;
     this._undoButton.ImageFocused               = null;
     this._undoButton.ImageInactive              = global::Bloom.Properties.Resources.undoDisabled32x32;
     this._undoButton.ImageMouseOver             = null;
     this._undoButton.ImageNormal                = global::Bloom.Properties.Resources.undo32x32;
     this._undoButton.ImagePressed               = null;
     this._undoButton.InnerBorderColor           = System.Drawing.Color.Transparent;
     this._undoButton.InnerBorderColor_Focus     = System.Drawing.Color.LightBlue;
     this._undoButton.InnerBorderColor_MouseOver = System.Drawing.Color.Gold;
     this._L10NSharpExtender.SetLocalizableToolTip(this._undoButton, null);
     this._L10NSharpExtender.SetLocalizationComment(this._undoButton, null);
     this._L10NSharpExtender.SetLocalizingId(this._undoButton, "EditTab.UndoButton");
     this._undoButton.Location             = new System.Drawing.Point(128, 0);
     this._undoButton.Name                 = "_undoButton";
     this._undoButton.OffsetPressedContent = true;
     this._undoButton.Size                 = new System.Drawing.Size(54, 66);
     this._undoButton.StretchImage         = false;
     this._undoButton.TabIndex             = 9;
     this._undoButton.Text                 = "Undo";
     this._undoButton.TextAlign            = System.Drawing.ContentAlignment.BottomCenter;
     this._undoButton.TextDropShadow       = false;
     this._betterToolTip1.SetToolTip(this._undoButton, "Undo (Ctrl+Z)");
     this._betterToolTip1.SetToolTipWhenDisabled(this._undoButton, "There is nothing to undo");
     this._undoButton.UseVisualStyleBackColor = false;
     this._undoButton.Click += new System.EventHandler(this._undoButton_Click);
     //
     // _cutButton
     //
     this._cutButton.BackColor                 = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(102)))), ((int)(((byte)(143)))));
     this._cutButton.BorderColor               = System.Drawing.Color.Transparent;
     this._cutButton.DisabledTextColor         = System.Drawing.Color.FromArgb(((int)(((byte)(114)))), ((int)(((byte)(74)))), ((int)(((byte)(106)))));
     this._cutButton.FlatAppearance.BorderSize = 0;
     this._cutButton.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this._cutButton.FocusRectangleEnabled     = true;
     this._cutButton.Font                       = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this._cutButton.ForeColor                  = System.Drawing.Color.FromArgb(((int)(((byte)(49)))), ((int)(((byte)(32)))), ((int)(((byte)(46)))));
     this._cutButton.Image                      = null;
     this._cutButton.ImageAlign                 = System.Drawing.ContentAlignment.MiddleLeft;
     this._cutButton.ImageAttributes            = imageAttributes2;
     this._cutButton.ImageBorderColor           = System.Drawing.Color.Transparent;
     this._cutButton.ImageBorderEnabled         = false;
     this._cutButton.ImageDropShadow            = false;
     this._cutButton.ImageFocused               = null;
     this._cutButton.ImageInactive              = global::Bloom.Properties.Resources.cutDisable16x16;
     this._cutButton.ImageMouseOver             = null;
     this._cutButton.ImageNormal                = global::Bloom.Properties.Resources.Cut16x16;
     this._cutButton.ImagePressed               = null;
     this._cutButton.InnerBorderColor           = System.Drawing.Color.Transparent;
     this._cutButton.InnerBorderColor_Focus     = System.Drawing.Color.LightBlue;
     this._cutButton.InnerBorderColor_MouseOver = System.Drawing.Color.Gold;
     this._L10NSharpExtender.SetLocalizableToolTip(this._cutButton, null);
     this._L10NSharpExtender.SetLocalizationComment(this._cutButton, null);
     this._L10NSharpExtender.SetLocalizingId(this._cutButton, "EditTab.CutButton");
     this._cutButton.Location             = new System.Drawing.Point(52, 7);
     this._cutButton.Name                 = "_cutButton";
     this._cutButton.OffsetPressedContent = true;
     this._cutButton.Size                 = new System.Drawing.Size(75, 20);
     this._cutButton.StretchImage         = false;
     this._cutButton.TabIndex             = 8;
     this._cutButton.Text                 = "Cut";
     this._cutButton.TextAlign            = System.Drawing.ContentAlignment.MiddleLeft;
     this._cutButton.TextDropShadow       = false;
     this._betterToolTip1.SetToolTip(this._cutButton, "Cut (Ctrl+X)");
     this._cutButton.UseVisualStyleBackColor = false;
     this._cutButton.Click += new System.EventHandler(this._cutButton_Click);
     //
     // _pasteButton
     //
     this._pasteButton.BackColor                 = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(102)))), ((int)(((byte)(143)))));
     this._pasteButton.BorderColor               = System.Drawing.Color.Transparent;
     this._pasteButton.DisabledTextColor         = System.Drawing.Color.FromArgb(((int)(((byte)(114)))), ((int)(((byte)(74)))), ((int)(((byte)(106)))));
     this._pasteButton.FlatAppearance.BorderSize = 0;
     this._pasteButton.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this._pasteButton.FocusRectangleEnabled     = true;
     this._pasteButton.Font                       = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this._pasteButton.ForeColor                  = System.Drawing.Color.FromArgb(((int)(((byte)(49)))), ((int)(((byte)(32)))), ((int)(((byte)(46)))));
     this._pasteButton.Image                      = null;
     this._pasteButton.ImageAlign                 = System.Drawing.ContentAlignment.TopCenter;
     this._pasteButton.ImageAttributes            = imageAttributes3;
     this._pasteButton.ImageBorderColor           = System.Drawing.Color.Transparent;
     this._pasteButton.ImageBorderEnabled         = false;
     this._pasteButton.ImageDropShadow            = false;
     this._pasteButton.ImageFocused               = null;
     this._pasteButton.ImageInactive              = global::Bloom.Properties.Resources.pasteDisabled32x32;
     this._pasteButton.ImageMouseOver             = null;
     this._pasteButton.ImageNormal                = global::Bloom.Properties.Resources.paste32x32;
     this._pasteButton.ImagePressed               = null;
     this._pasteButton.InnerBorderColor           = System.Drawing.Color.Transparent;
     this._pasteButton.InnerBorderColor_Focus     = System.Drawing.Color.LightBlue;
     this._pasteButton.InnerBorderColor_MouseOver = System.Drawing.Color.Gold;
     this._L10NSharpExtender.SetLocalizableToolTip(this._pasteButton, null);
     this._L10NSharpExtender.SetLocalizationComment(this._pasteButton, null);
     this._L10NSharpExtender.SetLocalizingId(this._pasteButton, "EditTab.PasteButton");
     this._pasteButton.Location             = new System.Drawing.Point(2, 5);
     this._pasteButton.Name                 = "_pasteButton";
     this._pasteButton.OffsetPressedContent = true;
     this._pasteButton.Size                 = new System.Drawing.Size(54, 61);
     this._pasteButton.StretchImage         = false;
     this._pasteButton.TabIndex             = 7;
     this._pasteButton.Text                 = "Paste";
     this._pasteButton.TextAlign            = System.Drawing.ContentAlignment.BottomCenter;
     this._pasteButton.TextDropShadow       = false;
     this._betterToolTip1.SetToolTip(this._pasteButton, "Paste (Ctrl+V)");
     this._betterToolTip1.SetToolTipWhenDisabled(this._pasteButton, "There is nothing on the Clipboard that you can paste here.");
     this._pasteButton.UseVisualStyleBackColor = false;
     this._pasteButton.Click += new System.EventHandler(this._pasteButton_Click);
     //
     // _copyButton
     //
     this._copyButton.BackColor                 = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(102)))), ((int)(((byte)(143)))));
     this._copyButton.BorderColor               = System.Drawing.Color.Transparent;
     this._copyButton.DisabledTextColor         = System.Drawing.Color.FromArgb(((int)(((byte)(114)))), ((int)(((byte)(74)))), ((int)(((byte)(106)))));
     this._copyButton.FlatAppearance.BorderSize = 0;
     this._copyButton.FlatStyle                 = System.Windows.Forms.FlatStyle.Flat;
     this._copyButton.FocusRectangleEnabled     = true;
     this._copyButton.Font                       = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this._copyButton.ForeColor                  = System.Drawing.Color.FromArgb(((int)(((byte)(49)))), ((int)(((byte)(32)))), ((int)(((byte)(46)))));
     this._copyButton.Image                      = null;
     this._copyButton.ImageAlign                 = System.Drawing.ContentAlignment.MiddleLeft;
     this._copyButton.ImageAttributes            = imageAttributes4;
     this._copyButton.ImageBorderColor           = System.Drawing.Color.Transparent;
     this._copyButton.ImageBorderEnabled         = false;
     this._copyButton.ImageDropShadow            = false;
     this._copyButton.ImageFocused               = null;
     this._copyButton.ImageInactive              = global::Bloom.Properties.Resources.copyDisable16x16;
     this._copyButton.ImageMouseOver             = null;
     this._copyButton.ImageNormal                = global::Bloom.Properties.Resources.Copy16x16;
     this._copyButton.ImagePressed               = null;
     this._copyButton.InnerBorderColor           = System.Drawing.Color.Transparent;
     this._copyButton.InnerBorderColor_Focus     = System.Drawing.Color.LightBlue;
     this._copyButton.InnerBorderColor_MouseOver = System.Drawing.Color.Gold;
     this._L10NSharpExtender.SetLocalizableToolTip(this._copyButton, null);
     this._L10NSharpExtender.SetLocalizationComment(this._copyButton, null);
     this._L10NSharpExtender.SetLocalizingId(this._copyButton, "EditTab.CopyButton");
     this._copyButton.Location             = new System.Drawing.Point(52, 29);
     this._copyButton.Name                 = "_copyButton";
     this._copyButton.OffsetPressedContent = true;
     this._copyButton.Size                 = new System.Drawing.Size(75, 19);
     this._copyButton.StretchImage         = false;
     this._copyButton.TabIndex             = 6;
     this._copyButton.Text                 = "Copy";
     this._copyButton.TextAlign            = System.Drawing.ContentAlignment.MiddleLeft;
     this._copyButton.TextDropShadow       = false;
     this._betterToolTip1.SetToolTip(this._copyButton, "Copy (Ctrl+C)");
     this._betterToolTip1.SetToolTipWhenDisabled(this._copyButton, "You need to select some text before you can copy it");
     this._copyButton.UseVisualStyleBackColor = false;
     this._copyButton.Click += new System.EventHandler(this._copyButton_Click);
     //
     // _menusToolStrip
     //
     this._menusToolStrip.AutoSize    = false;
     this._menusToolStrip.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(102)))), ((int)(((byte)(143)))));
     this._menusToolStrip.CanOverflow = false;
     this._menusToolStrip.Dock        = System.Windows.Forms.DockStyle.None;
     this._menusToolStrip.GripStyle   = System.Windows.Forms.ToolStripGripStyle.Hidden;
     this._menusToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this._contentLanguagesDropdown,
         this._layoutChoices
     });
     this._menusToolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Table;
     this._L10NSharpExtender.SetLocalizableToolTip(this._menusToolStrip, null);
     this._L10NSharpExtender.SetLocalizationComment(this._menusToolStrip, null);
     this._L10NSharpExtender.SetLocalizationPriority(this._menusToolStrip, L10NSharp.LocalizationPriority.NotLocalizable);
     this._L10NSharpExtender.SetLocalizingId(this._menusToolStrip, "EditTab.MenusToolStrip");
     this._menusToolStrip.Location = new System.Drawing.Point(200, 0);
     this._menusToolStrip.Name     = "_menusToolStrip";
     this._menusToolStrip.Size     = new System.Drawing.Size(165, 56);
     this._menusToolStrip.TabIndex = 2;
     //
     // _contentLanguagesDropdown
     //
     this._contentLanguagesDropdown.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
     this._contentLanguagesDropdown.ForeColor             = System.Drawing.Color.FromArgb(((int)(((byte)(49)))), ((int)(((byte)(32)))), ((int)(((byte)(46)))));
     this._contentLanguagesDropdown.ImageTransparentColor = System.Drawing.Color.Magenta;
     this._L10NSharpExtender.SetLocalizableToolTip(this._contentLanguagesDropdown, "Choose language to make this a bilingual or trilingual book");
     this._L10NSharpExtender.SetLocalizationComment(this._contentLanguagesDropdown, null);
     this._L10NSharpExtender.SetLocalizingId(this._contentLanguagesDropdown, "EditTab.ContentLanguagesDropdown");
     this._contentLanguagesDropdown.Name = "_contentLanguagesDropdown";
     this._contentLanguagesDropdown.Size = new System.Drawing.Size(129, 19);
     this._contentLanguagesDropdown.Text = "Multilingual Settings";
     //
     // _layoutChoices
     //
     this._layoutChoices.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
     this._layoutChoices.ForeColor             = System.Drawing.Color.FromArgb(((int)(((byte)(49)))), ((int)(((byte)(32)))), ((int)(((byte)(46)))));
     this._layoutChoices.ImageTransparentColor = System.Drawing.Color.Magenta;
     this._L10NSharpExtender.SetLocalizableToolTip(this._layoutChoices, "");
     this._L10NSharpExtender.SetLocalizationComment(this._layoutChoices, null);
     this._L10NSharpExtender.SetLocalizationPriority(this._layoutChoices, L10NSharp.LocalizationPriority.NotLocalizable);
     this._L10NSharpExtender.SetLocalizingId(this._layoutChoices, "EditTab.PageSizeAndOrientationChoices");
     this._layoutChoices.Name        = "_layoutChoices";
     this._layoutChoices.Size        = new System.Drawing.Size(50, 19);
     this._layoutChoices.Text        = "Paper";
     this._layoutChoices.ToolTipText = "(set dynamically, see code)";
     //
     // _browser1
     //
     this._browser1.BackColor           = System.Drawing.Color.DarkGray;
     this._browser1.ContextMenuProvider = null;
     this._browser1.ControlKeyEvent     = null;
     this._browser1.Dock     = System.Windows.Forms.DockStyle.Fill;
     this._browser1.Isolator = null;
     this._L10NSharpExtender.SetLocalizableToolTip(this._browser1, null);
     this._L10NSharpExtender.SetLocalizationComment(this._browser1, null);
     this._L10NSharpExtender.SetLocalizingId(this._browser1, "EditTab.Browser");
     this._browser1.Location = new System.Drawing.Point(0, 0);
     this._browser1.Margin   = new System.Windows.Forms.Padding(5);
     this._browser1.Name     = "_browser1";
     this._browser1.Size     = new System.Drawing.Size(826, 561);
     this._browser1.TabIndex = 1;
     this._browser1.VerticalScrollDistance = 0;
     this._browser1.OnBrowserClick        += new System.EventHandler(this._browser1_OnBrowserClick);
     //
     // _splitTemplateAndSource
     //
     this._splitTemplateAndSource.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(150)))), ((int)(((byte)(102)))), ((int)(((byte)(143)))));
     this._splitTemplateAndSource.Dock      = System.Windows.Forms.DockStyle.Fill;
     this._L10NSharpExtender.SetLocalizableToolTip(this._splitTemplateAndSource, null);
     this._L10NSharpExtender.SetLocalizationComment(this._splitTemplateAndSource, null);
     this._L10NSharpExtender.SetLocalizingId(this._splitTemplateAndSource, "EditTab.SplitTemplateAndSource");
     this._splitTemplateAndSource.Location    = new System.Drawing.Point(0, 0);
     this._splitTemplateAndSource.Margin      = new System.Windows.Forms.Padding(4);
     this._splitTemplateAndSource.Name        = "_splitTemplateAndSource";
     this._splitTemplateAndSource.Orientation = System.Windows.Forms.Orientation.Horizontal;
     //
     // _splitTemplateAndSource.Panel1
     //
     this._splitTemplateAndSource.Panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
     //
     // _splitTemplateAndSource.Panel2
     //
     this._splitTemplateAndSource.Panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
     this._splitTemplateAndSource.Size             = new System.Drawing.Size(154, 561);
     this._splitTemplateAndSource.SplitterDistance = 230;
     this._splitTemplateAndSource.SplitterWidth    = 10;
     this._splitTemplateAndSource.TabIndex         = 0;
     this._splitTemplateAndSource.TabStop          = false;
     //
     // _betterToolTip1
     //
     this._L10NSharpExtender.SetLocalizableToolTip(this._betterToolTip1, null);
     this._L10NSharpExtender.SetLocalizationComment(this._betterToolTip1, null);
     this._L10NSharpExtender.SetLocalizingId(this._betterToolTip1, "BTT_id");
     //
     // EditingView
     //
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
     this.Controls.Add(this._splitContainer1);
     this._L10NSharpExtender.SetLocalizableToolTip(this, null);
     this._L10NSharpExtender.SetLocalizationComment(this, null);
     this._L10NSharpExtender.SetLocalizingId(this, "EditTab.EditingView");
     this.Margin = new System.Windows.Forms.Padding(4);
     this.Name   = "EditingView";
     this.Size   = new System.Drawing.Size(1200, 561);
     ((System.ComponentModel.ISupportInitialize)(this._L10NSharpExtender)).EndInit();
     this._splitContainer1.Panel2.ResumeLayout(false);
     ((System.ComponentModel.ISupportInitialize)(this._splitContainer1)).EndInit();
     this._splitContainer1.ResumeLayout(false);
     this._splitContainer2.Panel1.ResumeLayout(false);
     this._splitContainer2.Panel2.ResumeLayout(false);
     ((System.ComponentModel.ISupportInitialize)(this._splitContainer2)).EndInit();
     this._splitContainer2.ResumeLayout(false);
     this._topBarPanel.ResumeLayout(false);
     this._menusToolStrip.ResumeLayout(false);
     this._menusToolStrip.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)(this._splitTemplateAndSource)).EndInit();
     this._splitTemplateAndSource.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Example #15
0
        /// <summary>
        /// 加图片水印
        /// </summary>
        /// <param name="filename">文件名</param>
        /// <param name="watermarkFilename">水印文件名</param>
        /// <param name="watermarkStatus">图片水印位置:0=不使用 1=左上 2=中上 3=右上 4=左中 ... 9=右下</param>
        /// <param name="quality">是否是高质量图片 取值范围0--100</param> 
        /// <param name="watermarkTransparency">图片水印透明度 取值范围1--10 (10为不透明)</param>
        public static void AddImageSignPic(string Path, string filename, string watermarkFilename, int watermarkStatus, int quality, int watermarkTransparency)
        {
            System.Drawing.Image img = System.Drawing.Image.FromFile(Path);
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);

            //设置高质量插值法
            //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            //设置高质量,低速度呈现平滑程度
            //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            System.Drawing.Image watermark = new System.Drawing.Bitmap(watermarkFilename);

            if (watermark.Height >= img.Height || watermark.Width >= img.Width)
            {
                return;
            }

            System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
            System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();

            colorMap.OldColor = System.Drawing.Color.FromArgb(255, 0, 255, 0);
            colorMap.NewColor = System.Drawing.Color.FromArgb(0, 0, 0, 0);
            System.Drawing.Imaging.ColorMap[] remapTable = { colorMap };

            imageAttributes.SetRemapTable(remapTable, System.Drawing.Imaging.ColorAdjustType.Bitmap);

            float transparency = 0.5F;
            if (watermarkTransparency >= 1 && watermarkTransparency <= 10)
            {
                transparency = (watermarkTransparency / 10.0F);
            }

            float[][] colorMatrixElements = {
                                                new float[] {1.0f,  0.0f,  0.0f,  0.0f, 0.0f},
                                                new float[] {0.0f,  1.0f,  0.0f,  0.0f, 0.0f},
                                                new float[] {0.0f,  0.0f,  1.0f,  0.0f, 0.0f},
                                                new float[] {0.0f,  0.0f,  0.0f,  transparency, 0.0f},
                                                new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}
                                            };

            System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);

            imageAttributes.SetColorMatrix(colorMatrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);

            int xpos = 0;
            int ypos = 0;

            switch (watermarkStatus)
            {
                case 1:
                    xpos = (int)(img.Width * (float).01);
                    ypos = (int)(img.Height * (float).01);
                    break;
                case 2:
                    xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
                    ypos = (int)(img.Height * (float).01);
                    break;
                case 3:
                    xpos = (int)((img.Width * (float).99) - (watermark.Width));
                    ypos = (int)(img.Height * (float).01);
                    break;
                case 4:
                    xpos = (int)(img.Width * (float).01);
                    ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
                    break;
                case 5:
                    xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
                    ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
                    break;
                case 6:
                    xpos = (int)((img.Width * (float).99) - (watermark.Width));
                    ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
                    break;
                case 7:
                    xpos = (int)(img.Width * (float).01);
                    ypos = (int)((img.Height * (float).99) - watermark.Height);
                    break;
                case 8:
                    xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
                    ypos = (int)((img.Height * (float).99) - watermark.Height);
                    break;
                case 9:
                    xpos = (int)((img.Width * (float).99) - (watermark.Width));
                    ypos = (int)((img.Height * (float).99) - watermark.Height);
                    break;
            }

            g.DrawImage(watermark, new System.Drawing.Rectangle(xpos, ypos, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, System.Drawing.GraphicsUnit.Pixel, imageAttributes);

            System.Drawing.Imaging.ImageCodecInfo[] codecs = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
            System.Drawing.Imaging.ImageCodecInfo ici = null;
            foreach (System.Drawing.Imaging.ImageCodecInfo codec in codecs)
            {
                //if (codec.MimeType.IndexOf("jpeg") > -1)
                if (codec.MimeType.Contains("jpeg"))
                {
                    ici = codec;
                }
            }
            System.Drawing.Imaging.EncoderParameters encoderParams = new System.Drawing.Imaging.EncoderParameters();
            long[] qualityParam = new long[1];
            if (quality < 0 || quality > 100)
            {
                quality = 80;
            }
            qualityParam[0] = quality;

            System.Drawing.Imaging.EncoderParameter encoderParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityParam);
            encoderParams.Param[0] = encoderParam;

            if (ici != null)
            {
                img.Save(filename, ici, encoderParams);
            }
            else
            {
                img.Save(filename);
            }

            g.Dispose();
            img.Dispose();
            watermark.Dispose();
            imageAttributes.Dispose();
        }
Example #16
0
		public static void PaintButton(ButtonItem button, ItemPaintArgs pa)
		{
			System.Drawing.Graphics g=pa.Graphics;
			ThemeToolbar theme=pa.ThemeToolbar;
			ThemeToolbarParts part=ThemeToolbarParts.Button;
			ThemeToolbarStates state=ThemeToolbarStates.Normal;
			Color textColor=ButtonItemPainterHelper.GetTextColor(button,pa);

			Rectangle rectImage=Rectangle.Empty;
			Rectangle itemRect=button.DisplayRectangle;
			
			Font font=null;
			CompositeImage image=button.GetImage();

			font=button.GetFont(pa, false);

			eTextFormat format= GetStringFormat(button, pa, image);

			bool bSplitButton=(button.SubItems.Count>0 || button.PopupType==ePopupType.Container) && button.ShowSubItems && !button.SubItemsRect.IsEmpty;

			if(bSplitButton)
				part=ThemeToolbarParts.SplitButton;

			// Calculate image position
			if(image!=null)
			{
				if(button.ImagePosition==eImagePosition.Top || button.ImagePosition==eImagePosition.Bottom)
					rectImage=new Rectangle(button.ImageDrawRect.X,button.ImageDrawRect.Y,itemRect.Width,button.ImageDrawRect.Height);
				else
					rectImage=new Rectangle(button.ImageDrawRect.X,button.ImageDrawRect.Y,button.ImageDrawRect.Width,button.ImageDrawRect.Height);

				rectImage.Offset(itemRect.Left,itemRect.Top);
				rectImage.Offset((rectImage.Width-button.ImageSize.Width)/2,(rectImage.Height-button.ImageSize.Height)/2);
				rectImage.Width=button.ImageSize.Width;
				rectImage.Height=button.ImageSize.Height;
			}

			// Set the state and text brush
			if(!ButtonItemPainter.IsItemEnabled(button, pa))
			{
				state=ThemeToolbarStates.Disabled;
			}
			else if(button.IsMouseDown)
			{
				state=ThemeToolbarStates.Pressed;
			}
			else if(button.IsMouseOver && button.Checked)
			{
				state=ThemeToolbarStates.HotChecked;
			}
			else if(button.IsMouseOver || button.Expanded)
			{
				state=ThemeToolbarStates.Hot;
			}
			else if(button.Checked)
			{
				state=ThemeToolbarStates.Checked;
			}
			
			Rectangle backRect=button.DisplayRectangle;
			if(button.HotTrackingStyle==eHotTrackingStyle.Image && image!=null)
			{
				backRect=rectImage;
				backRect.Inflate(3,3);
			}
			else if(bSplitButton)
			{
				backRect.Width=backRect.Width-button.SubItemsRect.Width;
			}

			// Draw Button Background
			if(button.HotTrackingStyle!=eHotTrackingStyle.None)
			{
				theme.DrawBackground(g,part,state,backRect);
			}

			// Draw Image
			if(image!=null && button.ButtonStyle!=eButtonStyle.TextOnlyAlways)
			{
				if(state==ThemeToolbarStates.Normal && button.HotTrackingStyle==eHotTrackingStyle.Color)
				{
					// Draw gray-scale image for this hover style...
					float[][] array = new float[5][];
					array[0] = new float[5] {0.2125f, 0.2125f, 0.2125f, 0, 0};
					array[1] = new float[5] {0.5f, 0.5f, 0.5f, 0, 0};
					array[2] = new float[5] {0.0361f, 0.0361f, 0.0361f, 0, 0};
					array[3] = new float[5] {0,       0,       0,       1, 0};
					array[4] = new float[5] {0.2f,    0.2f,    0.2f,    0, 1};
					System.Drawing.Imaging.ColorMatrix grayMatrix = new System.Drawing.Imaging.ColorMatrix(array);
					System.Drawing.Imaging.ImageAttributes att = new System.Drawing.Imaging.ImageAttributes();
					att.SetColorMatrix(grayMatrix);
					//g.DrawImage(image,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,att);
					image.DrawImage(g,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,att);
				}
				else if(state==ThemeToolbarStates.Normal && !image.IsIcon)
				{
					// Draw image little bit lighter, I decied to use gamma it is easy
					System.Drawing.Imaging.ImageAttributes lightImageAttr = new System.Drawing.Imaging.ImageAttributes();
					lightImageAttr.SetGamma(.7f,System.Drawing.Imaging.ColorAdjustType.Bitmap);
					//g.DrawImage(image,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,lightImageAttr);
					image.DrawImage(g,rectImage,0,0,image.Width,image.Height,GraphicsUnit.Pixel,lightImageAttr);
				}
				else
				{
					image.DrawImage(g,rectImage);
				}
			}

			// Draw Text
			if(button.ButtonStyle==eButtonStyle.ImageAndText || button.ButtonStyle==eButtonStyle.TextOnlyAlways || image==null)
			{
				Rectangle rectText=button.TextDrawRect;
				if(button.ImagePosition==eImagePosition.Top || button.ImagePosition==eImagePosition.Bottom)
				{
					if(button.Orientation==eOrientation.Vertical)
					{
						rectText=new Rectangle(button.TextDrawRect.X,button.TextDrawRect.Y,button.TextDrawRect.Width,button.TextDrawRect.Height);
					}
					else
					{
						rectText=new Rectangle(button.TextDrawRect.X,button.TextDrawRect.Y,itemRect.Width,button.TextDrawRect.Height);
						if((button.SubItems.Count>0 || button.PopupType==ePopupType.Container) && button.ShowSubItems)
							rectText.Width-=10;
					}
					format|=eTextFormat.HorizontalCenter;
				}

				rectText.Offset(itemRect.Left,itemRect.Top);

				if(button.Orientation==eOrientation.Vertical)
				{
					g.RotateTransform(90);
					TextDrawing.DrawStringLegacy(g,ButtonItemPainter.GetDrawText(button.Text),font,textColor,new Rectangle(rectText.Top,-rectText.Right,rectText.Height,rectText.Width),format);
					g.ResetTransform();
				}
				else
				{
					if(rectText.Right>button.DisplayRectangle.Right)
						rectText.Width=button.DisplayRectangle.Right-rectText.Left;
					TextDrawing.DrawString(g,ButtonItemPainter.GetDrawText(button.Text),font,textColor,rectText,format);
					if(!button.DesignMode && button.Focused && !pa.IsOnMenu && !pa.IsOnMenuBar)
					{
						//SizeF szf=g.MeasureString(m_Text,font,rectText.Width,format);
						Rectangle r=rectText;
						//r.Width=(int)Math.Ceiling(szf.Width);
						//r.Height=(int)Math.Ceiling(szf.Height);
						//r.Inflate(1,1);
						System.Windows.Forms.ControlPaint.DrawFocusRectangle(g,r);
					}
				}				
			}

			// If it has subitems draw the triangle to indicate that
			if(bSplitButton)
			{
				part=ThemeToolbarParts.SplitButtonDropDown;
				
				if(!ButtonItemPainter.IsItemEnabled(button, pa))
					state=ThemeToolbarStates.Disabled;
				else
					state=ThemeToolbarStates.Normal;

				if(button.HotTrackingStyle!=eHotTrackingStyle.None && button.HotTrackingStyle!=eHotTrackingStyle.Image && ButtonItemPainter.IsItemEnabled(button, pa))
				{
					if(button.Expanded || button.IsMouseDown)
						state=ThemeToolbarStates.Pressed;
					else if(button.IsMouseOver && button.Checked)
						state=ThemeToolbarStates.HotChecked;
					else if(button.Checked)
						state=ThemeToolbarStates.Checked;
					else if(button.IsMouseOver)
						state=ThemeToolbarStates.Hot;
				}

                if (!button.AutoExpandOnClick)
                {
                    if (button.Orientation == eOrientation.Horizontal)
                    {
                        Rectangle r = button.SubItemsRect;
                        r.Offset(itemRect.X, itemRect.Y);
                        theme.DrawBackground(g, part, state, r);
                    }
                    else
                    {
                        Rectangle r = button.SubItemsRect;
                        r.Offset(itemRect.X, itemRect.Y);
                        theme.DrawBackground(g, part, state, r);
                    }
                }
			}

			if(button.Focused && button.DesignMode)
			{
				Rectangle r=itemRect;
				r.Inflate(-1,-1);
				DesignTime.DrawDesignTimeSelection(g,r,pa.Colors.ItemDesignTimeBorder);
			}

			if(image!=null)
				image.Dispose();
		}
Example #17
0
        //────────────────────────────────────────
        /// <summary>
        /// 全体図の描画。
        /// </summary>
        /// <param name="g"></param>
        /// <param name="isOnWindow"></param>
        /// <param name="memorySprite"></param>
        /// <param name="xBase">ベースX</param>
        /// <param name="yBase">ベースY</param>
        /// <param name="scale"></param>
        /// <param name="imgOpaque"></param>
        /// <param name="isImageGrid"></param>
        /// <param name="isVisible_Infodisplay"></param>
        /// <param name="infoDisplay"></param>
        public void Perform(
            Graphics g,
            bool isOnWindow,
            MemorySpriteImpl memorySprite,
            float xBase,
            float yBase,
            float scale,
            float imgOpaque,
            bool isImageGrid,
            bool isVisible_Infodisplay,
            PartnumberconfigImpl partnumberconf,
            Usercontrolview_Infodisplay infoDisplay
            )
        {
            // ビットマップ画像の不透明度を指定します。
            System.Drawing.Imaging.ImageAttributes ia;
            {
                System.Drawing.Imaging.ColorMatrix cm =
                    new System.Drawing.Imaging.ColorMatrix();
                cm.Matrix00 = 1;
                cm.Matrix11 = 1;
                cm.Matrix22 = 1;
                cm.Matrix33 = imgOpaque;//α値。0~1か?
                cm.Matrix44 = 1;

                //ImageAttributesオブジェクトの作成
                ia = new System.Drawing.Imaging.ImageAttributes();
                //ColorMatrixを設定する
                ia.SetColorMatrix(cm);
            }
            float leftSprite = 0;
            float topSprite = 0;
            if (isOnWindow)
            {
                leftSprite += memorySprite.Lefttop.X;
                topSprite += memorySprite.Lefttop.Y;
            }

            //
            // 表示画像の長方形(Image rectangle)
            RectangleF dstIrScaled = new RectangleF(
                leftSprite + xBase,
                topSprite + yBase,
                scale * (float)memorySprite.Bitmap.Width,
                scale * (float)memorySprite.Bitmap.Height
                );
            // グリッド枠の長方形(Grid frame rectangle)
            RectangleF dstGrScaled;
            {
                float col = memorySprite.CountcolumnResult;
                float row = memorySprite.CountrowResult;
                if (col < 1)
                {
                    col = 1;
                }

                if (row < 1)
                {
                    row = 1;
                }

                float cw = memorySprite.WidthcellResult;
                float ch = memorySprite.HeightcellResult;

                //グリッドのベース
                dstGrScaled = new RectangleF(
                                scale * memorySprite.GridLefttop.X + leftSprite + xBase,
                                scale * memorySprite.GridLefttop.Y + topSprite + yBase,
                                scale * col * cw,
                                scale * row * ch
                                );
            }

            // 太さ2pxの枠が収まるサイズ
            float borderWidth = 2.0f;
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;//ドット絵のまま拡縮するように。しかし、この指定だと半ピクセル左上にずれるバグ。
            g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;//半ピクセル左上にずれるバグに対応。

            //
            // 画像描画
            g.DrawImage(
                memorySprite.Bitmap,
                new Rectangle((int)dstIrScaled.X, (int)dstIrScaled.Y, (int)dstIrScaled.Width, (int)dstIrScaled.Height),
                0,
                0,
                memorySprite.Bitmap.Width,
                memorySprite.Bitmap.Height,
                GraphicsUnit.Pixel,
                ia
                );

            // 枠線
            if (isImageGrid)
            {

                //
                // 枠線:影
                //
                // オフセット 0、0 だと、上辺、左辺の緑線、黒線が保存画像から見切れます。
                // オフセット 1、1 だと、上辺、左辺の緑線が保存画像から見切れます。
                // オフセット 2、2 だと、上辺、左辺の緑線、黒線が保存画像に入ります。
                //
                // X,Yを、2ドット右下にずらします。
                dstGrScaled.Offset(2, 2);
                // X,Yの起点をずらした分だけ、縦幅、横幅を小さくします。
                dstGrScaled.Width -= 2;
                dstGrScaled.Height -= 2;
                g.DrawRectangle(Pens.Black, dstGrScaled.X, dstGrScaled.Y, dstGrScaled.Width, dstGrScaled.Height);
                //
                //
                dstGrScaled.Offset(-1, -1);// 元の位置に戻します。
                dstGrScaled.Width += 2;// 元のサイズに戻します。
                dstGrScaled.Height += 2;

                // 格子:横線
                {
                    float h2 = infoDisplay.MemorySprite.HeightcellResult * scale;

                    for (int row = 1; row < infoDisplay.MemorySprite.CountrowResult; row++)
                    {
                        g.DrawLine(infoDisplay.GridPen,//Pens.Black,
                            dstGrScaled.X + borderWidth,
                            (float)row * h2 + dstGrScaled.Y,
                            dstGrScaled.Width + dstGrScaled.X - borderWidth - 1,
                            (float)row * h2 + dstGrScaled.Y
                            );
                    }
                }

                // 格子:影:縦線
                {
                    float w2 = infoDisplay.MemorySprite.WidthcellResult * scale;

                    for (int column = 1; column < infoDisplay.MemorySprite.CountcolumnResult; column++)
                    {
                        g.DrawLine(infoDisplay.GridPen,//Pens.Black,
                            (float)column * w2 + dstGrScaled.X,
                            dstGrScaled.Y + borderWidth - 1,//上辺の枠と隙間を空けないように-1で調整。
                            (float)column * w2 + dstGrScaled.X,
                            dstGrScaled.Height + dstGrScaled.Y - borderWidth - 1
                            );
                    }
                }

                //
                // 枠線:緑
                //
                // 上辺、左辺の 0、0 と、
                // 右辺、下辺の -2、 -2 に線を引きます。
                //
                // 右辺、下辺が 0、0 だと画像外、
                // 右辺、下辺が -1、-1 だと影線の位置になります。
                dstGrScaled.Width -= 2;
                dstGrScaled.Height -= 2;
                g.DrawRectangle(Pens.Green, dstGrScaled.X, dstGrScaled.Y, dstGrScaled.Width, dstGrScaled.Height);
            }

            // 部品番号の描画
            if (partnumberconf.Visibled)
            {
                //
                // 数字は桁が多くなると横幅が伸びます。「0」「32」「105」
                // 特例で1桁は2桁扱いとして、「横幅÷桁数」が目安です。
                //

                // 最終部品番号
                int numberLast = (int)(infoDisplay.MemorySprite.CountrowResult * infoDisplay.MemorySprite.CountcolumnResult - 1) + partnumberconf.FirstIndex;
                // 最終部品番号の桁数
                int digit = numberLast.ToString().Length;
                if(1==digit)
                {
                    digit = 2;//特例で1桁は2桁扱いとします。
                }
                float fontPtScaled = scale * memorySprite.WidthcellResult / digit;

                //partnumberconf.Font = new Font("MS ゴシック", fontPt);
                partnumberconf.Font = new Font("メイリオ", fontPtScaled);

                for (int row = 0; row < infoDisplay.MemorySprite.CountrowResult; row++)
                {
                    for (int column = 0; column < infoDisplay.MemorySprite.CountcolumnResult; column++)
                    {
                        int number = (int)(row * infoDisplay.MemorySprite.CountcolumnResult + column) + partnumberconf.FirstIndex;
                        string text = number.ToString();
                        SizeF stringSizeScaled = g.MeasureString(text, partnumberconf.Font);

                        g.DrawString(text, partnumberconf.Font, partnumberconf.Brush,
                            new PointF(
                                scale * (column * memorySprite.WidthcellResult + memorySprite.WidthcellResult / 2) - stringSizeScaled.Width / 2 + dstGrScaled.X,
                                scale * (row * memorySprite.HeightcellResult + memorySprite.HeightcellResult / 2) - stringSizeScaled.Height / 2 + dstGrScaled.Y
                                ));
                    }
                }
            }

            // 情報欄の描画
            if (isVisible_Infodisplay)
            {
                int dy;
                if (isOnWindow)
                {
                    dy = 100;
                }
                else
                {
                    dy = 4;// 16;
                }
                infoDisplay.Paint(g, isOnWindow, dy, scale);
            }
        }
Example #18
0
File: SVG.cs Project: stuart2w/SAW
        public override void DrawImage(MemoryImage image, RectangleF destination, System.Drawing.Imaging.ImageAttributes attributes = null)
        {
            string ID = PrepareMemoryImage(image, image.GetHashCode(), RectangleF.Empty);

            SimpleImage(ID, image.Size, destination);
        }
Example #19
0
File: SVG.cs Project: stuart2w/SAW
        public override void DrawImage(MemoryImage image, RectangleF destination, RectangleF sourceRect, System.Drawing.Imaging.ImageAttributes attributes = null)
        {
            if (image.IsSVG && sourceRect.Location.IsEmpty && sourceRect.Size.Equals(image.Size.ToSizeF()))
            {             // sourceRect param was actually redundant as it specifies the entire thing
                          // this check done for efficiency, since if rendering the entire thing we can use SVG, whereas code below generates an entire new image each time
                DrawImage(image, destination, attributes);
                return;
            }
            string ID = PrepareMemoryImage(image, image.GetHashCode(), sourceRect);

            SimpleImage(ID, sourceRect.Size, destination);
        }
Example #20
0
        /// <summary>
        /// 加图片水印
        /// </summary>
        /// <param name="filename">文件名</param>
        /// <param name="watermarkFilename">水印文件名</param>
        /// <param name="watermarkStatus">图片水印位置:0=不使用 1=左上 2=中上 3=右上 4=左中 ... 9=右下</param>
        /// <param name="quality">是否是高质量图片 取值范围0--100</param>
        /// <param name="watermarkTransparency">图片水印透明度 取值范围1--10 (10为不透明)</param>

        public static void AddImageSignPic(string Path, string filename, string watermarkFilename, int watermarkStatus, int quality, int watermarkTransparency)
        {
            System.Drawing.Image    img = System.Drawing.Image.FromFile(Path);
            System.Drawing.Graphics g   = System.Drawing.Graphics.FromImage(img);

            //设置高质量插值法
            //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            //设置高质量,低速度呈现平滑程度
            //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            System.Drawing.Image watermark = new System.Drawing.Bitmap(watermarkFilename);

            if (watermark.Height >= img.Height || watermark.Width >= img.Width)
            {
                return;
            }

            System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
            System.Drawing.Imaging.ColorMap        colorMap        = new System.Drawing.Imaging.ColorMap();

            colorMap.OldColor = System.Drawing.Color.FromArgb(255, 0, 255, 0);
            colorMap.NewColor = System.Drawing.Color.FromArgb(0, 0, 0, 0);
            System.Drawing.Imaging.ColorMap[] remapTable = { colorMap };

            imageAttributes.SetRemapTable(remapTable, System.Drawing.Imaging.ColorAdjustType.Bitmap);

            float transparency = 0.5F;

            if (watermarkTransparency >= 1 && watermarkTransparency <= 10)
            {
                transparency = (watermarkTransparency / 10.0F);
            }

            float[][] colorMatrixElements =
            {
                new float[] { 1.0f, 0.0f, 0.0f,         0.0f, 0.0f },
                new float[] { 0.0f, 1.0f, 0.0f,         0.0f, 0.0f },
                new float[] { 0.0f, 0.0f, 1.0f,         0.0f, 0.0f },
                new float[] { 0.0f, 0.0f, 0.0f, transparency, 0.0f },
                new float[] { 0.0f, 0.0f, 0.0f,         0.0f, 1.0f }
            };

            System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);

            imageAttributes.SetColorMatrix(colorMatrix, System.Drawing.Imaging.ColorMatrixFlag.Default, System.Drawing.Imaging.ColorAdjustType.Bitmap);

            int xpos = 0;
            int ypos = 0;

            switch (watermarkStatus)
            {
            case 1:
                xpos = (int)(img.Width * (float).01);
                ypos = (int)(img.Height * (float).01);
                break;

            case 2:
                xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
                ypos = (int)(img.Height * (float).01);
                break;

            case 3:
                xpos = (int)((img.Width * (float).99) - (watermark.Width));
                ypos = (int)(img.Height * (float).01);
                break;

            case 4:
                xpos = (int)(img.Width * (float).01);
                ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
                break;

            case 5:
                xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
                ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
                break;

            case 6:
                xpos = (int)((img.Width * (float).99) - (watermark.Width));
                ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
                break;

            case 7:
                xpos = (int)(img.Width * (float).01);
                ypos = (int)((img.Height * (float).99) - watermark.Height);
                break;

            case 8:
                xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
                ypos = (int)((img.Height * (float).99) - watermark.Height);
                break;

            case 9:
                xpos = (int)((img.Width * (float).99) - (watermark.Width));
                ypos = (int)((img.Height * (float).99) - watermark.Height);
                break;
            }

            g.DrawImage(watermark, new System.Drawing.Rectangle(xpos, ypos, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, System.Drawing.GraphicsUnit.Pixel, imageAttributes);

            System.Drawing.Imaging.ImageCodecInfo[] codecs = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
            System.Drawing.Imaging.ImageCodecInfo   ici    = null;
            foreach (System.Drawing.Imaging.ImageCodecInfo codec in codecs)
            {
                //if (codec.MimeType.IndexOf("jpeg") > -1)
                if (codec.MimeType.Contains("jpeg"))
                {
                    ici = codec;
                }
            }
            System.Drawing.Imaging.EncoderParameters encoderParams = new System.Drawing.Imaging.EncoderParameters();
            long[] qualityParam = new long[1];
            if (quality < 0 || quality > 100)
            {
                quality = 80;
            }
            qualityParam[0] = quality;

            System.Drawing.Imaging.EncoderParameter encoderParam = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityParam);
            encoderParams.Param[0] = encoderParam;

            if (ici != null)
            {
                img.Save(filename, ici, encoderParams);
            }
            else
            {
                img.Save(filename);
            }

            g.Dispose();
            img.Dispose();
            watermark.Dispose();
            imageAttributes.Dispose();
        }
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (this.Items.Count <= 0)
            {
                return;
            }
            if (e.Index < 0)
            {
                return;
            }
            try
            {
                System.Drawing.Design.ToolboxItem tbi = Items[e.Index] as System.Drawing.Design.ToolboxItem;
                System.Drawing.Rectangle          rc  = new System.Drawing.Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
                if (e.Index == nIndexMouseOn)
                {
                    e.Graphics.FillRectangle(m_brushBK, e.Bounds);
                    if ((e.State & DrawItemState.Selected) != 0)
                    {
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                    }
                    else
                    {
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                        e.Graphics.DrawLine(m_penWhite, e.Bounds.X, e.Bounds.Y, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                        e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                    }
                }
                else if ((e.State & DrawItemState.Selected) != 0)
                {
                    e.Graphics.FillRectangle(System.Drawing.Brushes.AntiqueWhite, e.Bounds);

                    e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                    e.Graphics.DrawLine(m_penDarkGray, e.Bounds.X, e.Bounds.Y, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                    e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1);
                    e.Graphics.DrawLine(m_penWhite, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y + e.Bounds.Height - 1, e.Bounds.X + e.Bounds.Width - 1, e.Bounds.Y);
                }
                else
                {
                    e.Graphics.FillRectangle(new LinearGradientBrush(this.Bounds, Color.White, Color.LightBlue, 0F), e.Bounds);
                }
                //draw icon
                // Create an ImageAttributes object and set the color key.
                System.Drawing.Color lowerColor = System.Drawing.Color.FromArgb(255, 255, 255);
                System.Drawing.Color upperColor = System.Drawing.Color.FromArgb(255, 255, 255);
                System.Drawing.Imaging.ImageAttributes imageAttr = new System.Drawing.Imaging.ImageAttributes();
                imageAttr.SetColorKey(lowerColor,
                                      upperColor,
                                      System.Drawing.Imaging.ColorAdjustType.Default);

                rc.X      += 2;
                rc.Width   = nIconSize;
                rc.Y       = rc.Top + 1;
                rc.Height -= 2;
                e.Graphics.DrawImage(tbi.Bitmap,                        // Image
                                     rc,                                // Dest. rect.
                                     0,                                 // srcX
                                     0,                                 // srcY
                                     tbi.Bitmap.Width,                  // srcWidth
                                     tbi.Bitmap.Height,                 // srcHeight
                                     System.Drawing.GraphicsUnit.Pixel, // srcUnit
                                     imageAttr);                        // ImageAttributes
                //draw name
                rc.X     = rc.Width + 3;
                rc.Width = e.Bounds.Width - rc.X - 1;
                rc.Y     = rc.Top + nDrawTop;
                if (rc.Width > 0)
                {
                    e.Graphics.DrawString(tbi.DisplayName, m_font, System.Drawing.Brushes.Black, rc);
                }
            }
            catch
            {
            }
        }
Example #22
0
        private void CaptureScaledScreen(object state)
        {
            try
            {
                var count = Interlocked.Increment(ref executionCount);

                var size = new System.Drawing.Size((int)System.Windows.SystemParameters.WorkArea.Width, (int)System.Windows.SystemParameters.WorkArea.Height);



                using (var screenBmp = new Bitmap(size.Width, size.Height))
                {
                    var destRect  = new Rectangle(0, 0, this.width, this.height);
                    var destImage = new Bitmap(this.width, this.height);

                    using (Graphics screenGraphics = Graphics.FromImage(screenBmp),
                           destGraphics = Graphics.FromImage(destImage)
                           )
                    {
                        screenGraphics.CopyFromScreen(new System.Drawing.Point(0, 0), new System.Drawing.Point(0, 0), size);

                        Bitmap32 bm32 = new Bitmap32(screenBmp);
                        bm32.LockBitmap();
                        Rectangle src_rect = Bitmap32.ImageBounds(bm32);
                        bm32.UnlockBitmap();



                        // Copy the non-white area.
                        int    wid = src_rect.Width;
                        int    hgt = src_rect.Height;
                        Bitmap bm  = new Bitmap(wid, hgt);


                        using (Graphics gr = Graphics.FromImage(bm))
                        {
                            gr.Clear(Color.White);
                            Rectangle dest_rect = new Rectangle(
                                0, 0, src_rect.Width, src_rect.Height);
                            gr.DrawImage(screenBmp, dest_rect, src_rect, GraphicsUnit.Pixel);
                        }


                        destGraphics.CompositingMode   = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                        destGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bicubic;
                        //destGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                        using (var wrapMode = new System.Drawing.Imaging.ImageAttributes())
                        {
                            wrapMode.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
                            destGraphics.DrawImage(bm, destRect, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel, wrapMode);
                        }


                        //destImage.Save("test.png");
                    }


                    this.ExtractColors(destImage);
                }
            }
            catch (Exception)
            {
            }
        }
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Drawing.Imaging.ImageAttributes imageAttributes1 = new System.Drawing.Imaging.ImageAttributes();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			this.soundFieldControl1 = new Palaso.Media.SoundFieldControl();
			this.shortSoundFieldControl1 = new Palaso.Media.ShortSoundFieldControl();
			this.shortSoundFieldControl2 = new Palaso.Media.ShortSoundFieldControl();
			this.bitmapButton1 = new BitmapButton();
			this.SuspendLayout();
			//
			// soundFieldControl1
			//
			this.soundFieldControl1.Location = new System.Drawing.Point(44, 21);
			this.soundFieldControl1.Name = "soundFieldControl1";
			this.soundFieldControl1.Path = null;
			this.soundFieldControl1.Size = new System.Drawing.Size(150, 34);
			this.soundFieldControl1.TabIndex = 0;
			//
			// shortSoundFieldControl1
			//
			this.shortSoundFieldControl1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.shortSoundFieldControl1.Location = new System.Drawing.Point(44, 92);
			this.shortSoundFieldControl1.Name = "shortSoundFieldControl1";
			this.shortSoundFieldControl1.Path = null;
			this.shortSoundFieldControl1.PlayOnly = false;
			this.shortSoundFieldControl1.Size = new System.Drawing.Size(328, 22);
			this.shortSoundFieldControl1.TabIndex = 1;
			this.shortSoundFieldControl1.Load += new System.EventHandler(this.shortSoundFieldControl1_Load);
			//
			// shortSoundFieldControl2
			//
			this.shortSoundFieldControl2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.shortSoundFieldControl2.Location = new System.Drawing.Point(44, 150);
			this.shortSoundFieldControl2.Name = "shortSoundFieldControl2";
			this.shortSoundFieldControl2.Path = null;
			this.shortSoundFieldControl2.PlayOnly = false;
			this.shortSoundFieldControl2.Size = new System.Drawing.Size(328, 25);
			this.shortSoundFieldControl2.TabIndex = 2;
			this.shortSoundFieldControl2.Load += new System.EventHandler(this.shortSoundFieldControl2_Load);
			//
			// bitmapButton1
			//
			this.bitmapButton1.BackColor = System.Drawing.Color.Transparent;
			this.bitmapButton1.BorderColor = System.Drawing.Color.DarkBlue;
			this.bitmapButton1.FlatAppearance.BorderSize = 0;
			this.bitmapButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.bitmapButton1.FocusRectangleEnabled = true;
			this.bitmapButton1.Image = null;
			this.bitmapButton1.ImageAttributes = imageAttributes1;
			this.bitmapButton1.ImageBorderColor = System.Drawing.Color.Transparent;
			this.bitmapButton1.ImageBorderEnabled = false;
			this.bitmapButton1.ImageDropShadow = false;
			this.bitmapButton1.ImageFocused = null;
			this.bitmapButton1.ImageInactive = null;
			this.bitmapButton1.ImageMouseOver = null;
			this.bitmapButton1.ImageNormal = global::Palaso.Media.Tests.Properties.Resources.MP3_PLAYER;
			this.bitmapButton1.ImagePressed = null;
			this.bitmapButton1.InnerBorderColor = System.Drawing.Color.Transparent;
			this.bitmapButton1.InnerBorderColor_Focus = System.Drawing.Color.LightBlue;
			this.bitmapButton1.InnerBorderColor_MouseOver = System.Drawing.Color.Gold;
			this.bitmapButton1.Location = new System.Drawing.Point(326, 21);
			this.bitmapButton1.Name = "bitmapButton1";
			this.bitmapButton1.OffsetPressedContent = true;
			this.bitmapButton1.Size = new System.Drawing.Size(37, 34);
			this.bitmapButton1.StretchImage = false;
			this.bitmapButton1.TabIndex = 3;
			this.bitmapButton1.TextDropShadow = true;
			this.bitmapButton1.UseVisualStyleBackColor = false;
			//
			// Form1
			//
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.ClientSize = new System.Drawing.Size(461, 264);
			this.Controls.Add(this.bitmapButton1);
			this.Controls.Add(this.shortSoundFieldControl2);
			this.Controls.Add(this.shortSoundFieldControl1);
			this.Controls.Add(this.soundFieldControl1);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Form1";
			this.Text = "Palaso.Media Sample App";
			this.ResumeLayout(false);

		}
Example #24
0
		protected override void PaintControlBackground(ItemPaintArgs pa)
		{
            bool mouseOver = m_MouseOver;
            bool fade = m_FadeImageState!=null;

            if (fade)
                mouseOver = false;
            GraphicsPath insideClip = null;
            ElementStyle backStyle = GetBackgroundStyle();
            bool disposeBackStyle = fade;
            try
            {
                if (backStyle != null)
                {
                    Rectangle r = GetBackgroundRectangle();
                    pa.Graphics.SetClip(r, CombineMode.Replace);
                    ElementStyle mouseOverStyle = GetBackgroundMouseOverStyle();
                    if (mouseOver && backStyle != null && mouseOverStyle != null && mouseOverStyle.Custom)
                    {
                        backStyle = backStyle.Copy();
                        disposeBackStyle = true;
                        backStyle.ApplyStyle(mouseOverStyle);
                    }

                    ElementStyleDisplayInfo displayInfo = new ElementStyleDisplayInfo(backStyle, pa.Graphics, r, EffectiveStyle == eDotNetBarStyle.Office2007);
                    ElementStyleDisplay.Paint(displayInfo);
                    pa.Graphics.ResetClip();
                    displayInfo.Bounds = GetBackgroundRectangle();
                    // Adjust so the title shows over the inside light border line
                    displayInfo.Bounds.X--;
                    displayInfo.Bounds.Width++;
                    insideClip = ElementStyleDisplay.GetInsideClip(displayInfo);
                    displayInfo.Bounds.X++;
                    displayInfo.Bounds.Width--;
                }

                if (insideClip != null)
                    pa.Graphics.SetClip(insideClip, CombineMode.Replace);

                m_DialogLauncherRect = Rectangle.Empty;

                if (m_TitleVisible && !this.OverflowState)
                {
                    ElementStyle style = GetTitleStyle();
                    ElementStyle styleMouseOver = GetTitleMouseOverStyle();
                    if (mouseOver && style != null && styleMouseOver != null && styleMouseOver.Custom)
                    {
                        style = style.Copy();
                        style.ApplyStyle(styleMouseOver);
                    }

                    if (style != null)
                    {
                        SimpleNodeDisplayInfo info = new SimpleNodeDisplayInfo(style, pa.Graphics, m_TitleElement, this.Font, (this.RightToLeft == RightToLeft.Yes));
                        if (m_DialogLauncherVisible)
                        {
                            if (m_DialogLauncherButton == null)
                            {
                                Rectangle textRect = m_TitleElement.TextBounds;
                                textRect.Width -= m_TitleRectangle.Height;
                                if (this.RightToLeft == RightToLeft.Yes)
                                    textRect.X += m_TitleRectangle.Height;
                                info.TextBounds = textRect;
                            }
                            else
                            {
                                if (m_MouseOverDialogLauncher && m_DialogLauncherMouseOverButton != null)
                                    m_TitleElement.Image = m_DialogLauncherMouseOverButton;
                                else
                                    m_TitleElement.Image = m_DialogLauncherButton;
                            }
                        }

                        SimpleNodeDisplay.Paint(info);

                        if (m_DialogLauncherVisible && m_TitleElement.Image == null)
                            PaintDialogLauncher(pa);
                        else
                            m_DialogLauncherRect = m_TitleElement.ImageBounds;
                    }
                }

                pa.Graphics.ResetClip();

                m_FadeImageLock.AcquireReaderLock(-1);
                try
                {
                    if (m_FadeImageState != null)
                    {
                        Graphics g = pa.Graphics;
                        Rectangle r = new Rectangle(0, 0, this.Width, this.Height);

                        System.Drawing.Imaging.ColorMatrix matrix1 = new System.Drawing.Imaging.ColorMatrix();
                        matrix1[3, 3] = (float)((float)m_FadeAlpha / 255);
                        using (System.Drawing.Imaging.ImageAttributes imageAtt = new System.Drawing.Imaging.ImageAttributes())
                        {
                            imageAtt.SetColorMatrix(matrix1);

                            g.DrawImage(m_FadeImageState, r, 0, 0, r.Width, r.Height, GraphicsUnit.Pixel, imageAtt);
                        }
                        return;
                    }
                }
                finally
                {
                    m_FadeImageLock.ReleaseReaderLock();
                }
            }
            finally
            {
                if (insideClip != null) insideClip.Dispose();
                if (disposeBackStyle && backStyle != null) backStyle.Dispose();
            }
		}
Example #25
0
File: SVG.cs Project: stuart2w/SAW
        public override void DrawImage(MemoryImage image, PointF[] destinationPoints, RectangleF sourceRect, System.Drawing.Imaging.ImageAttributes attributes = null)
        {
            var ID = PrepareMemoryImage(image, image.GetHashCode(), sourceRect);

            ComplexImage(ID, sourceRect, destinationPoints);
        }
        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
			this.components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PageListView));
			System.Drawing.Imaging.ImageAttributes imageAttributes2 = new System.Drawing.Imaging.ImageAttributes();
			this._pageThumbnails = new System.Windows.Forms.ImageList(this.components);
			this._pagesLabel = new System.Windows.Forms.Label();
			this._L10NSharpExtender = new L10NSharp.UI.L10NSharpExtender(this.components);
			this._addPageButton = new SIL.Windows.Forms.Widgets.BitmapButton();
			this._pageControlsPanel = new System.Windows.Forms.Panel();
			this._thumbNailList = new Bloom.Edit.WebThumbNailList();
			((System.ComponentModel.ISupportInitialize)(this._L10NSharpExtender)).BeginInit();
			this._pageControlsPanel.SuspendLayout();
			this.SuspendLayout();
			// 
			// _pageThumbnails
			// 
			this._pageThumbnails.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_pageThumbnails.ImageStream")));
			this._pageThumbnails.TransparentColor = System.Drawing.Color.Transparent;
			this._pageThumbnails.Images.SetKeyName(0, "x-office-document.png");
			// 
			// _pagesLabel
			// 
			this._pagesLabel.AutoSize = true;
			this._pagesLabel.BackColor = System.Drawing.Color.Transparent;
			this._pagesLabel.Dock = System.Windows.Forms.DockStyle.Top;
			this._pagesLabel.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
			this._pagesLabel.ForeColor = System.Drawing.Color.WhiteSmoke;
			this._L10NSharpExtender.SetLocalizableToolTip(this._pagesLabel, null);
			this._L10NSharpExtender.SetLocalizationComment(this._pagesLabel, null);
			this._L10NSharpExtender.SetLocalizingId(this._pagesLabel, "EditTab.PageList.Heading");
			this._pagesLabel.Location = new System.Drawing.Point(0, 0);
			this._pagesLabel.Name = "_pagesLabel";
			this._pagesLabel.Size = new System.Drawing.Size(50, 20);
			this._pagesLabel.TabIndex = 1;
			this._pagesLabel.Text = "Pages";
			// 
			// _L10NSharpExtender
			// 
			this._L10NSharpExtender.LocalizationManagerId = "Bloom";
			this._L10NSharpExtender.PrefixForNewItems = null;
			// 
			// _addPageButton
			// 
			this._addPageButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
			this._addPageButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
			this._addPageButton.BorderColor = System.Drawing.Color.Transparent;
			this._addPageButton.DisabledTextColor = System.Drawing.Color.FromArgb(((int)(((byte)(87)))), ((int)(((byte)(87)))), ((int)(((byte)(87)))));
			this._addPageButton.FlatAppearance.BorderSize = 0;
			this._addPageButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this._addPageButton.FocusRectangleEnabled = true;
			this._addPageButton.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
			this._addPageButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(129)))), ((int)(((byte)(146)))));
			this._addPageButton.Image = null;
			this._addPageButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
			this._addPageButton.ImageAttributes = imageAttributes2;
			this._addPageButton.ImageBorderColor = System.Drawing.Color.Transparent;
			this._addPageButton.ImageBorderEnabled = false;
			this._addPageButton.ImageDropShadow = false;
			this._addPageButton.ImageFocused = null;
			this._addPageButton.ImageInactive = null;
			this._addPageButton.ImageMouseOver = null;
			this._addPageButton.ImageNormal = global::Bloom.Properties.Resources.AddPageButton;
			this._addPageButton.ImagePressed = null;
			this._addPageButton.InnerBorderColor = System.Drawing.Color.Transparent;
			this._addPageButton.InnerBorderColor_Focus = System.Drawing.Color.LightBlue;
			this._addPageButton.InnerBorderColor_MouseOver = System.Drawing.Color.Gold;
			this._L10NSharpExtender.SetLocalizableToolTip(this._addPageButton, null);
			this._L10NSharpExtender.SetLocalizationComment(this._addPageButton, "This is for the button that LAUNCHES the dialog, not the \"Add this page\" button that is IN the dialog.");
			this._L10NSharpExtender.SetLocalizingId(this._addPageButton, "EditTab.AddPageDialog.AddPageButton");
			this._addPageButton.Location = new System.Drawing.Point(23, 17);
			this._addPageButton.Name = "_addPageButton";
			this._addPageButton.OffsetPressedContent = true;
			this._addPageButton.Size = new System.Drawing.Size(68, 60);
			this._addPageButton.StretchImage = false;
			this._addPageButton.TabIndex = 10;
			this._addPageButton.Text = "Add Page";
			this._addPageButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			this._addPageButton.TextDropShadow = false;
			this._addPageButton.UseVisualStyleBackColor = false;
			this._addPageButton.Click += new System.EventHandler(this._addPageButton_Click);
			// 
			// _pageControlsPanel
			// 
			this._pageControlsPanel.Controls.Add(this._addPageButton);
			this._pageControlsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
			this._pageControlsPanel.Location = new System.Drawing.Point(0, 199);
			this._pageControlsPanel.Name = "_pageControlsPanel";
			this._pageControlsPanel.Size = new System.Drawing.Size(137, 80);
			this._pageControlsPanel.TabIndex = 3;
			// 
			// _thumbNailList
			// 
			this._thumbNailList.BackColor = System.Drawing.SystemColors.Control;
			this._thumbNailList.Dock = System.Windows.Forms.DockStyle.Fill;
			this._thumbNailList.ForeColor = System.Drawing.SystemColors.WindowText;
			this._thumbNailList.Isolator = null;
			this._L10NSharpExtender.SetLocalizableToolTip(this._thumbNailList, null);
			this._L10NSharpExtender.SetLocalizationComment(this._thumbNailList, null);
			this._L10NSharpExtender.SetLocalizingId(this._thumbNailList, "WebThumbNailList");
			this._thumbNailList.Location = new System.Drawing.Point(0, 20);
			this._thumbNailList.Name = "_thumbNailList";
			this._thumbNailList.PreferPageNumbers = false;
			this._thumbNailList.RelocatePageEvent = null;
			this._thumbNailList.Size = new System.Drawing.Size(137, 179);
			this._thumbNailList.TabIndex = 4;
			// 
			// PageListView
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
			this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
			this.Controls.Add(this._thumbNailList);
			this.Controls.Add(this._pageControlsPanel);
			this.Controls.Add(this._pagesLabel);
			this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
			this._L10NSharpExtender.SetLocalizableToolTip(this, null);
			this._L10NSharpExtender.SetLocalizationComment(this, null);
			this._L10NSharpExtender.SetLocalizingId(this, "EditTab.PageList");
			this.Name = "PageListView";
			this.Size = new System.Drawing.Size(137, 279);
			this.BackColorChanged += new System.EventHandler(this.PageListView_BackColorChanged);
			((System.ComponentModel.ISupportInitialize)(this._L10NSharpExtender)).EndInit();
			this._pageControlsPanel.ResumeLayout(false);
			this.ResumeLayout(false);
			this.PerformLayout();

        }
Example #27
0
 private void DrawForegroundFromButton(PaintEventArgs pevent)
 {
     if (_imageButton == null)
     {
         _imageButton        = new Button();
         _imageButton.Parent = new TransparentControl();
         _imageButton.SuspendLayout();
         _imageButton.BackColor = Color.Transparent;
         _imageButton.FlatAppearance.BorderSize = 0;
         _imageButton.FlatStyle = FlatStyle.Flat;
     }
     else
     {
         _imageButton.SuspendLayout();
     }
     _imageButton.AutoEllipsis = AutoEllipsis;
     if (Enabled)
     {
         _imageButton.ForeColor = ForeColor;
     }
     else
     {
         _imageButton.ForeColor = Color.FromArgb((3 * ForeColor.R + _backColor.R) >> 2,
                                                 (3 * ForeColor.G + _backColor.G) >> 2,
                                                 (3 * ForeColor.B + _backColor.B) >> 2);
     }
     _imageButton.Font        = Font;
     _imageButton.RightToLeft = RightToLeft;
     _imageButton.Image       = Image;
     if (Image != null && !Enabled)
     {
         Size      size           = Image.Size;
         float[][] newColorMatrix = new float[5][];
         newColorMatrix[0] = new float[] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f };
         newColorMatrix[1] = new float[] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f };
         newColorMatrix[2] = new float[] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f };
         float[] arr = new float[5];
         arr[3]            = 1f;
         newColorMatrix[3] = arr;
         newColorMatrix[4] = new float[] { 0.38f, 0.38f, 0.38f, 0f, 1f };
         System.Drawing.Imaging.ColorMatrix     matrix            = new System.Drawing.Imaging.ColorMatrix(newColorMatrix);
         System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes();
         disabledImageAttr.ClearColorKey();
         disabledImageAttr.SetColorMatrix(matrix);
         _imageButton.Image = new Bitmap(Image.Width, Image.Height);
         using (Graphics gr = Graphics.FromImage(_imageButton.Image))
         {
             gr.DrawImage(Image, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, disabledImageAttr);
         }
     }
     _imageButton.ImageAlign                 = ImageAlign;
     _imageButton.ImageIndex                 = ImageIndex;
     _imageButton.ImageKey                   = ImageKey;
     _imageButton.ImageList                  = ImageList;
     _imageButton.Padding                    = Padding;
     _imageButton.Size                       = Size;
     _imageButton.Text                       = Text;
     _imageButton.TextAlign                  = TextAlign;
     _imageButton.TextImageRelation          = TextImageRelation;
     _imageButton.UseCompatibleTextRendering = UseCompatibleTextRendering;
     _imageButton.UseMnemonic                = UseMnemonic;
     _imageButton.ResumeLayout();
     InvokePaint(_imageButton, pevent);
     if (_imageButton.Image != null && _imageButton.Image != Image)
     {
         _imageButton.Image.Dispose();
         _imageButton.Image = null;
     }
 }
Example #28
0
        private static System.Drawing.Bitmap MakeGrayscale3(System.Drawing.Bitmap original)
        {
            //create a blank bitmap the same size as original
            System.Drawing.Bitmap newBitmap = new System.Drawing.Bitmap(original.Width, original.Height);

            //get a graphics object from the new image
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(newBitmap);

            //create the grayscale ColorMatrix
            System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(
                       new float[][]
              {
                 new float[] {.3f, .3f, .3f, 0, 0},
                 new float[] {.59f, .59f, .59f, 0, 0},
                 new float[] {.11f, .11f, .11f, 0, 0},
                 new float[] {0, 0, 0, 1, 0},
                 new float[] {0, 0, 0, 0, 1}
              });

            //create some image attributes
            System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes();

            //set the color matrix attribute
            attributes.SetColorMatrix(colorMatrix);

            //draw the original image on the new image
            //using the grayscale color matrix
            g.DrawImage(original, new System.Drawing.Rectangle(0, 0, original.Width, original.Height),
               0, 0, original.Width, original.Height, System.Drawing.GraphicsUnit.Pixel, attributes);

            //dispose the Graphics object
            g.Dispose();
            return newBitmap;
        }
Example #29
0
        /// <summary>
        /// Draws the Chevron Image at the specified location.
        /// </summary>
        /// <param name="graphics">The Graphics to draw on.</param>
        /// <param name="imgChevron">Chevron image to draw.</param>
        /// <param name="imageRectangle">A Rectangle structure that specifies the bounds of the linear gradient.</param>
        /// <param name="foreColorImage">the foreground color of this image</param>
        /// <param name="bDrawBackground">Gets or sets a value indicating whether the background of the close and expand images is drawn</param>
        protected static void DrawChevron(Graphics graphics, Image imgChevron, Rectangle imageRectangle, Color foreColorImage, bool bDrawBackground, int chevronPositionY)
        {
            if (graphics == null)
            {
                throw new ArgumentException(
                    string.Format(
                    System.Globalization.CultureInfo.CurrentUICulture,
                    Resources.IDS_ArgumentException,
                    typeof(Graphics).Name));
            }
            if (imgChevron == null)
            {
                throw new ArgumentException(
                    string.Format(
                    System.Globalization.CultureInfo.CurrentUICulture,
                    Resources.IDS_ArgumentException,
                    typeof(Image).Name));
            }

            int chevronPositionX = imageRectangle.Left;

            Rectangle rectangleChevron = new Rectangle(
                chevronPositionX + (imageRectangle.Width / 3) - 2,
                chevronPositionY + 3,
                9,
                9);

            using (System.Drawing.Imaging.ImageAttributes imageAttribute = new System.Drawing.Imaging.ImageAttributes())
            {
                imageAttribute.SetColorKey(Color.Magenta, Color.Magenta);
                System.Drawing.Imaging.ColorMap colorMap = new System.Drawing.Imaging.ColorMap();
                colorMap.OldColor = Color.FromArgb(0, 60, 166);
                colorMap.NewColor = foreColorImage;
                imageAttribute.SetRemapTable(new System.Drawing.Imaging.ColorMap[] { colorMap });

                if (bDrawBackground == true)
                {
                    using (LinearGradientBrush brushInnerCircle = new LinearGradientBrush(
                        new Rectangle(chevronPositionX, chevronPositionY, 16, 16),
                        Color.FromArgb(128, Color.White),
                        Color.FromArgb(0, Color.White),
                        LinearGradientMode.Vertical))
                    {
                        graphics.FillPath(brushInnerCircle, GetPath(new Rectangle(chevronPositionX, chevronPositionY, 15, 15), 5));
                    }
                }
                graphics.DrawImage(imgChevron, rectangleChevron, 0, 0, 9, 9, GraphicsUnit.Pixel, imageAttribute);
            }
        }
Example #30
0
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint(e);

			Rectangle colorBoxOuter = new Rectangle(
				this.ClientRectangle.X + this.pickerSize,
				this.ClientRectangle.Y + this.pickerSize,
				this.ClientRectangle.Width - this.pickerSize * 2 - 1,
				this.ClientRectangle.Height - this.pickerSize * 2 - 1);
			Rectangle colorBoxInner = new Rectangle(
				colorBoxOuter.X + 1,
				colorBoxOuter.Y + 1,
				colorBoxOuter.Width - 2,
				colorBoxOuter.Height - 2);
			Rectangle colorArea = this.ColorAreaRectangle;
			int pickerVisualPos = colorArea.Y + (int)Math.Round((1.0f - this.pickerPos) * colorArea.Height);

			if (this.min.A < 255 || this.max.A < 255)
				e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, Color.LightGray, Color.Gray), colorArea);

			System.Drawing.Imaging.ImageAttributes colorAreaImageAttr = new System.Drawing.Imaging.ImageAttributes();
			colorAreaImageAttr.SetWrapMode(WrapMode.TileFlipXY);
			e.Graphics.DrawImage(this.srcImage, colorArea, 0, 0, this.srcImage.Width, this.srcImage.Height - 1, GraphicsUnit.Pixel, colorAreaImageAttr);

			e.Graphics.DrawRectangle(SystemPens.ControlDark, colorBoxOuter);
			e.Graphics.DrawRectangle(SystemPens.ControlLightLight, colorBoxInner);

			e.Graphics.DrawLines(this.Enabled ? Pens.Black : SystemPens.ControlDark, new Point[] {
				new Point(0, pickerVisualPos - this.pickerSize),
				new Point(this.pickerSize, pickerVisualPos),
				new Point(0, pickerVisualPos + this.pickerSize),
				new Point(0, pickerVisualPos - this.pickerSize)});
			e.Graphics.DrawLines(this.Enabled ? Pens.Black : SystemPens.ControlDark, new Point[] {
				new Point(colorBoxOuter.Right + this.pickerSize, pickerVisualPos - this.pickerSize),
				new Point(colorBoxOuter.Right, pickerVisualPos),
				new Point(colorBoxOuter.Right + this.pickerSize, pickerVisualPos + this.pickerSize),
				new Point(colorBoxOuter.Right + this.pickerSize, pickerVisualPos - this.pickerSize)});
			
			if (this.innerPicker)
			{
				Pen innerPickerPen = this.valTemp.GetLuminance() > 0.5f ? Pens.Black : Pens.White;
				e.Graphics.DrawLine(innerPickerPen,
					new Point(colorArea.Left, pickerVisualPos),
					new Point(colorArea.Left + 2, pickerVisualPos));
				e.Graphics.DrawLine(innerPickerPen,
					new Point(colorArea.Right - 1, pickerVisualPos),
					new Point(colorArea.Right - 1 - 2, pickerVisualPos));
			}

			if (!this.Enabled)
			{
				e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(128, SystemColors.Control)), colorArea);
			}
		}
        // codigo sacado de https://code.msdn.microsoft.com/windowsdesktop/ColorMatrix-Image-Filters-f6ed20ae
        // el codigo se sacó de la pagina, pero se modificó para aplicarlo de mejor manera
        public static Bitmap Transform(Bitmap Img, string filter)
        {
            float[][] Values =
            {
                new float[] { 1, 0, 0, 0, 0 },
                new float[] { 0, 1, 0, 0, 0 },
                new float[] { 0, 0, 1, 0, 0 },
                new float[] { 0, 0, 0, 1, 0 },
                new float[] { 0, 0, 0, 0, 1 }
            };
            switch (filter)
            {
            case "sepia":
                float[][] sepiaValues =
                {
                    new float[] { .393f, .349f, .272f, 0, 0 },
                    new float[] { .769f, .686f, .534f, 0, 0 },
                    new float[] { .189f, .168f, .131f, 0, 0 },
                    new float[] {     0,     0,     0, 1, 0 },
                    new float[] {     0,     0,     0, 0, 1 }
                };
                Values = sepiaValues;

                break;

            case "greyscale":
                float[][] greyscaleValues =
                {
                    new float[] { .299f, .299f, .299f, 0, 0 },
                    new float[] { .587f, .587f, .587f, 0, 0 },
                    new float[] { .114f, .114f, .114f, 0, 0 },
                    new float[] {     0,     0,     0, 1, 0 },
                    new float[] {     0,     0,     0, 0, 1 }
                };
                Values = greyscaleValues;
                break;


            case "negative":
                float[][] negativeValues =
                {
                    new float[] { -1,  0,  0, 0, 0 },
                    new float[] {  0, -1,  0, 0, 0 },
                    new float[] {  0,  0, -1, 0, 0 },
                    new float[] {  0,  0,  0, 1, 0 },
                    new float[] {  1,  1,  1, 1, 1 }
                };
                Values = negativeValues;
                break;

            case "red":
                float[][] redValues =
                {
                    new float[] { 1.4f,    0,    0, 0, 0 },
                    new float[] {    0, 0.6f,    0, 0, 0 },
                    new float[] {    0,    0, 0.6f, 0, 0 },
                    new float[] {    0,    0,    0, 1, 0 },
                    new float[] {    0,    0,    0, 0, 1 }
                };
                Values = redValues;
                break;

            case "orange":
                float[][] orangeValues =
                {
                    new float[] { 1.7f,    0,    0, 0, 0 },
                    new float[] {    0, 0.8f,    0, 0, 0 },
                    new float[] {    0,    0, 0.2f, 0, 0 },
                    new float[] {    0,    0,    0, 1, 0 },
                    new float[] {    0,    0,    0, 0, 1 }
                };
                Values = orangeValues;
                break;

            case "yellow":
                float[][] yellowValues =
                {
                    new float[] { 1.5f,    0,    0, 0, 0 },
                    new float[] {    0, 1.1f,    0, 0, 0 },
                    new float[] {    0,    0, 0.2f, 0, 0 },
                    new float[] {    0,    0,    0, 1, 0 },
                    new float[] {    0,    0,    0, 0, 1 }
                };
                Values = yellowValues;
                break;

            case "green":
                float[][] greenValues =
                {
                    new float[] { 0.8f,  0,    0, 0, 0 },
                    new float[] {    0, 1f,    0, 0, 0 },
                    new float[] {    0,  0, 0.6f, 0, 0 },
                    new float[] {    0,  0,    0, 1, 0 },
                    new float[] {    0,  0,    0, 0, 1 }
                };
                Values = greenValues;
                break;

            case "lightblue":
                float[][] lbValues =
                {
                    new float[] { 0.8f,    0,    0, 0, 0 },
                    new float[] {    0, 0.8f,    0, 0, 0 },
                    new float[] {    0,    0, 1.9f, 0, 0 },
                    new float[] {    0,    0,    0, 1, 0 },
                    new float[] {    0,    0,    0, 0, 1 }
                };
                Values = lbValues;
                break;

            case "blue":
                float[][] blueValues =
                {
                    new float[] { 0.5f,    0,    0, 0, 0 },
                    new float[] {    0, 0.5f,    0, 0, 0 },
                    new float[] {    0,    0, 1.1f, 0, 0 },
                    new float[] {    0,    0,    0, 1, 0 },
                    new float[] {    0,    0,    0, 0, 1 }
                };
                Values = blueValues;
                break;

            case "purple":
                float[][] purpleValues =
                {
                    new float[] { 1.1f,    0,    0, 0, 0 },
                    new float[] {    0, 0.5f,    0, 0, 0 },
                    new float[] {    0,    0, 1.1f, 0, 0 },
                    new float[] {    0,    0,    0, 1, 0 },
                    new float[] {    0,    0,    0, 0, 1 }
                };
                Values = purpleValues;
                break;

            case "frozen":
                float[][] frozenValues =
                {
                    new float[] { .393f + 0.3f,        .349f,        .272f, 0, 0 },
                    new float[] {        .769f, .686f + 0.2f,        .534f, 0, 0 },
                    new float[] {        .189f,        .168f, .131f + 0.9f, 0, 0 },
                    new float[] {            0,            0,            0, 1, 0 },
                    new float[] {            0,            0,            0, 0, 1 }
                };
                Values = frozenValues;
                break;

            case "transparent":
                float[][] transparentValues =
                {
                    new float[] { 1, 0, 0,    0, 0 },
                    new float[] { 0, 1, 0,    0, 0 },
                    new float[] { 0, 0, 1,    0, 0 },
                    new float[] { 0, 0, 0, 0.2f, 0 },
                    new float[] { 0, 0, 0,    0, 1 }
                };
                Values = transparentValues;
                break;

            default:
                break;
            }

            System.Drawing.Imaging.ColorMatrix     Matrix = new System.Drawing.Imaging.ColorMatrix(Values);
            System.Drawing.Imaging.ImageAttributes IA     = new System.Drawing.Imaging.ImageAttributes();
            IA.SetColorMatrix(Matrix);
            Bitmap Effect = (Bitmap)Img.Clone();

            using (Graphics G = Graphics.FromImage(Effect))
            {
                G.DrawImage(Img, new Rectangle(0, 0, Effect.Width, Effect.Height), 0, 0, Effect.Width, Effect.Height, GraphicsUnit.Pixel, IA);
            }
            Img = Effect;
            return(Img);
        }
Example #32
0
        public virtual void Render(Graphics g, Rectangle bounds)
        {
            try
            {
                g.Clip = new Region(bounds);
                currentOffset = bounds;
                SolidBrush ForeBrush = new SolidBrush(ClientSettings.ForeColor);
                Rectangle textBounds;
                //Shrink the text area to accomidate avatars if appropriate
                if (ClientSettings.ShowAvatars)
                {
                    textBounds = new Rectangle(bounds.X + (ClientSettings.SmallArtSize + ClientSettings.Margin), bounds.Y, bounds.Width - (ClientSettings.SmallArtSize + (ClientSettings.Margin * 2)), bounds.Height);
                }
                else
                {
                    textBounds = new Rectangle(bounds.X + ClientSettings.Margin, bounds.Y, bounds.Width - (ClientSettings.Margin * 2), bounds.Height);
                }

                Rectangle InnerBounds = new Rectangle(bounds.Left, bounds.Top, bounds.Width, bounds.Height);
                InnerBounds.Offset(1, 1);
                InnerBounds.Width--; InnerBounds.Height--;

                if (m_selected)
                {
                    ForeBrush = new SolidBrush(ClientSettings.SelectedForeColor);
                    if (ClientSettings.SelectedBackColor != ClientSettings.SelectedBackGradColor)
                    {
                        try
                        {
                            Gradient.GradientFill.Fill(g, InnerBounds, ClientSettings.SelectedBackColor, ClientSettings.SelectedBackGradColor, Gradient.GradientFill.FillDirection.TopToBottom);
                        }
                        catch
                        {
                            using (Brush BackBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                            {
                                g.FillRectangle(BackBrush, InnerBounds);
                            }
                        }
                    }
                    else
                    {
                        using (Brush BackBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                        {
                            g.FillRectangle(BackBrush, InnerBounds);
                        }
                    }
                }
                else
                {
                    if (ClientSettings.BackColor != ClientSettings.BackGradColor)
                    {
                        try
                        {
                            Gradient.GradientFill.Fill(g, InnerBounds, ClientSettings.BackColor, ClientSettings.BackGradColor, Gradient.GradientFill.FillDirection.TopToBottom);
                        }
                        catch
                        {
                            using (Brush BackBrush = new SolidBrush(ClientSettings.BackColor))
                            {
                                g.FillRectangle(BackBrush, InnerBounds);
                            }
                        }
                    }
                    else
                    {
                        using (Brush BackBrush = new SolidBrush(ClientSettings.BackColor))
                        {
                            g.FillRectangle(BackBrush, InnerBounds);
                        }
                    }
                }


                Point ImageLocation = new Point(bounds.X + ClientSettings.Margin, bounds.Y + ClientSettings.Margin);

                //Add the timestamp if the settings call for it.
                if (ClientSettings.ShowExtra)
                {
                    Color SmallColor = ClientSettings.SmallTextColor;
                    if (this.Selected) { SmallColor = ClientSettings.SelectedSmallTextColor; }
                    using (Brush dateBrush = new SolidBrush(SmallColor))
                    {
                        g.DrawString(Tweet.TimeStamp, ClientSettings.SmallFont, dateBrush, bounds.Left + ClientSettings.Margin, ClientSettings.SmallArtSize + ClientSettings.Margin + bounds.Top, m_stringFormat);
                    }
                }

                //Get and draw the avatar area.
                if (ClientSettings.ShowAvatars)
                {
                    string artURL = Tweet.user.profile_image_url;
                    if (!ClientSettings.HighQualityAvatars)
                    {
                        artURL = Tweet.user.profile_image_url;
                    }
                    try
                    {
                        using (Image UserImage = PockeTwit.ThrottledArtGrabber.GetArt(artURL))
                        {
                            //g.DrawImage(UserImage, ImageLocation.X, ImageLocation.Y,);
                            g.DrawImage(UserImage, new Rectangle(ImageLocation.X, ImageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize), new Rectangle(0, 0, UserImage.Width, UserImage.Height), GraphicsUnit.Pixel);

                        }
                    }
                    catch(Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }

                    //Only occasionally is an item "starred", but we draw one on there if it is.
                    if (hasFavoriteStar)
                    {
                        System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
                        ia.SetColorKey(PockeTwit.ThrottledArtGrabber.FavoriteImage.GetPixel(0, 0), PockeTwit.ThrottledArtGrabber.FavoriteImage.GetPixel(0, 0));
                        g.DrawImage(PockeTwit.ThrottledArtGrabber.FavoriteImage,
                            new Rectangle(bounds.X + 5, bounds.Y + 5, 7, 7), 0, 0, 7, 7, GraphicsUnit.Pixel, ia);
                    }

                    //If it's a reply or direct message, overlay that on the avatar
                    if (Tweet.TypeofMessage == PockeTwit.Library.StatusTypes.Reply)
                    {
                        using (Brush sBrush = new SolidBrush(ClientSettings.SelectedForeColor))
                        {

                            Rectangle ImageRect = new Rectangle(ImageLocation.X, ImageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize);
                            Point sPoint = new Point(ImageRect.Right - 15, ImageRect.Top);

                            using (Brush bBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                            {
                                g.FillRectangle(bBrush, new Rectangle(ImageRect.Right - 15, ImageRect.Top, 15, 15));
                            }
                            g.DrawString("@", ClientSettings.TextFont, sBrush, new Rectangle(ImageRect.Right - 12, ImageRect.Top - 2, 10, 20));
                        }
                    }
                    else if (Tweet.TypeofMessage == PockeTwit.Library.StatusTypes.Direct)
                    {
                        using (Brush sBrush = new SolidBrush(ClientSettings.SelectedForeColor))
                        {
                            Rectangle ImageRect = new Rectangle(ImageLocation.X, ImageLocation.Y, ClientSettings.SmallArtSize, ClientSettings.SmallArtSize);
                            Point sPoint = new Point(ImageRect.Right - 15, ImageRect.Top);

                            using (Brush bBrush = new SolidBrush(ClientSettings.SelectedBackColor))
                            {
                                g.FillRectangle(bBrush, new Rectangle(ImageRect.Right - 15, ImageRect.Top, 15, 15));
                            }
                            g.DrawString("D", ClientSettings.TextFont, sBrush, new Rectangle(ImageRect.Right - 10, ImageRect.Top, 10, 20));
                        }

                    }
                }


                textBounds.Offset(ClientSettings.Margin, 1);
                textBounds.Height--;

                BreakUpTheText(g, textBounds);
                int lineOffset = 0;

                if (!ClientSettings.UseClickables)
                {
                    g.DrawString(Tweet.DisplayText, ClientSettings.TextFont, ForeBrush, new RectangleF((float)textBounds.Left, (float)textBounds.Top, (float)textBounds.Width, (float)textBounds.Height));
                    //g.DrawString(Tweet.DisplayText, TextFont, ForeBrush, textBounds.Left, textBounds.Top, m_stringFormat);
                }
                else
                {

                    for (int i = 0; i < Tweet.SplitLines.Count; i++)
                    {
                        if (i >= ClientSettings.LinesOfText)
                        {
                            break;
                        }
                        float Position = ((lineOffset * (ClientSettings.TextSize)) + textBounds.Top);

                        g.DrawString(Tweet.SplitLines[i], ClientSettings.TextFont, ForeBrush, textBounds.Left, Position, m_stringFormat);
                        lineOffset++;
                    }
                    MakeClickable(g, textBounds);
                }
                ForeBrush.Dispose();
                g.Clip = new Region();
                this.Tweet.SplitLines = null;
            }
            catch (ObjectDisposedException)
            {
            }
            
            
        }
Example #33
0
File: SVG.cs Project: stuart2w/SAW
        public override void DrawImage(string resourceName, int preferredSize, RectangleF destination, RectangleF sourceRect, System.Drawing.Imaging.ImageAttributes attributes = null)
        {
            Image  image = GUIUtilities.VariableSizeImage(resourceName, "", preferredSize);
            string ID    = PrepareImage((Bitmap)image, resourceName.GetHashCode(), sourceRect);

            SimpleImage(ID, sourceRect.Size, destination);
        }
Example #34
0
        /// <summary>
        /// Renders a text to the specified target Image.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="target"></param>
        public void RenderToBitmap(string text, System.Drawing.Image target, float x = 0.0f, float y = 0.0f, System.Drawing.Image icons = null)
        {
            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(target))
            {
                g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                // Rendering
                int fontNum = this.fonts != null ? this.fonts.Length : 0;
                RenderState state = new RenderState(this);
                Element elem;
                while ((elem = state.NextElement()) != null)
                {
                    if (elem is TextElement && state.Font != null)
                    {
                        TextElement textElem = elem as TextElement;
                        state.Font.RenderToBitmap(
                            state.CurrentElemText,
                            target,
                            x + state.CurrentElemOffset.X,
                            y + state.CurrentElemOffset.Y + state.LineBaseLine - state.Font.BaseLine,
                            state.Color);
                    }
                    else if (elem is IconElement)
                    {
                        IconElement iconElem = elem as IconElement;
                        Icon icon = iconElem.IconIndex >= 0 && iconElem.IconIndex < this.icons.Length ? this.icons[iconElem.IconIndex] : new Icon();
                        Vector2 iconSize = icon.size;
                        Vector2 iconOffset = icon.offset;
                        Rect iconUvRect = icon.uvRect;
                        Vector2 dataCoord = iconUvRect.Pos * new Vector2(icons.Width, icons.Height);
                        Vector2 dataSize = iconUvRect.Size * new Vector2(icons.Width, icons.Height);

                        var attrib = new System.Drawing.Imaging.ImageAttributes();
                        attrib.SetColorMatrix(new System.Drawing.Imaging.ColorMatrix(new[] {
                            new[] {state.Color.R / 255.0f, 0, 0, 0},
                            new[] {0, state.Color.G / 255.0f, 0, 0},
                            new[] {0, 0, state.Color.B / 255.0f, 0},
                            new[] {0, 0, 0, state.Color.A / 255.0f} }));
                        g.DrawImage(icons,
                            new System.Drawing.Rectangle(
                                MathF.RoundToInt(x + state.CurrentElemOffset.X + iconOffset.X),
                                MathF.RoundToInt(y + state.CurrentElemOffset.Y + state.LineBaseLine - iconSize.Y + iconOffset.Y),
                                MathF.RoundToInt(iconSize.X),
                                MathF.RoundToInt(iconSize.Y)),
                            dataCoord.X, dataCoord.Y, dataSize.X, dataSize.Y,
                            System.Drawing.GraphicsUnit.Pixel,
                            attrib);
                    }
                }
            }
        }
Example #35
0
        //────────────────────────────────────────
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g"></param>
        /// <param name="isOnWindow"></param>
        /// <param name="memorySprite"></param>
        /// <param name="xBase">ベースX</param>
        /// <param name="yBase">ベースY</param>
        /// <param name="scale"></param>
        /// <param name="imgOpaque"></param>
        /// <param name="isImageGrid"></param>
        /// <param name="isInfodisplayVisible"></param>
        /// <param name="infodisplay"></param>
        public void Perform(
            Graphics g,
            bool isOnWindow,
            MemorySpriteImpl memorySprite,
            float xBase,
            float yBase,
            float scale,
            float imgOpaque,
            bool isImageGrid,
            bool isInfodisplayVisible,
            Usercontrolview_Infodisplay infodisplay
            )
        {
            // ビットマップ画像の不透明度を指定します。
            System.Drawing.Imaging.ImageAttributes ia;
            {
                System.Drawing.Imaging.ColorMatrix cm =
                    new System.Drawing.Imaging.ColorMatrix();
                cm.Matrix00 = 1;
                cm.Matrix11 = 1;
                cm.Matrix22 = 1;
                cm.Matrix33 = imgOpaque;//α値。0~1か?
                cm.Matrix44 = 1;

                //ImageAttributesオブジェクトの作成
                ia = new System.Drawing.Imaging.ImageAttributes();
                //ColorMatrixを設定する
                ia.SetColorMatrix(cm);
            }
            float dstX = 0;
            float dstY = 0;
            if (isOnWindow)
            {
                dstX += memorySprite.Lefttop.X;
                dstY += memorySprite.Lefttop.Y;
            }

            // 表示する画像の横幅、縦幅。
            float viWidth = (float)memorySprite.Bitmap.Width / memorySprite.CountcolumnResult;
            float viHeight = (float)memorySprite.Bitmap.Height / memorySprite.CountrowResult;

            // 横幅、縦幅の上限。
            if (memorySprite.WidthcellResult < viWidth)
            {
                viWidth = memorySprite.WidthcellResult;
            }

            if (memorySprite.HeightcellResult < viHeight)
            {
                viHeight = memorySprite.HeightcellResult;
            }

            // 枠を考慮しない画像サイズ
            Rectangle dstR = new Rectangle(
                (int)(dstX + xBase),
                (int)(dstY + yBase),
                (int)viWidth,
                (int)viHeight
                );
            Rectangle dstRScaled = new Rectangle(
                (int)(dstX + xBase),
                (int)(dstY + yBase),
                (int)(scale * viWidth),
                (int)(scale * viHeight)
                );

            // 太さ2pxの枠が収まるサイズ(Border Rectangle)
            int borderWidth = 2;
            Rectangle dstBr = new Rectangle(
                (int)dstX + borderWidth,
                (int)dstY + borderWidth,
                (int)viWidth - 2 * borderWidth,
                (int)viHeight - 2 * borderWidth);
            Rectangle dstBrScaled = new Rectangle(
                (int)dstX + borderWidth,
                (int)dstY + borderWidth,
                (int)(scale * viWidth) - 2 * borderWidth,
                (int)(scale * viHeight) - 2 * borderWidth);

            // 切り抜く位置。
            PointF srcL = memorySprite.GetCropXy();

            float gridX = memorySprite.GridLefttop.X;
            float gridY = memorySprite.GridLefttop.Y;

            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;//ドット絵のまま拡縮するように。しかし、この指定だと半ピクセル左上にずれるバグ。
            g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;//半ピクセル左上にずれるバグに対応。
            g.DrawImage(
                memorySprite.Bitmap,
                dstRScaled,
                srcL.X,
                srcL.Y,
                viWidth,
                viHeight,
                GraphicsUnit.Pixel,
                ia
                );

            // 枠線
            if (isImageGrid)
            {
                //
                // 枠線:影
                //
                // X,Yを、1ドット右下にずらします。
                dstRScaled.Offset(1, 1);
                // 最初の状態だと、右辺、下辺が外に1px出ています。
                // X,Yをずらした分と合わせて、縦幅、横幅を2ドット狭くします。
                dstRScaled.Width -= 2;
                dstRScaled.Height -= 2;
                g.DrawRectangle(Pens.Black, dstRScaled);
                //
                //
                dstRScaled.Offset(-1, -1);// 元の位置に戻します。
                dstRScaled.Width += 2;// 元のサイズに戻します。
                dstRScaled.Height += 2;

                //
                // 格子線は引かない。
                //

                // 枠線:緑
                // 最初から1ドット出ている分と、X,Yをずらした分と合わせて、
                // 縦幅、横幅を2ドット狭くします。
                dstRScaled.Width -= 2;
                dstRScaled.Height -= 2;
                g.DrawRectangle(Pens.Green, dstRScaled);
            }

            // 情報欄の描画
            if (isInfodisplayVisible)
            {
                int dy;
                if (isOnWindow)
                {
                    dy = 100;
                }
                else
                {
                    dy = 4;// 16;
                }
                infodisplay.Paint(g, isOnWindow, dy, scale);
            }
        }
Example #36
0
        private void pBox_Paint(object sender, PaintEventArgs e)
        {
            lRed.Text = fRed.ToString();
            lGreen.Text = fGreen.ToString();
            lBlue.Text = fBlue.ToString();
            lRedScale.Text = fRedScale.ToString();
            lGreenScale.Text = fGreenScale.ToString();
            lBlueScale.Text = fBlueScale.ToString();

            Rectangle BaseRectangle =
                new Rectangle(0, 0, pBox.Width, pBox.Height);
            Image ImageBack = null;
            if (imageBackG == null)
            {
                ImageBack = Properties.Resources.grey;

            }
            else
            {
                ImageBack = imageBackG;
            }
            System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
            float[][] colorMatrixElements = {
                           new float[] {fRedScale,  0,  0,  0, 0},        // red scaling factor
                           new float[] {0,  fGreenScale,  0,  0, 0},        // green scaling factor
                           new float[] {0,  0,  fBlueScale,  0, 0},        // blue scaling factor
                           new float[] {0,  0,  0,  1, 0},        // alpha scaling factor of 1
                           new float[] {fRed, fGreen, fBlue, 0, 1}};    //translations

            System.Drawing.Imaging.ColorMatrix colorMatrix = new System.Drawing.Imaging.ColorMatrix(colorMatrixElements);

            imageAttributes.SetColorMatrix(
               colorMatrix,
               System.Drawing.Imaging.ColorMatrixFlag.Default,
               System.Drawing.Imaging.ColorAdjustType.Bitmap);

            int width = ImageBack.Width;
            int height = ImageBack.Height;

            // what to do when pic is larger than picture box...? I decided to scale it down to picbox width

            //if (height > pBox.Height)
            //{
            //    ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
            //    ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
            //    width = (width * pBox.Height) / height;
            //    height = pBox.Height;
            //    ImageBack = ImageBack.GetThumbnailImage(width, height, null, IntPtr.Zero);

            //}
            if (width > pBox.Width)
            {
                ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
                ImageBack.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);
                height = (height * pBox.Width) / width;
                width = pBox.Width;
                ImageBack = ImageBack.GetThumbnailImage(width, height, null, IntPtr.Zero);

            }
            if (bBGIFill)
                e.Graphics.DrawImage(
                   ImageBack,
                   BaseRectangle,
                   0, 0,        // upper-left corner of source rectangle
                   width,       // width of source rectangle
                   height,      // height of source rectangle
                   GraphicsUnit.Pixel,
                   imageAttributes);
            else
            {
                imageAttributes.SetWrapMode(System.Drawing.Drawing2D.WrapMode.Tile);
                Rectangle brushRect = new Rectangle(0, 0, width, height);
                TextureBrush tBrush = new TextureBrush(ImageBack, brushRect, imageAttributes);
                e.Graphics.FillRectangle(tBrush, BaseRectangle);
                tBrush.Dispose();
            }
               // ImageBack.Dispose();
        }
Example #37
0
 private void PreparePicture()
 {
     // If there's a picture
     if (imgPicture != null)
     {
         // Create new Bitmap object with the size of the picture
             bmpPicture = new Bitmap(imgPicture.Width, imgPicture.Height);
         // Image attributes for setting the attributes of the picture
             iaPicture = new System.Drawing.Imaging.ImageAttributes();
     }
 }
		public IconImage(Image source)
		{
			this.sourceImage = source;

			// Generate specific images
			var imgAttribs = new System.Drawing.Imaging.ImageAttributes();
			System.Drawing.Imaging.ColorMatrix colorMatrix = null;
			{
				colorMatrix = new System.Drawing.Imaging.ColorMatrix(new float[][] {
					new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
					new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
					new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 0.65f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}});
				imgAttribs.SetColorMatrix(colorMatrix);
				this.images[0] = new Bitmap(source.Width, source.Height);
				using (Graphics g = Graphics.FromImage(this.images[0]))
				{
					g.DrawImage(source, 
						new Rectangle(Point.Empty, source.Size), 
						0, 0, source.Width, source.Height, GraphicsUnit.Pixel, 
						imgAttribs);
				}
			}
			{
				colorMatrix = new System.Drawing.Imaging.ColorMatrix(new float[][] {
					new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
					new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
					new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}});
				imgAttribs.SetColorMatrix(colorMatrix);
				this.images[1] = new Bitmap(source.Width, source.Height);
				using (Graphics g = Graphics.FromImage(this.images[1]))
				{
					g.DrawImage(source, 
						new Rectangle(Point.Empty, source.Size), 
						0, 0, source.Width, source.Height, GraphicsUnit.Pixel, 
						imgAttribs);
				}
			}
			{
				colorMatrix = new System.Drawing.Imaging.ColorMatrix(new float[][] {
					new float[] {1.3f, 0.0f, 0.0f, 0.0f, 0.0f},
					new float[] {0.0f, 1.3f, 0.0f, 0.0f, 0.0f},
					new float[] {0.0f, 0.0f, 1.3f, 0.0f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 1.0f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}});
				imgAttribs.SetColorMatrix(colorMatrix);
				this.images[2] = new Bitmap(source.Width, source.Height);
				using (Graphics g = Graphics.FromImage(this.images[2]))
				{
					g.DrawImage(source, 
						new Rectangle(Point.Empty, source.Size), 
						0, 0, source.Width, source.Height, GraphicsUnit.Pixel, 
						imgAttribs);
				}
			}
			{
				colorMatrix = new System.Drawing.Imaging.ColorMatrix(new float[][] {
					new float[] {0.34f, 0.34f, 0.34f, 0.0f, 0.0f},
					new float[] {0.34f, 0.34f, 0.34f, 0.0f, 0.0f},
					new float[] {0.34f, 0.34f, 0.34f, 0.0f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 0.5f, 0.0f},
					new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}});
				imgAttribs.SetColorMatrix(colorMatrix);
				this.images[3] = new Bitmap(source.Width, source.Height);
				using (Graphics g = Graphics.FromImage(this.images[3]))
				{
					g.DrawImage(source, 
						new Rectangle(Point.Empty, source.Size), 
						0, 0, source.Width, source.Height, GraphicsUnit.Pixel, 
						imgAttribs);
				}
			}
		}
 private void DrawForegroundFromButton(PaintEventArgs pevent)
 {
     if (_imageButton == null) {
         _imageButton = new Button();
         _imageButton.Parent = new TransparentControl();
         _imageButton.SuspendLayout();
         _imageButton.BackColor = Color.Transparent;
         _imageButton.FlatAppearance.BorderSize = 0;
         _imageButton.FlatStyle = FlatStyle.Flat;
     }
     else {
         _imageButton.SuspendLayout();
     }
     _imageButton.AutoEllipsis = AutoEllipsis;
     if (Enabled) {
         _imageButton.ForeColor = ForeColor;
     }
     else {
         _imageButton.ForeColor = Color.FromArgb((3 * ForeColor.R + _backColor.R) >> 2,
             (3 * ForeColor.G + _backColor.G) >> 2,
             (3 * ForeColor.B + _backColor.B) >> 2);
     }
     _imageButton.Font = Font;
     _imageButton.RightToLeft = RightToLeft;
     _imageButton.Image = Image;
     if (Image != null && !Enabled) {
         Size size = Image.Size;
         float[][] newColorMatrix = new float[5][];
         newColorMatrix[0] = new float[] { 0.2125f, 0.2125f, 0.2125f, 0f, 0f };
         newColorMatrix[1] = new float[] { 0.2577f, 0.2577f, 0.2577f, 0f, 0f };
         newColorMatrix[2] = new float[] { 0.0361f, 0.0361f, 0.0361f, 0f, 0f };
         float[] arr = new float[5];
         arr[3] = 1f;
         newColorMatrix[3] = arr;
         newColorMatrix[4] = new float[] { 0.38f, 0.38f, 0.38f, 0f, 1f };
         System.Drawing.Imaging.ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(newColorMatrix);
         System.Drawing.Imaging.ImageAttributes disabledImageAttr = new System.Drawing.Imaging.ImageAttributes();
         disabledImageAttr.ClearColorKey();
         disabledImageAttr.SetColorMatrix(matrix);
         _imageButton.Image = new Bitmap(Image.Width, Image.Height);
         using (Graphics gr = Graphics.FromImage(_imageButton.Image)) {
             gr.DrawImage(Image, new Rectangle(0, 0, size.Width, size.Height), 0, 0, size.Width, size.Height, GraphicsUnit.Pixel, disabledImageAttr);
         }
     }
     _imageButton.ImageAlign = ImageAlign;
     _imageButton.ImageIndex = ImageIndex;
     _imageButton.ImageKey = ImageKey;
     _imageButton.ImageList = ImageList;
     _imageButton.Padding = Padding;
     _imageButton.Size = Size;
     _imageButton.Text = Text;
     _imageButton.TextAlign = TextAlign;
     _imageButton.TextImageRelation = TextImageRelation;
     _imageButton.UseCompatibleTextRendering = UseCompatibleTextRendering;
     _imageButton.UseMnemonic = UseMnemonic;
     _imageButton.ResumeLayout();
     InvokePaint(_imageButton, pevent);
     if (_imageButton.Image != null && _imageButton.Image != Image) {
         _imageButton.Image.Dispose();
         _imageButton.Image = null;
     }
 }
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Drawing.Imaging.ImageAttributes imageAttributes1 = new System.Drawing.Imaging.ImageAttributes();
			this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
			this.button5 = new System.Windows.Forms.Button();
			this.bitmapButton1 = new Palaso.UI.WindowsForms.Widgets.BitmapButton();
			this.flowLayoutPanel1.SuspendLayout();
			this.SuspendLayout();
			//
			// flowLayoutPanel1
			//
			this.flowLayoutPanel1.Controls.Add(this.button5);
			this.flowLayoutPanel1.Controls.Add(this.bitmapButton1);
			this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
			this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
			this.flowLayoutPanel1.Name = "flowLayoutPanel1";
			this.flowLayoutPanel1.Size = new System.Drawing.Size(154, 150);
			this.flowLayoutPanel1.TabIndex = 1;
			//
			// button5
			//
			this.button5.AutoSize = true;
			this.button5.Dock = System.Windows.Forms.DockStyle.Top;
			this.button5.FlatAppearance.BorderSize = 0;
			this.button5.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.button5.Image = global::Bloom.Properties.Resources.placeHolderBookThumbnail;
			this.button5.Location = new System.Drawing.Point(0, 0);
			this.button5.Margin = new System.Windows.Forms.Padding(0);
			this.button5.Name = "button5";
			this.button5.Size = new System.Drawing.Size(76, 93);
			this.button5.TabIndex = 9;
			this.button5.Text = "1";
			this.button5.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
			this.button5.UseVisualStyleBackColor = true;
			//
			// bitmapButton1
			//
			this.bitmapButton1.BorderColor = System.Drawing.Color.Transparent;
			this.bitmapButton1.DisabledTextColor = System.Drawing.Color.DimGray;
			this.bitmapButton1.FlatAppearance.BorderSize = 0;
			this.bitmapButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.bitmapButton1.FocusRectangleEnabled = false;
			this.bitmapButton1.Image = null;
			this.bitmapButton1.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
			this.bitmapButton1.ImageAttributes = imageAttributes1;
			this.bitmapButton1.ImageBorderColor = System.Drawing.Color.Transparent;
			this.bitmapButton1.ImageBorderEnabled = false;
			this.bitmapButton1.ImageDropShadow = false;
			this.bitmapButton1.ImageFocused = null;
			this.bitmapButton1.ImageInactive = null;
			this.bitmapButton1.ImageMouseOver = null;
			this.bitmapButton1.ImageNormal = global::Bloom.Properties.Resources.placeHolderBookThumbnail;
			this.bitmapButton1.ImagePressed = null;
			this.bitmapButton1.InnerBorderColor = System.Drawing.Color.LightGray;
			this.bitmapButton1.InnerBorderColor_Focus = System.Drawing.Color.LightBlue;
			this.bitmapButton1.InnerBorderColor_MouseOver = System.Drawing.Color.Gold;
			this.bitmapButton1.Location = new System.Drawing.Point(76, 0);
			this.bitmapButton1.Margin = new System.Windows.Forms.Padding(0);
			this.bitmapButton1.Name = "bitmapButton1";
			this.bitmapButton1.OffsetPressedContent = true;
			this.bitmapButton1.Size = new System.Drawing.Size(61, 96);
			this.bitmapButton1.StretchImage = false;
			this.bitmapButton1.TabIndex = 10;
			this.bitmapButton1.Text = "2";
			this.bitmapButton1.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.bitmapButton1.TextDropShadow = false;
			this.bitmapButton1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
			this.bitmapButton1.UseVisualStyleBackColor = false;
			//
			// FlowThumbNailList
			//
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.BackColor = System.Drawing.SystemColors.Control;
			this.Controls.Add(this.flowLayoutPanel1);
			this.ForeColor = System.Drawing.SystemColors.WindowText;
			this.Name = "FlowThumbNailList";
			this.Size = new System.Drawing.Size(154, 150);
			//this.BackColorChanged += new System.EventHandler(this.ThumbNailList_BackColorChanged);
			this.flowLayoutPanel1.ResumeLayout(false);
			this.flowLayoutPanel1.PerformLayout();
			this.ResumeLayout(false);

		}
Example #41
0
        private void panelPreview_Paint(object sender, PaintEventArgs e)
        {
            if (_preview == null)
            {
                e.Graphics.Clear(Color.FromKnownColor(KnownColor.AppWorkspace));
                return;
            }

            using (Graphics g = Graphics.FromImage(_preview))
            {
                g.Clear(Color.FromKnownColor(KnownColor.AppWorkspace));

                var gray_matrix = new float[][] {
                    new float[] { 0.299f, 0.299f, 0.299f, 0, 0 },
                    new float[] { 0.587f, 0.587f, 0.587f, 0, 0 },
                    new float[] { 0.114f, 0.114f, 0.114f, 0, 0 },
                    new float[] { 0, 0, 0, 1, 0 },
                    new float[] { 0, 0, 0, 0, 1 }
                };

                var ia = new System.Drawing.Imaging.ImageAttributes();
                ia.SetColorMatrix(new System.Drawing.Imaging.ColorMatrix(gray_matrix));
                //            ia.SetThreshold(0.2f); // Change this threshold as needed
                float t = sliderAlpha.Value / 100f;
                ia.SetThreshold(t); // Change this threshold as needed

                g.DrawImage(
                    _selection,
                    new Rectangle(0, 0, (int)txtWidth.Value, (int)txtHeight.Value),
                    _topX,
                    _topY,
                    (int)txtWidth.Value,
                    (int)txtHeight.Value,
                    GraphicsUnit.Pixel,
                    ia);
            }
            //e.Graphics.Clear(Color.FromKnownColor(KnownColor.AppWorkspace));
            //if (_source == null)
            //    return;

            //var gray_matrix = new float[][] {
            //    new float[] { 0.299f, 0.299f, 0.299f, 0, 0 },
            //    new float[] { 0.587f, 0.587f, 0.587f, 0, 0 },
            //    new float[] { 0.114f, 0.114f, 0.114f, 0, 0 },
            //    new float[] { 0,      0,      0,      1, 0 },
            //    new float[] { 0,      0,      0,      0, 1 }
            //};

            //var ia = new System.Drawing.Imaging.ImageAttributes();
            //ia.SetColorMatrix(new System.Drawing.Imaging.ColorMatrix(gray_matrix));
            ////            ia.SetThreshold(0.2f); // Change this threshold as needed
            //float t = sliderAlpha.Value / 100f;
            //ia.SetThreshold(t); // Change this threshold as needed
            //e.Graphics.Clear(Color.Black);
            //e.Graphics.DrawImage(
            //    _selection,
            //    new Rectangle(0, 0, (int)txtWidth.Value, (int)txtHeight.Value),
            //    _topX,
            //    _topY,
            //    (int)txtWidth.Value,
            //    (int)txtHeight.Value,
            //    GraphicsUnit.Pixel,
            //    ia);
        }