Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Bitmap Button

Bitmap Button

Scheduled Pinned Locked Moved C#
graphicshelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    How can I draw a bitmap button with a transparent background. Im using the code below to try and do this but its not working how it should. Bitmap b = new Bitmap("D:\\-=[Pics]=-\\test.jpg"); b.MakeTransparent(b.GetPixel(0,0)); pe.Graphics.FillRectangle (Brushes.Transparent,ClientRectangle); pe.Graphics.DrawImage(b,ClientRectangle); Im trying to paint the button transparent then draw an image whose transparency key is the same as the color at 0,0 of the bitmap. It sort of works but when the image is drawn on the button the background looks more like swiss cheese than transparent. Any help would be great. Thanks Danny

    J 1 Reply Last reply
    0
    • L Lost User

      How can I draw a bitmap button with a transparent background. Im using the code below to try and do this but its not working how it should. Bitmap b = new Bitmap("D:\\-=[Pics]=-\\test.jpg"); b.MakeTransparent(b.GetPixel(0,0)); pe.Graphics.FillRectangle (Brushes.Transparent,ClientRectangle); pe.Graphics.DrawImage(b,ClientRectangle); Im trying to paint the button transparent then draw an image whose transparency key is the same as the color at 0,0 of the bitmap. It sort of works but when the image is drawn on the button the background looks more like swiss cheese than transparent. Any help would be great. Thanks Danny

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      Try opening the JPEG in an image viewer, I bet your background color got mangled during the compression of the file resulting in a slightly different color in spots (but nothing the human eye would notice). If possible you should stick to lossless image formats such as: BMP, GIF, PNG HTH, James Sonork: Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups