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. getting the visible pixel-colors

getting the visible pixel-colors

Scheduled Pinned Locked Moved C#
question
5 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.
  • R Offline
    R Offline
    Rupel
    wrote on last edited by
    #1

    hi, i'm developing a program with a transparent area. i want to draw a text on that area. how do i get to know the colors of the pixels underneath? i want to adjust the textcolor, so that the text is almost always easy to read (you know, white on black, black on white, etc...) would be the same, if i would like to develop a screenshot-program. any idea? thx. :-O :wq

    E 1 Reply Last reply
    0
    • R Rupel

      hi, i'm developing a program with a transparent area. i want to draw a text on that area. how do i get to know the colors of the pixels underneath? i want to adjust the textcolor, so that the text is almost always easy to read (you know, white on black, black on white, etc...) would be the same, if i would like to develop a screenshot-program. any idea? thx. :-O :wq

      E Offline
      E Offline
      Eric Gunnerson msft
      wrote on last edited by
      #2

      I think you'll have to use P/Invoke to call directly into the Win32 API to do this. Here's a class I wrote that should get you started; it does screenshots now. http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=win32window One more thought - GDI+ supports alpha channel blending, which lets you do transparency. I don't know if it works for windows over the desktop, but it's worth exploring. You'll find it in the System.Drawing namespace.

      R 1 Reply Last reply
      0
      • E Eric Gunnerson msft

        I think you'll have to use P/Invoke to call directly into the Win32 API to do this. Here's a class I wrote that should get you started; it does screenshots now. http://www.gotdotnet.com/userarea/keywordsrch.aspx?keyword=win32window One more thought - GDI+ supports alpha channel blending, which lets you do transparency. I don't know if it works for windows over the desktop, but it's worth exploring. You'll find it in the System.Drawing namespace.

        R Offline
        R Offline
        Rupel
        wrote on last edited by
        #3

        i will look at your class in a minute. thx. :) i know about the alpha-blending and i'm using it. that's why i need the background-pixels. i want to know which color to use for text in the transparent area. when the background is dark, i use a light color, when it is red i use ... you see? :wq

        R 1 Reply Last reply
        0
        • R Rupel

          i will look at your class in a minute. thx. :) i know about the alpha-blending and i'm using it. that's why i need the background-pixels. i want to know which color to use for text in the transparent area. when the background is dark, i use a light color, when it is red i use ... you see? :wq

          R Offline
          R Offline
          Rupel
          wrote on last edited by
          #4

          yep. it works. great man! :) so GetDesktopWindow is the magic function. hmm. i always thought it takes a picture of the background-image of the desktop...but luckily i was wrong and it really takes a screenshot :) btw: what das msft mean? :eek: :wq

          J 1 Reply Last reply
          0
          • R Rupel

            yep. it works. great man! :) so GetDesktopWindow is the magic function. hmm. i always thought it takes a picture of the background-image of the desktop...but luckily i was wrong and it really takes a screenshot :) btw: what das msft mean? :eek: :wq

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

            Rüpel wrote: what does msft mean? M_icro_s_o_ft, if I remember correctly Eric is one of the higher ups of the C# team. James "And we are all men; apart from the females." - Colin Davies

            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