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 / C++ / MFC
  4. Colors and Alpha

Colors and Alpha

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
4 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.
  • T Offline
    T Offline
    Tomas Petricek
    wrote on last edited by
    #1

    Hi, I need to calculate color, when I use two layers.. bottom layer have color: r1,g1,b1,a1 and top layer have color: r2,g2,b2,a2 but I don't know how to calculate resulting color.:confused: Alpha component is:

    a=a1+a2*(255-a1)/255;

    but I don't know other color components. (Only when a1==255 => bottom layer is opaque). Thanks for help! i'm only pointer to myself

    C 1 Reply Last reply
    0
    • T Tomas Petricek

      Hi, I need to calculate color, when I use two layers.. bottom layer have color: r1,g1,b1,a1 and top layer have color: r2,g2,b2,a2 but I don't know how to calculate resulting color.:confused: Alpha component is:

      a=a1+a2*(255-a1)/255;

      but I don't know other color components. (Only when a1==255 => bottom layer is opaque). Thanks for help! i'm only pointer to myself

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      alpha generally ignores the bottom layer. alpha usually only applies to the top image, it controls overlay transparency and the bottom alpha is unchanged by the overlay image. -c


      When history comes, it always takes you by surprise.

      Bobber!

      J 1 Reply Last reply
      0
      • C Chris Losinger

        alpha generally ignores the bottom layer. alpha usually only applies to the top image, it controls overlay transparency and the bottom alpha is unchanged by the overlay image. -c


        When history comes, it always takes you by surprise.

        Bobber!

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #3

        Surely you must consider the alpha values of all images in the stack if there's a background layer? -- It's not unusual to be picked up by a klingon woman It's not unusual to have fun with a klingon When I see you kicking me around It's not unusual to see me cry, I wanna die

        C 1 Reply Last reply
        0
        • J Jorgen Sigvardsson

          Surely you must consider the alpha values of all images in the stack if there's a background layer? -- It's not unusual to be picked up by a klingon woman It's not unusual to have fun with a klingon When I see you kicking me around It's not unusual to see me cry, I wanna die

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          just merge each layer onto the background, one at a time, in Z order. -c


          When history comes, it always takes you by surprise.

          Bobber!

          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