• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Imaging.ColorMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Drawing.Imaging.ColorMap的典型用法代码示例。如果您正苦于以下问题:C# ColorMap类的具体用法?C# ColorMap怎么用?C# ColorMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ColorMap类属于System.Drawing.Imaging命名空间,在下文中一共展示了ColorMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WndProc

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case LpsWindowsApiDefine.WM_PAINT:

                    Bitmap bmpCaptured =
                      new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
                    Bitmap bmpResult =
                      new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
                    Rectangle r =
                      new Rectangle(0, 0, this.ClientRectangle.Width,
                      this.ClientRectangle.Height);

                    CaptureWindow(this, ref bmpCaptured);
                    this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
                    this.BackColor = Color.Transparent;

                    ImageAttributes imgAttrib = new ImageAttributes();

                    ColorMap[] colorMap = new ColorMap[1];

                    colorMap[0] = new ColorMap();

                    colorMap[0].OldColor = Color.White;

                    colorMap[0].NewColor = Color.Transparent;

                    imgAttrib.SetRemapTable(colorMap);

                    Graphics g = Graphics.FromImage(bmpResult);

                    g.DrawImage(bmpCaptured, r, 0, 0, this.ClientRectangle.Width,
                        this.ClientRectangle.Height, GraphicsUnit.Pixel, imgAttrib);

                    g.Dispose();

                    pictureBox.Image = (Image)bmpResult.Clone();
                    break;

                case LpsWindowsApiDefine.WM_HSCROLL:

                case LpsWindowsApiDefine.WM_VSCROLL:

                    this.Invalidate(); // repaint

                    // if you use scrolling then add these two case statements

                    break;

            }

            //switch (m.WParam.ToInt32())
            //{
            //    case WindowsApiDefine.WM_LBUTTONDOWN:
            //        p = new Point(Cursor.Position.X, Cursor.Position.Y);
            //        break;
            //}
            base.WndProc(ref m);
        }
开发者ID:yuta1011tokyo,项目名称:Liplis-Windows,代码行数:60,代码来源:CusCtlTextBox.cs


示例2: Show

        public void Show()
        {
            if (!isInit) {
                isInit = true;

                using (Bitmap newBmp = new Bitmap(16, 16)) {
                    Graphics g = Graphics.FromImage(newBmp);
                    ColorMap[] colorMap = new ColorMap[1];
                    colorMap[0] = new ColorMap();
                    colorMap[0].OldColor = Color.Fuchsia;
                    colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace);
                    ImageAttributes attr = new ImageAttributes();
                    attr.SetRemapTable(colorMap);
                    g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr);
                    tbIcon = Icon.FromHandle(newBmp.GetHicon());
                }

                NppTbData _nppTbData = new NppTbData();
                _nppTbData.hClient = this.Handle;
                _nppTbData.pszName = this.FormName();
                _nppTbData.dlgID = id;
                _nppTbData.uMask = FormMask;
                _nppTbData.hIconTab = (uint)tbIcon.Handle;
                _nppTbData.pszModuleName = UnmanagedExports.main.PluginName();
                IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
                Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false);

                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);
            } else {
                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, this.Handle);
            }
        }
开发者ID:KillerGoldFisch,项目名称:NotepadPP-CSharp-VS10-Plugin-Template,代码行数:32,代码来源:NppPluginForm.cs


示例3: RenderAlphaImage

 internal static void RenderAlphaImage(Graphics g, Image image, Rectangle imageRect, float alpha)
 {
     using (ImageAttributes imageAttributes = new ImageAttributes())
     {
         ColorMap colorMap = new ColorMap();
         colorMap.OldColor = Color.FromArgb(0xff, 0, 0xff, 0);
         colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
         ColorMap[] remapTable = new ColorMap[] { colorMap };
         imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
         float[][] CS_0_0001 = new float[5][];
         float[] CS_0_0002 = new float[5];
         CS_0_0002[0] = 1f;
         CS_0_0001[0] = CS_0_0002;
         float[] CS_0_0003 = new float[5];
         CS_0_0003[1] = 1f;
         CS_0_0001[1] = CS_0_0003;
         float[] CS_0_0004 = new float[5];
         CS_0_0004[2] = 1f;
         CS_0_0001[2] = CS_0_0004;
         float[] CS_0_0005 = new float[5];
         CS_0_0005[3] = alpha;
         CS_0_0001[3] = CS_0_0005;
         float[] CS_0_0006 = new float[5];
         CS_0_0006[4] = 1f;
         CS_0_0001[4] = CS_0_0006;
         float[][] colorMatrixElements = CS_0_0001;
         ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);
         imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
         g.DrawImage(image, imageRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
     }
 }
