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


C# Bitmap.MakeTransparent方法代码示例

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


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

示例1: Create

        public static Icon Create(Bitmap bm)
        {
            bm.MakeTransparent(Color.White);
            IntPtr ich = bm.GetHicon();

            return Icon.FromHandle(ich);
        }
开发者ID:ben-shepherd,项目名称:RealityCheckReminder,代码行数:7,代码来源:Program.cs

示例2: ScaleBitmap

        private static Bitmap ScaleBitmap(Bitmap image, int width, int height)
        {
            if (height == -1)
            {
                var scale = (double)image.Height / (double)image.Width;
                height = (int)Math.Ceiling(image.Height * ((double)width / (double)image.Width) * scale);
            }
            var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            // set the resolutions the same to avoid cropping due to resolution differences
            bmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);

            //use a graphics object to draw the resized image into the bitmap
            using (Graphics graphics = Graphics.FromImage(bmp))
            {
                //set the resize quality modes to high quality
                graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                //draw the image into the target bitmap
                graphics.DrawImage(image, 0, 0, bmp.Width, bmp.Height);
                bmp.MakeTransparent(bmp.GetPixel(0, 0));
            }
            //return the resulting bitmap
            return bmp;
        }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:25,代码来源:ImageUtil.cs

示例3: clsPickups

        public clsPickups(int x, int y, int pickupType)
            : base(x, y, 0, 0)
        {
            //------------------------------------------------------------------------------------------------------------------
            // Purpose: Class constructor
            //------------------------------------------------------------------------------------------------------------------

            //:: Load resource image(s) & remove background and thu a sprite is born ::
            switch (pickupType)
            {
                case 0:
                    pickup = GridcoinGalaza.Properties.Resources.pickupA;
                    break;
                case 1:
                    pickup = GridcoinGalaza.Properties.Resources.pickupB;
                    break;
                case 2:
                    pickup = GridcoinGalaza.Properties.Resources.pickupC;
                    break;
            }

            // Remove background
            pickup.MakeTransparent(Color.Black);

            // Assign attributes this class
            this.pickupType = pickupType;

            // Apply width and height call to super
            base.setH(pickup.Height);
            base.setW(pickup.Width);
        }
开发者ID:JohnLZeller,项目名称:Gridcoin-Research,代码行数:31,代码来源:clsPickups.cs

示例4: MultivariateRendPropPageCS

		public MultivariateRendPropPageCS()
		{
			//'MsgBox("New (color prop page)")
			m_Page = new PropPageForm();
			m_Priority = 550; // 5th category is for multiple attribute renderers

			string[] res = typeof(MultivariateRendPropPageCS).Assembly.GetManifestResourceNames();
			if (res.GetLength(0) > 0)
			{
				
                

                try
                {   
                    string bitmapResourceName = GetType().Name + ".bmp";
                    //creating a new bitmap
                    m_bitmap = new Bitmap(GetType(), bitmapResourceName);
                }
                 catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap");
                }


				if (m_bitmap != null)
				{
					m_bitmap.MakeTransparent(m_bitmap.GetPixel(1, 1));
					m_hBitmap = m_bitmap.GetHbitmap();
				}
			}

		}
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:32,代码来源:MultivariateRendPropPage.cs

示例5: Node

        public Node(int type,Point screenPos)
        {
            screenPosition = screenPos;
            float ratioX =  (float)screenPosition.X / (float)AutomatsDesign.PICTURE_WIDTH ;
            centerPoint.X = AutomatsDesign.LOGICAL_SIZE.X * ratioX;
            float ratioY =  (float)screenPosition.Y /(float)AutomatsDesign.PICTURE_HEIGHT ;
            centerPoint.Y = AutomatsDesign.LOGICAL_SIZE.Y * ratioY;
            try
            {
                System.Reflection.Assembly thisExe;
                thisExe = System.Reflection.Assembly.GetExecutingAssembly();
                String imagePath="";
                typeNode = type;
                switch (type)
                {
                    case 0: imagePath = "Linquistics.Resources.state_begin.bmp"; break;
                    case 1: imagePath = "Linquistics.Resources.state.bmp"; break;
                    case 2: imagePath = "Linquistics.Resources.state_accepted.bmp"; break;
                }
                System.IO.Stream file =
                     thisExe.GetManifestResourceStream(imagePath);

                statePicture = new Bitmap(file);

                statePicture.MakeTransparent(Color.FromArgb(240, 240, 240));
                widthPict = (int)((float)AutomatsDesign.IMAGE_DIMENSION * ((float)statePicture.Width / (float)statePicture.Height));
                radius = (int)(Math.Round(Math.Sqrt(Math.Pow((statePicture.Height / 2), 2) + Math.Pow((statePicture.Width / 2), 2)))) - 10;
            }
            catch(Exception ex)
            {

            }
        }
