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. Transparent bitmap

Transparent bitmap

Scheduled Pinned Locked Moved C#
csharpc++graphicshelpquestion
3 Posts 2 Posters 1 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

    To draw a transparent bitmap on the form I use the old trick from VC++ which is to draw a bitmap that is stored in ImageList. When you set TransparentColor property of ImageList to the color of the bitmap's transparency color, the bitamp is drawn transparently on the form. My problem is that this doesn't work when there is another bitmap on the form behind my bitmap. I want to see this another bitmap through the transparent bitmap. In VC++ a was using SRCCOPY, SRCAND and SRCINVERT in BitBlt(). I don't see any equivalent of raster operation codes in C#. Any ideas? Jerzy

    J 1 Reply Last reply
    0
    • L Lost User

      To draw a transparent bitmap on the form I use the old trick from VC++ which is to draw a bitmap that is stored in ImageList. When you set TransparentColor property of ImageList to the color of the bitmap's transparency color, the bitamp is drawn transparently on the form. My problem is that this doesn't work when there is another bitmap on the form behind my bitmap. I want to see this another bitmap through the transparent bitmap. In VC++ a was using SRCCOPY, SRCAND and SRCINVERT in BitBlt(). I don't see any equivalent of raster operation codes in C#. Any ideas? Jerzy

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

      Bitmap bmp = Bitmap.FromFile( strFilename ); bmp.MakeTransparent( clrTransparentColorInBitmap ); Graphics g = GetGraphicsObjectToPaintOn(); g.DrawImage( bmp, x, y ); Took a bit of searching to find it :( James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

      L 1 Reply Last reply
      0
      • J James T Johnson

        Bitmap bmp = Bitmap.FromFile( strFilename ); bmp.MakeTransparent( clrTransparentColorInBitmap ); Graphics g = GetGraphicsObjectToPaintOn(); g.DrawImage( bmp, x, y ); Took a bit of searching to find it :( James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Thanks James Yes, it's a nice alternative to was I was doing (using ImageList class). But I forgot to explain that I was using PictureBox control not device context. I still wonder if I could use two PictureBox controls, one transparent over the other. Thanks again Jerzy

        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