开发者ID:zhushengwen,项目名称:example-zhushengwen,代码行数:31,代码来源:RenderHelper.cs


示例4: Threshold

        public static Bitmap Threshold(Bitmap original)
        {
            int width = original.Width;
            int height = original.Height;
            Bitmap bmp = new Bitmap(width, height);
            using (Graphics g = Graphics.FromImage(bmp))
            {
                ImageAttributes threshold = new ImageAttributes();
                threshold.SetThreshold(0.92f);
                //attributes.SetThreshold(0.08f);

                g.DrawImage(original, new Rectangle(0, 0, width, height),
                    0, 0, width, height, GraphicsUnit.Pixel, threshold);

                ImageAttributes invert = new ImageAttributes();
                ColorMap[] map = new ColorMap[2];
                map[0] = new ColorMap();
                map[0].OldColor = Color.Black;
                map[0].NewColor = Color.White;
                map[1] = new ColorMap();
                map[1].OldColor = Color.White;
                map[1].NewColor = Color.Black;
                invert.SetRemapTable(map);

                g.DrawImage(bmp, new Rectangle(0, 0, width, height),
                    0, 0, width, height, GraphicsUnit.Pixel, invert);
            }
            return bmp;
        }
开发者ID:notox,项目名称:Hello-World,代码行数:29,代码来源:Processor.cs


示例5: DrawImageColorMapped

        /// <summary>
        /// Will draw the image, replacing oldColor with the foreColor.
        /// And also replacing the color at [0,0] to be the default transparent color.
        /// Usefull for operations with system BMP images.
        /// </summary>
        public static void DrawImageColorMapped(Graphics g, Bitmap image, Rectangle rectangle, Color oldColor, Color foreColor)
        {
            ColorMap[] colorMap = new ColorMap[2];
            colorMap[0] = new ColorMap();
            colorMap[0].OldColor = oldColor;
            colorMap[0].NewColor = foreColor;

            colorMap[1] = new ColorMap();
            colorMap[1].OldColor = image.GetPixel(0, 0);
            colorMap[1].NewColor = Color.Transparent;

            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                imageAttributes.SetRemapTable(colorMap);

                g.DrawImage(
                   image,
                   //new Rectangle(0, 0, image.Width, image.Height),
                   rectangle,
                   0, 0,
                   image.Width,
                   image.Height,
                   GraphicsUnit.Pixel,
                   imageAttributes);
            }
        }
开发者ID:redrhino,项目名称:DotNetConnectTerminal,代码行数:31,代码来源:DrawingHelper.cs


示例6: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            if (IsMouseOver && Enabled)
            {
                using (Pen pen = new Pen(ForeColor))
                {
                    e.Graphics.DrawRectangle(pen, Rectangle.Inflate(ClientRectangle, -1, -1));
                }
            }

            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                ColorMap[] colorMap = new ColorMap[2];
                colorMap[0] = new ColorMap();
                colorMap[0].OldColor = Color.FromArgb(0, 0, 0);
                colorMap[0].NewColor = ForeColor;
                colorMap[1] = new ColorMap();
                colorMap[1].OldColor = Image.GetPixel(0, 0);
                colorMap[1].NewColor = Color.Transparent;

                imageAttributes.SetRemapTable(colorMap);

                e.Graphics.DrawImage(
                   Image,
                   new Rectangle(0, 0, Image.Width, Image.Height),
                   0, 0,
                   Image.Width,
                   Image.Height,
                   GraphicsUnit.Pixel,
                   imageAttributes);
            }

            base.OnPaint(e);
        }
开发者ID:675492062,项目名称:behaviac,代码行数:34,代码来源:InertButtonBase.cs