开发者ID:BackupTheBerlios,项目名称:railwaysim,代码行数:33,代码来源:Node.cs

示例6: CommunityToolWindow

 public CommunityToolWindow(IServiceProvider serviceProvider)
     : base(serviceProvider)
 {
     this.InitializeUserInterface();
     Bitmap bitmap = new Bitmap(typeof(CommunityToolWindow), "Refresh.bmp");
     bitmap.MakeTransparent(Color.Fuchsia);
     this._buttonImages.Images.Add(bitmap);
     this._refreshButton = new MxToolBarButton();
     this._refreshButton.ToolTipText = "Refresh";
     this._refreshButton.Enabled = false;
     this._refreshButton.ImageIndex = 0;
     MxToolBarButton button = new MxToolBarButton();
     button.Style = ToolBarButtonStyle.Separator;
     this._toolBar.Buttons.Add(this._refreshButton);
     this._toolBar.Buttons.Add(button);
     this._tabs = new ArrayList();
     ArrayList config = (ArrayList) ConfigurationSettings.GetConfig("microsoft.matrix/community");
     if (config != null)
     {
         for (int i = 0; i < config.Count; i += 2)
         {
             string typeName = (string) config[i];
             string initializationData = (string) config[i + 1];
             try
             {
                 CommunityTab tab = (CommunityTab) Activator.CreateInstance(System.Type.GetType(typeName, true, false));
                 tab.Initialize(serviceProvider, initializationData);
                 this.AddTab(tab);
             }
             catch (Exception)
             {
             }
         }
     }
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:35,代码来源:CommunityToolWindow.cs

示例7: Joueur

        private int totalPoint; // le score du joueur

        #endregion Fields

        #region Constructors

        // constructeur, on recoit le panel, le point de départ dans le panel et si le joueur est le premier ou le deuxieme
        public Joueur(Panel panel, Point loc, bool j1)
        {
            pBJoueur = new PictureBox(); // on instencie le pB du joueur
            pBJoueur.Location = loc;    // on place le joueur a la bonne position dans le panel
            pBJoueur.BackColor = Color.Transparent; // Astuce pour avoir un fond transparent avec un bitmap. La couleur de fond est transparente
            Bitmap vaisseau;
            if (j1)                 // Si c'est le joueur 1 alors il sera blanc. On choisi un pixel ( dans un des coins) dont la couleur correspondra au transparent
            {
                joueur1 = true;     // variable pour les animations (pas avoir de changement de couleurs lors du changement d'image)
                vaisseau = new Bitmap(@".\vaisseau.bmp");
                vaisseau.MakeTransparent((vaisseau.GetPixel(0, vaisseau.Size.Height - 1)));
            }                       // si c'est le joueur 2
            else
            {
                joueur1 = false;
                vaisseau = new Bitmap(@".\vaisseau2.bmp");
                vaisseau.MakeTransparent((vaisseau.GetPixel(0, vaisseau.Size.Height - 1)));
            }
            pBJoueur.Size = new Size(50, 50); // on donne la taille au pB
            pBJoueur.Image = vaisseau; // On donne au pB l'image
            pBJoueur.BringToFront();    // On met le pB au premier plan pour éviter des recouvrements
            this.panelFond = panel;     // On met le panel recu dans une des variables pour éviter de devoir faire des envois intempestifs
            panelFond.Controls.Add(pBJoueur); // on ajoute le joueur au controle du panel (pour qu'on ne voie pas le gros carré noir)
            pBJoueur.Refresh(); // Pour etre certain que l'image est bien présente dans le pB
            totalPoint = 0; // on mets son score a 0
            combo = 1000;   // On rempli sa jauge de super tir
        }
开发者ID:Boucquey,项目名称:projetInfo,代码行数:34,代码来源:Joueur.cs

示例8: Main

        static void Main(string[] args)
        {

            String timestamp = args[0];
            //Console.WriteLine(timestamp);

            Bitmap p0 = new Bitmap(256*6, 256*6);
            Graphics g = Graphics.FromImage(p0);
            g.CompositingMode = CompositingMode.SourceCopy;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    try
                    {
                        int x = 1648 + i;
                        int y = 441 + j;
                        Bitmap p1 = new Bitmap("data\\" + timestamp + "_" + x + "_" + y + ".png");
                        p1.MakeTransparent();
                        g.DrawImage(p1, new Point(i * 256, (6 - j) * 256));
                    }
                    catch (Exception e)
                    { }
                }
            }
                
            p0.Save("data\\"+timestamp+".png");
        }
