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. WPF BitmapImage and transparency

WPF BitmapImage and transparency

Scheduled Pinned Locked Moved C#
csharpwpfgraphics
6 Posts 3 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.
  • S Offline
    S Offline
    Steve Bickell
    wrote on last edited by
    #1

    Does anyone know how you select a pixel from a BitmapImage instance, say the one at 0.0, and set that as the transparent color for a bitmap.

    A G 2 Replies Last reply
    0
    • S Steve Bickell

      Does anyone know how you select a pixel from a BitmapImage instance, say the one at 0.0, and set that as the transparent color for a bitmap.

      A Offline
      A Offline
      Arjun Mjolnir Bahree
      wrote on last edited by
      #2

      Have a look at the Bitblt in Win32 APIs. thats one way fo doing this, though through Interop in .NET

      Excelsior Arjun Bahree "By The Might of Mjolnir" I Came! I Coded! I Conquered!

      S 1 Reply Last reply
      0
      • S Steve Bickell

        Does anyone know how you select a pixel from a BitmapImage instance, say the one at 0.0, and set that as the transparent color for a bitmap.

        G Offline
        G Offline
        g00fyman
        wrote on last edited by
        #3

        try this[^] hope that helps, it did me g00fy :D

        S 1 Reply Last reply
        0
        • A Arjun Mjolnir Bahree

          Have a look at the Bitblt in Win32 APIs. thats one way fo doing this, though through Interop in .NET

          Excelsior Arjun Bahree "By The Might of Mjolnir" I Came! I Coded! I Conquered!

          S Offline
          S Offline
          Steve Bickell
          wrote on last edited by
          #4

          Thanks for that. With Windows Forms etc it was easy just bitmap.MakeTransparent(bitmap.GetPixel(0, 0)); and I'm sure Bitblt would do it but I always try and avoid unmanaged code as it seems like such a backward step especially with WPF and XAML on the horizon.

          A 1 Reply Last reply
          0
          • G g00fyman

            try this[^] hope that helps, it did me g00fy :D

            S Offline
            S Offline
            Steve Bickell
            wrote on last edited by
            #5

            Wow.And to think I just used to write bitmap.MakeTransparent(bitmap.GetPixel(0, 0)); Still, that's progress for you. Thanks for the info, I'll give it a try.

            1 Reply Last reply
            0
            • S Steve Bickell

              Thanks for that. With Windows Forms etc it was easy just bitmap.MakeTransparent(bitmap.GetPixel(0, 0)); and I'm sure Bitblt would do it but I always try and avoid unmanaged code as it seems like such a backward step especially with WPF and XAML on the horizon.

              A Offline
              A Offline
              Arjun Mjolnir Bahree
              wrote on last edited by
              #6

              Anytime Steve :) Yes Bitmap class offers the transparency thing, but under the hoods its using the same API so i chose to put forward the native thing :D. There are tons of benefits of blitting but then not all is offered through the GDI+ classes and the likes. MS is making life easier for us by putting better and more abstractions over the native ways....and that is really productive. However, knowing how my car runs can reduce my dependency on the mechanic :))

              Excelsior Arjun Bahree "By The Might of Mjolnir" I Came! I Coded! I Conquered!

              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