示例7: ConvertImage

        public static void ConvertImage(Bitmap image, Graphics g, Color ForeColor, Color BackColor, bool isActive)
        {
            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                ColorMap[] colorMap = new ColorMap[2];
                colorMap[0] = new ColorMap();
                colorMap[0].OldColor = Color.FromArgb(0, 0, 0);
                colorMap[0].NewColor = ForeColor;

                colorMap[1] = new ColorMap();
                colorMap[1].OldColor = image.GetPixel(0, 0);
                colorMap[1].NewColor = isActive ? BackColor : Color.Transparent;

                imageAttributes.SetRemapTable(colorMap);

                g.DrawImage(
                   image,
                   new Rectangle(0, 0, image.Width, image.Height),
                   0, 0,
                   image.Width,
                   image.Height,
                   GraphicsUnit.Pixel,
                   imageAttributes);
            }
        }
开发者ID:armano2,项目名称:dockpanelsuite,代码行数:25,代码来源:DrawImageHelper.cs


示例8: RenderAlphaImage

 internal static void RenderAlphaImage(Graphics g, Image image, Rectangle imageRect, float alpha)
 {
     using (ImageAttributes attributes = new ImageAttributes())
     {
         ColorMap map = new ColorMap {
             OldColor = Color.FromArgb(0xff, 0, 0xff, 0),
             NewColor = Color.FromArgb(0, 0, 0, 0)
         };
         ColorMap[] mapArray = new ColorMap[] { map };
         attributes.SetRemapTable(mapArray, ColorAdjustType.Bitmap);
         float[][] numArray2 = new float[5][];
         float[] numArray3 = new float[5];
         numArray3[0] = 1f;
         numArray2[0] = numArray3;
         float[] numArray4 = new float[5];
         numArray4[1] = 1f;
         numArray2[1] = numArray4;
         float[] numArray5 = new float[5];
         numArray5[2] = 1f;
         numArray2[2] = numArray5;
         float[] numArray6 = new float[5];
         numArray6[3] = alpha;
         numArray2[3] = numArray6;
         float[] numArray7 = new float[5];
         numArray7[4] = 1f;
         numArray2[4] = numArray7;
         float[][] newColorMatrix = numArray2;
         ColorMatrix matrix = new ColorMatrix(newColorMatrix);
         attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
         g.DrawImage(image, imageRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes);
     }
 }
开发者ID:jxdong1013,项目名称:archivems,代码行数:32,代码来源:RenderHelper.cs


示例9: LostPiecesControl

 //*********************************************************     
 //
 /// <summary>
 /// Control ctor
 /// </summary>
 //  
 //*********************************************************     
 public LostPiecesControl() {
     InitializeComponent();
     m_colorMapWhite             = new ColorMap();
     m_colorMapWhite.OldColor    = System.Drawing.Color.FromArgb(255, 255, 0, 0);
     m_colorMapWhite.NewColor    = System.Drawing.Color.FromArgb(255, System.Drawing.Color.White);
     m_colorMapTblWhite          = new ColorMap[] { m_colorMapWhite };
     m_imgAttrWhite              = new ImageAttributes();
     m_bDesignMode               = false;
     m_imgAttrWhite.SetRemapTable(m_colorMapTblWhite);
 }
开发者ID:sirfreedom,项目名称:ChessNet,代码行数:17,代码来源:LostPiecesControl.cs


示例10: myMenuFunction

        /*
        internal static void myMenuFunction()
        {
            MessageBox.Show("Hello N++!");
        }
         * */
        internal static void myDockableDialog()
        {
            if (frmMyDlg == null)
            {
                frmMyDlg = new frmMyDlg();

                using (Bitmap newBmp = new Bitmap(16, 16))
                {
                    Graphics g = Graphics.FromImage(newBmp);
                    ColorMap[] colorMap = new ColorMap[1];
                    colorMap[0] = new ColorMap();
                    colorMap[0].OldColor = Color.Fuchsia;
                    colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace);
                    ImageAttributes attr = new ImageAttributes();
                    attr.SetRemapTable(colorMap);
                    g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr);
                    tbIcon = Icon.FromHandle(newBmp.GetHicon());
                }

                NppTbData _nppTbData = new NppTbData();
                _nppTbData.hClient = frmMyDlg.Handle;
                _nppTbData.pszName = "Linq2Lines query";
                _nppTbData.dlgID = idMyDlg;
                _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_BOTTOM | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR;
                _nppTbData.hIconTab = (uint)tbIcon.Handle;
                _nppTbData.pszModuleName = PluginName;
                IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
                Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false);

                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);

                // init config
                if (xmlConfig != null)
                {
                    try
                    {
                        frmMyDlg.QueryText = xmlConfig.Element("query").Value;
                        frmMyDlg.HelpersText = xmlConfig.Element("helpers").Value;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Linq2Lines error: " + ex.Message);
                    }
                }
            }
            else
            {
                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle);
            }
        }