开发者ID:Erickrus,项目名称:js-web-crawler,代码行数:29,代码来源:Program.cs

示例9: Splash

 public Splash()
 {
     InitializeComponent();
     Bitmap b = new Bitmap(this.BackgroundImage);
     b.MakeTransparent(b.GetPixel(1, 1));
     this.BackgroundImage = b;
 }
开发者ID:Behzadkhosravifar,项目名称:CompilerT3,代码行数:7,代码来源:Splash.cs

示例10: SigNameToImage

        /// <summary>
        /// Draws a signature using the journal font.
        /// </summary>
        /// <param name="name">User's name to create a signature for.</param>
        /// <param name="fontPath">Full path of journal.ttf. Should be passed if system doesn't have the font installed.</param>
        /// <returns>Bitmap image containing the user's signature.</returns>
        public Bitmap SigNameToImage(string name, string fontPath )
        {
            //we need a reference to the font, be it the .tff in the site project or the version installed on the host
            if (string.IsNullOrEmpty(fontPath) && !FontFamily.Families.Any(f => f.Name.Equals(FONT_FAMILY)))
            {
                throw new ArgumentException("FontPath must point to the copy of journal.ttf when the system does not have the font installed", "fontPath");
            }

            Bitmap signatureImage = new Bitmap(Width, Height);
            signatureImage.MakeTransparent();
            using (Graphics signatureGraphic = Graphics.FromImage(signatureImage))
            {
                signatureGraphic.Clear(Background);

                Font font;
                if (!string.IsNullOrEmpty(fontPath))
                {
                    //to make sure the host doesn't need the font installed, use a private font collection
                    PrivateFontCollection collection = new PrivateFontCollection();
                    collection.AddFontFile(fontPath);
                    font = new Font(collection.Families.First(), FontSize);
                }
                else
                {
                    //fall back to the version installed on the host
                    font = new Font(FONT_FAMILY, FontSize);
                }

                signatureGraphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                signatureGraphic.DrawString(name ?? string.Empty, font, new SolidBrush(PenColor), new PointF(0, 0));
            }
            return signatureImage;
        }
开发者ID:PaoloMisson,项目名称:GATEvolution,代码行数:39,代码来源:SignatureToImg.cs

示例11: GridErrorDlg

        public GridErrorDlg(PropertyGrid owner) {
            ownerGrid = owner;
            expandImage = new Bitmap(typeof(ThreadExceptionDialog), "down.bmp");
            expandImage.MakeTransparent();
            if (DpiHelper.IsScalingRequired) {
                DpiHelper.ScaleBitmapLogicalToDevice(ref expandImage);
            }
            collapseImage = new Bitmap(typeof(ThreadExceptionDialog), "up.bmp");
            collapseImage.MakeTransparent();
            if (DpiHelper.IsScalingRequired) {
                DpiHelper.ScaleBitmapLogicalToDevice(ref collapseImage);
            }

            InitializeComponent();

            foreach( Control c in this.Controls ){
                if( c.SupportsUseCompatibleTextRendering ){
                    c.UseCompatibleTextRenderingInt = ownerGrid.UseCompatibleTextRendering;
                }
            }

            pictureBox.Image = SystemIcons.Warning.ToBitmap();
            detailsBtn.Text = " " + SR.GetString(SR.ExDlgShowDetails);

            details.AccessibleName = SR.GetString(SR.ExDlgDetailsText);
            
            okBtn.Text = SR.GetString(SR.ExDlgOk);
            cancelBtn.Text = SR.GetString(SR.ExDlgCancel);
            detailsBtn.Image = expandImage;
        }
开发者ID:salim18,项目名称:DemoProject2,代码行数:30,代码来源:GridErrorDlg.cs

