当前位置: 首页>>代码示例>>C#>>正文


C# Imaging.ColorMap类代码示例

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


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


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