开发者ID:shlomiw,项目名称:npp-linq2lines,代码行数:56,代码来源:Main.cs


示例11: VisualRecognitionManager

        public VisualRecognitionManager(Table table, IVisualRecognitionManagerHandler handler)
        {
            Trace.Assert(table.Game != PokerGame.Unknown, "Cannot create a visual recognition manager without knowing the game of the table");
            Trace.Assert(table.WindowRect != Rectangle.Empty, "Cannot create a visual recognition manager without knowing the window rect");

            this.table = table;
            this.handler = handler;
            this.colorMap = ColorMap.Create(table.Game);
            this.recognitionMap = new VisualRecognitionMap(table.VisualRecognitionMapLocation, colorMap);
            this.matcher = new VisualMatcher(Globals.UserSettings.CurrentPokerClient);
            this.tableWindow = new Window(table.WindowTitle);

            this.timedScreenshotTaker = new TimedScreenshotTaker(REFRESH_TIME, tableWindow);
            this.timedScreenshotTaker.ScreenshotTaken += new TimedScreenshotTaker.ScreenshotTakenHandler(timedScreenshotTaker_ScreenshotTaken);
            this.timedScreenshotTaker.Start();
        }
开发者ID:JGEsteves89,项目名称:DaCMain,代码行数:16,代码来源:VisualRecognitionManager.cs


示例12: Form1

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            timer1.Start();
            ColorMap map = new ColorMap();
            map.OldColor = Color.FromArgb(104,144,168);
            map.NewColor = Color.FromArgb(0,0,0,0);
            att.SetRemapTable(new ColorMap[] { map });
        }
开发者ID:ngoctuandl,项目名称:go-fishing-game,代码行数:16,代码来源:Game.cs


示例13: RemapColor

        private static void RemapColor(Bitmap image, Color oldColor, Color newColor)
        {
            var graphics = Graphics.FromImage(image);
            var imageAttributes = new ImageAttributes();

            var colorMap = new ColorMap();
            colorMap.OldColor = oldColor;
            colorMap.NewColor = newColor;

            ColorMap[] remapTable = { colorMap };
            imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);

            graphics.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height),
                               0, 0, image.Width, image.Height,
                               GraphicsUnit.Pixel, imageAttributes);
            graphics.Dispose();
        }
开发者ID:Isthimius,项目名称:Gondwana,代码行数:17,代码来源:Program.cs


示例14: CreatePaletteIndex

        private static ColorMap[] CreatePaletteIndex(byte Alpha)
        {
            ColorMap[] OutputMap = new ColorMap[256];

            // Change this path to wherever you saved the palette image.
            Bitmap Palette = (Bitmap)Bitmap.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("BBot.Assets.palette_2.jpg"));

            // Loop through each pixel and create a new color mapping
            for (int X = 0; X <= 255; X++)
            {
                OutputMap[X] = new ColorMap();
                OutputMap[X].OldColor = Color.FromArgb(X, X, X);
                OutputMap[X].NewColor = Color.FromArgb(Alpha, Palette.GetPixel(X, 0));
            }

            return OutputMap;
        }
开发者ID:mrsheen,项目名称:bbot,代码行数:17,代码来源:Heatmap.cs


示例15: GetTransparencyAttributes

 public static ImageAttributes GetTransparencyAttributes(float value)
 {
     ImageAttributes imageAttributes = new ImageAttributes();
     ColorMap colorMap = new ColorMap();
     colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
     colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
     ColorMap[] remapTable = { colorMap };
     imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
     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,  value, 0.0f},
            new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}
         };
     ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);
     imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
     return imageAttributes;
 }