示例12: DrivesForm

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

			// Small and large image lists
			lvDrives.SmallImageList = new ImageList();
			Bitmap icoSmall = new Bitmap(GetType(), "LvIcons.bmp");
			icoSmall.MakeTransparent(Color.FromArgb(0xff, 0x00, 0xff));
			lvDrives.SmallImageList.Images.AddStrip(icoSmall);

			lvDrives.LargeImageList = new ImageList();
			Bitmap icoLarge = new Bitmap(GetType(), "LvIconsLarge.bmp");
			icoLarge.MakeTransparent(Color.FromArgb(0xff, 0x00, 0xff));
			Size sizeImages = new Size(32,32);
			lvDrives.LargeImageList.ImageSize = sizeImages;
			lvDrives.LargeImageList.Images.AddStrip(icoLarge);

			lvDrives.Columns.Add("Drive", 100, HorizontalAlignment.Left);
			lvDrives.Columns.Add("Type", 150, HorizontalAlignment.Left);

			ListDrives();
		}
开发者ID:ppatoria,项目名称:SoftwareDevelopment,代码行数:25,代码来源:MAIN.CS

示例13: DrawNote

        public Bitmap DrawNote(Bitmap stave, Bitmap note, Tone tone, int notePositionX)
        {
            int index = ToneGraph.GetReferenceToneIndex(tone);
            Bitmap newBitmap = new Bitmap(stave.Width, stave.Height);

            using (Graphics graphics = Graphics.FromImage(newBitmap))
            {
                Rectangle ImageSize = new Rectangle(0, 0, stave.Width, stave.Height);
                graphics.FillRectangle(Brushes.White, ImageSize);

                if (tone.ChromaticChange != 0)
                {
                    DrawFlatSharpSymbol(newBitmap, tone, index, notePositionX);
                }

                graphics.DrawImage(note, new Point(notePositionX, this.LowestNotePositionY -
                                                                 (this.DistanceBetweenLines / 2) * index));
                DrawLedgerLine(newBitmap, tone, index, notePositionX);
                graphics.CompositingMode = CompositingMode.SourceOver;
                stave.MakeTransparent(Color.White);
                graphics.DrawImage(stave, 0, 0);
            }

            return newBitmap;
        }
开发者ID:Desann36,项目名称:MusicTheory,代码行数:25,代码来源:StaveDrawing.cs

示例14: Enemy

 public Enemy(GameWorld game, string path)
     : base(game)
 {
     Bitmap b = new Bitmap(path);
     b.MakeTransparent(Color.Black);
     image = b;
 }
开发者ID:HitCZ,项目名称:SpaceShooter,代码行数:7,代码来源:Enemy.cs

示例15: GenerateEnemy

        public void GenerateEnemy()
        {
            Graphics _graphics;
            SolidBrush b = new SolidBrush(GhostColor);
            SolidBrush _eyeBrush = new SolidBrush(Color.White);
            SolidBrush _pupilBrush = new SolidBrush(Color.FromArgb(34, 32, 216));
            SolidBrush _coverBrush = new SolidBrush(Color.Black);

            Point _p = new Point(-1, -1);

            int _width = 30;
            int _height = 30;

            Bitmap _bmpCharBase = new Bitmap(_width, _height);
            _bmpCharBase = new Bitmap(_width, _height);
            _graphics = Graphics.FromImage(_bmpCharBase);
            _graphics.SmoothingMode = SmoothingMode.AntiAlias;
            _graphics.FillEllipse(b, _p.X + 3, _p.Y, _width - 4, _height - 2);
            _graphics.FillRectangle(b, _p.X + 3, _p.Y + _height / 2 - 1, _width - 4, _height / 2);

            BmpCharUp1 = (Bitmap)_bmpCharBase.Clone();
            _graphics = Graphics.FromImage(BmpCharUp1);
            _graphics.SmoothingMode = SmoothingMode.AntiAlias;
            _graphics.FillPie(_coverBrush, _p.X + 3, _p.Y + _height - 11, 10, 11, 45, 90);
            _graphics.FillRectangle(_coverBrush, _p.X + (_width / 2 - 1), _p.Y + _height - 5, 4, 5);
            _graphics.FillPie(_coverBrush, _p.X + _width - 11, _p.Y + _height - 11, 10, 11, 45, 90);

            BmpCharUp1.MakeTransparent(Color.Black);
        }
开发者ID:VaidasKrl,项目名称:Pacman,代码行数:29,代码来源:Enemy.cs


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