當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。