开发者ID:rezaabiat,项目名称:BinaryArchiver,代码行数:19,代码来源:ImageManipulation.cs


示例16: RenderAlphaImage

        internal static void RenderAlphaImage(
            Graphics g, 
            Image image,
            Rectangle imageRect,
            float alpha)
        {
            using (ImageAttributes imageAttributes = new ImageAttributes())
            {
                ColorMap colorMap = new ColorMap();

                colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
                colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);

                ColorMap[] remapTable = { colorMap };

                imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);

                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,  alpha, 0.0f},
                    new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}};
                ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);

                imageAttributes.SetColorMatrix(
                    wmColorMatrix,
                    ColorMatrixFlag.Default,
                    ColorAdjustType.Bitmap);

                g.DrawImage(
                    image,
                    imageRect,
                    0,
                    0,
                    image.Width,
                    image.Height,
                    GraphicsUnit.Pixel,
                    imageAttributes);
            }
        }
开发者ID:piaolingzxh,项目名称:Justin,代码行数:41,代码来源:RenderHelper.cs


示例17: myDockableDialog

        internal static void myDockableDialog()
        {
            if (frmMyDlg == null)
            {
                frmMyDlg = new ClipboardForm();

                using (Bitmap newBmp = new Bitmap(16, 16))
                {
                    Graphics g = Graphics.FromImage(newBmp);
                    ColorMap[] colorMap = new ColorMap[1];
                    colorMap[0] = new ColorMap();
                    colorMap[0].OldColor = Color.Fuchsia;
                    colorMap[0].NewColor = Color.FromKnownColor(KnownColor.ButtonFace);
                    ImageAttributes attr = new ImageAttributes();
                    attr.SetRemapTable(colorMap);
                    g.DrawImage(tbBmp_tbTab, new Rectangle(0, 0, 16, 16), 0, 0, 16, 16, GraphicsUnit.Pixel, attr);
                    tbIcon = Icon.FromHandle(newBmp.GetHicon());
                }

                NppTbData _nppTbData = new NppTbData();
                _nppTbData.hClient = frmMyDlg.Handle;
                _nppTbData.pszName = "Clipboard Helper";
                _nppTbData.dlgID = idMyDlg;
                _nppTbData.uMask = NppTbMsg.DWS_DF_CONT_RIGHT | NppTbMsg.DWS_ICONTAB | NppTbMsg.DWS_ICONBAR;
                _nppTbData.hIconTab = (uint)tbIcon.Handle;
                _nppTbData.pszModuleName = PluginName;
                IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
                Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false);

                Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);

                isDialogVisible = true;
            }
            else
            {
                Win32.SendMessage(PluginBase.nppData._nppHandle, isDialogVisible ? NppMsg.NPPM_DMMHIDE : NppMsg.NPPM_DMMSHOW, 0, frmMyDlg.Handle);
                isDialogVisible = !isDialogVisible;
            }

            frmMyDlg.SetItems(repository.Get());
        }
开发者ID:Yodadude,项目名称:ClipboardHelper,代码行数:41,代码来源:Main.cs


示例18: addStamp

        public void addStamp(Graphics graphics, String stampImagePath)
        {
            Image image2 = Image.FromFile(stampImagePath);

            //graphics.Clear(Color.Black);

            ImageAttributes imageAttributes = new ImageAttributes();
            ColorMap colorMap = new ColorMap();

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

            imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);

            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,  0.3f, 0.0f},
                                                new float[] {0.0f,  0.0f,  0.0f,  0.0f, 1.0f}
                                             };

            ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);

            imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            Point stampPoint = new Point(30, 20);
            //Add stamp on top
            graphics.DrawImage(image2, stampPoint);

            //Add stamp as watermark
            //graphics.DrawImage(image2, new Rectangle(30, 20, image2.Width, image2.Height), 0, 0, image2.Width, image2.Height, GraphicsUnit.Pixel, imageAttributes);
            //graphics.DrawImage(image2, new Point(0, image1.Height - image2.Height));

            graphics.Dispose();
            image2.Dispose();
        }
