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


C# ImageAttributes.SetRemapTable方法代码示例

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


在下文中一共展示了ImageAttributes.SetRemapTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: draw

        public override void draw(List<Cluster> clusters)
        {
            //I added this to subtract from the X, Y coord
              //to center the heat map.
              float radius = this._grid.cell_width / 2;
              if (this.surface == null)
            this.clear();

              surface.TranslateTransform(-this.grid.location.X, -this.grid.location.Y);

              PointF pasdf = this._grid.scale_to_screen_coords(new Location(1, 1));

              ImageAttributes remapper = new ImageAttributes();
              remapper.SetRemapTable(ColorHeatMapClusterRenderer.color_map);

              HeatMapClusterRenderer hm = new HeatMapClusterRenderer(this.surface, this._grid);
              hm.draw(clusters);

              Rectangle dest_rectangle = new Rectangle(this.grid.location, this.grid.size);

              dest_rectangle.Width += this.grid.location.X * 2;
              dest_rectangle.Height += this.grid.location.Y * 2;

              for (int i = 0; i < 12; ++i)
            this.g.DrawImage(output, dest_rectangle, 0, 0, output.Width, output.Height, GraphicsUnit.Pixel, remapper);
        }
开发者ID:iamjwc,项目名称:fightin-zigbees,代码行数:26,代码来源:color_heat_map_cluster_renderer.cs

示例8: PaintValue

        public override void PaintValue(PaintValueEventArgs e)
        {
            if (!(e.Context.Instance is KrbTabControl)) return;
            var parent = (KrbTabControl)e.Context.Instance;
            var caption = (ButtonsCaption)e.Value;

            using (var brush = new LinearGradientBrush(e.Bounds, parent.GradientCaption.InactiveCaptionColorStart, parent.GradientCaption.InactiveCaptionColorEnd, parent.GradientCaption.CaptionGradientStyle))
            {
                var bl = new Blend(2) { Factors = new[] { 0.1F, 1.0F }, Positions = new[] { 0.0F, 1.0F } };
                brush.Blend = bl;
                e.Graphics.FillRectangle(brush, e.Bounds);

                Image captionDropDown = Resources.DropDown;
                using (var attributes = new ImageAttributes())
                {
                    var map = new[]
                    {
                        new ColorMap {OldColor = Color.White, NewColor = Color.Transparent},
                        new ColorMap {OldColor = Color.Black, NewColor = caption.InactiveCaptionButtonsColor}
                    };

                    attributes.SetRemapTable(map);

                    var rect = e.Bounds;
                    rect.Inflate(-3, 0);
                    e.Graphics.DrawImage(captionDropDown, rect, 0, 0, captionDropDown.Width, captionDropDown.Height, GraphicsUnit.Pixel, attributes);
                }
            }
        }
开发者ID:KelvinCoding,项目名称:masterwork-dwarf-fortress,代码行数:29,代码来源:ButtonsCaptionEditor.cs

示例9: 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

示例10: Colorize

        public static Bitmap Colorize(Bitmap Mask, byte Alpha)
        {
            // Create new bitmap to act as a work surface for the colorization process
            Bitmap Output = new Bitmap(Mask.Width, Mask.Height, PixelFormat.Format32bppArgb);

            // Create a graphics object from our memory bitmap so we can draw on it and clear it's drawing surface
            using (Graphics Surface = Graphics.FromImage(Output))
            {
                Surface.Clear(Color.Transparent);

                // Build an array of color mappings to remap our greyscale mask to full color
                // Accept an alpha byte to specify the transparancy of the output image
                ColorMap[] Colors = CreatePaletteIndex(Alpha);

                // Create new image attributes class to handle the color remappings
                // Inject our color map array to instruct the image attributes class how to do the colorization
                ImageAttributes Remapper = new ImageAttributes();
                Remapper.SetRemapTable(Colors);

                // Draw our mask onto our memory bitmap work surface using the new color mapping scheme
                Surface.DrawImage(Mask, new Rectangle(0, 0, Mask.Width, Mask.Height), 0, 0, Mask.Width, Mask.Height, GraphicsUnit.Pixel, Remapper);
            }
            // Send back newly colorized memory bitmap
            return Output;
        }
开发者ID:mrsheen,项目名称:bbot,代码行数:25,代码来源:Heatmap.cs

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例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.ImageAttributes.SetRemapTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。