开发者ID:kingofhawks,项目名称:kcsj,代码行数:37,代码来源:BeiAnImageUtil.cs


示例19: OnPaint

		protected override void OnPaint (PaintEventArgs e) {
			base.OnPaint(e);
			if(color != null) {
				// replace transparent color with selected color
				Graphics g = e.Graphics;
				//Graphics g = Graphics.FromImage(Image);
				ColorMap[] colorMap = new ColorMap[1];
			    colorMap[0] = new ColorMap();
			    colorMap[0].OldColor = Color.Magenta;//this.ImageTransparentColor;
			    colorMap[0].NewColor = color;
			    ImageAttributes attr = new ImageAttributes();
			    attr.SetRemapTable(colorMap);
			    Rectangle rect = new Rectangle(0, 0, Image.Width, Image.Height);
			  	// todo find a way to retrieve transparency offset automatically
			  	// for now, we use the public variable Offset to define this manually
			  	rect.Offset(Offset.X,Offset.Y);
			  	//Image.
			  	Debug.WriteLine("paint!"+this.Text+": "+color);
			  	//ssif(color.Equals(Color.Transparent)) ((Bitmap)Image).MakeTransparent(Color.Magenta);
			    g.DrawImage(Image, rect, 0, 0, rect.Width, rect.Height, GraphicsUnit.Pixel, attr);
			    //this.Image.In
			    
			}
		}
开发者ID:logtcn,项目名称:greenshot,代码行数:24,代码来源:ColorPickerToolStripButton.cs


示例20: DrawImage

		private void DrawImage(Graphics g)
		{
			Image image = this.Enabled ? ImageEnabled : ((ImageDisabled != null) ? ImageDisabled : ImageEnabled);
			ImageAttributes imageAttr = null;

			if (null == image)
				return;

			if (m_monochrom)
			{
				imageAttr = new ImageAttributes();

				// transform the monochrom image
				// white -> BackColor
				// black -> ForeColor
				ColorMap[] colorMap = new ColorMap[2];
				colorMap[0] = new ColorMap();
				colorMap[0].OldColor = Color.White;
				colorMap[0].NewColor = this.BackColor;
				colorMap[1] = new ColorMap();
				colorMap[1].OldColor = Color.Black;
				colorMap[1].NewColor = this.ForeColor;
				imageAttr.SetRemapTable(colorMap);
			}

			Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);

			if ((!Enabled) && (null == ImageDisabled))
			{
				using (Bitmap bitmapMono = new Bitmap(image, ClientRectangle.Size))
				{
					if (imageAttr != null)
					{
						using (Graphics gMono = Graphics.FromImage(bitmapMono))
						{
							gMono.DrawImage(image, new Point[3] { new Point(0, 0), new Point(image.Width - 1, 0), new Point(0, image.Height - 1) }, rect, GraphicsUnit.Pixel, imageAttr);
						}
					}
					ControlPaint.DrawImageDisabled(g, bitmapMono, 0, 0, this.BackColor);
				}
			}
			else
			{
				// Three points provided are upper-left, upper-right and 
				// lower-left of the destination parallelogram. 
				Point[] pts = new Point[3];
				pts[0].X = (Enabled && m_mouseOver && m_mouseCapture) ? 1 : 0;
				pts[0].Y = (Enabled && m_mouseOver && m_mouseCapture) ? 1 : 0;
				pts[1].X = pts[0].X + ClientRectangle.Width;
				pts[1].Y = pts[0].Y;
				pts[2].X = pts[0].X;
				pts[2].Y = pts[1].Y + ClientRectangle.Height;

				if (imageAttr == null)
					g.DrawImage(image, pts, rect, GraphicsUnit.Pixel);
				else
					g.DrawImage(image, pts, rect, GraphicsUnit.Pixel, imageAttr);
			}
		}	
开发者ID:viticm,项目名称:pap2,代码行数:59,代码来源:InertButton.cs



注:本文中的System.Drawing.Imaging.ColorMap类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Imaging.ColorMatrix类代码示例发布时间:2022-05-26
下一篇:
C# Imaging.BitmapData类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap