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. Graphics
  4. Creating Gradient Images

Creating Gradient Images

Scheduled Pinned Locked Moved Graphics
xmlphpwpfcareer
5 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.
  • B Offline
    B Offline
    Bradml
    wrote on last edited by
    #1

    I am looking at the new Vista/07  styles and was wondering what the formula was for creating the gradients.


    Brad Australian - unknown PHP Developer on "Job Prospect" Requirement: * Experience working with XML, XSL, XPath Comment: and other things starting with X.

    R 1 Reply Last reply
    0
    • B Bradml

      I am looking at the new Vista/07  styles and was wondering what the formula was for creating the gradients.


      Brad Australian - unknown PHP Developer on "Job Prospect" Requirement: * Experience working with XML, XSL, XPath Comment: and other things starting with X.

      R Offline
      R Offline
      Rilhas
      wrote on last edited by
      #2

      I don't understand your question... I noted nothing misterious with Vista's gradients... maybe you mean gradients in color and in transparency? Or are you just asking about gradients in general?

      B 1 Reply Last reply
      0
      • R Rilhas

        I don't understand your question... I noted nothing misterious with Vista's gradients... maybe you mean gradients in color and in transparency? Or are you just asking about gradients in general?

        B Offline
        B Offline
        Bradml
        wrote on last edited by
        #3

        Yeah just gradients in general. I know nothing of graphics

        R 1 Reply Last reply
        0
        • B Bradml

          Yeah just gradients in general. I know nothing of graphics

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

          Ok. Modern computer graphics consist of pixels, which are the smallest units of color that can be represented on the screen. A screen of 1280x1024 contains 1.3 million pixels, and a modern display can set each one of those pixels to an individual color. These pixels are divided into 3 components: the red, the green, and the blue. This is because almost every color that our eyes can distinguish can be obtained by combining diferent amounts of red, green, and blue. So, controlling only these 3 components can make it possible to obtain almost any possible color. Then there is component resolution. Each component can be varied in intensity to achieve diferent colors, as I mentioned before. Usually we cannot distinguish between more than about 150 steps, meaning that if the span of a given component (from invisible (or off) to its full intensity) is divided into more than about 150 steps then we cannot tell the difference from one step to another. So we don't need to divide the span into more than 150 steps. However we divide it into 256 steps, to make it confortable to store components in computer memory (one byte per component) and for some other not so obvious reasons. This givs us a total of over 16 million individual colors (with 256 steps per component we get a total of 256x256x256 different colors). To get white you sum all components (you set red, green, and blue, to full intensity). This is the whitest that a screen is able to represent. To get black you turn them all off, and that is the blackest that a screen can represent. Screens vary in their ability to make full white or full black. For example, my video projector is unable to make perfect white because the blue component is a little weaker than the others (as with many of the mid-range video projectors). Also, LCD's/TFT's are unable to make perfect black, usually because the material used for their construction usually reflects some envoronmental light. If you want a gradient from black to white (from left to right, for example) then you should vary the component intensity from off (to the left) to on (to the right). Imagine an image of 800x600 and the following formula: for(x=0; x<800; x++) { for(y=0; y<600; y++) { pixel(x,y).red=x/799*255; pixel(x,y).green=x/799*255; pixel(x,y).blue=x/799*255; } // next y } // next x As you can see, x/799 is 1.0 only when x is 799, and that happens only at the rightmost pixel. Also, x/799 is zero on the left. An inversion would be simple, just replace x/799 by (799-x)/799. Also note tha

          B 1 Reply Last reply
          0
          • R Rilhas

            Ok. Modern computer graphics consist of pixels, which are the smallest units of color that can be represented on the screen. A screen of 1280x1024 contains 1.3 million pixels, and a modern display can set each one of those pixels to an individual color. These pixels are divided into 3 components: the red, the green, and the blue. This is because almost every color that our eyes can distinguish can be obtained by combining diferent amounts of red, green, and blue. So, controlling only these 3 components can make it possible to obtain almost any possible color. Then there is component resolution. Each component can be varied in intensity to achieve diferent colors, as I mentioned before. Usually we cannot distinguish between more than about 150 steps, meaning that if the span of a given component (from invisible (or off) to its full intensity) is divided into more than about 150 steps then we cannot tell the difference from one step to another. So we don't need to divide the span into more than 150 steps. However we divide it into 256 steps, to make it confortable to store components in computer memory (one byte per component) and for some other not so obvious reasons. This givs us a total of over 16 million individual colors (with 256 steps per component we get a total of 256x256x256 different colors). To get white you sum all components (you set red, green, and blue, to full intensity). This is the whitest that a screen is able to represent. To get black you turn them all off, and that is the blackest that a screen can represent. Screens vary in their ability to make full white or full black. For example, my video projector is unable to make perfect white because the blue component is a little weaker than the others (as with many of the mid-range video projectors). Also, LCD's/TFT's are unable to make perfect black, usually because the material used for their construction usually reflects some envoronmental light. If you want a gradient from black to white (from left to right, for example) then you should vary the component intensity from off (to the left) to on (to the right). Imagine an image of 800x600 and the following formula: for(x=0; x<800; x++) { for(y=0; y<600; y++) { pixel(x,y).red=x/799*255; pixel(x,y).green=x/799*255; pixel(x,y).blue=x/799*255; } // next y } // next x As you can see, x/799 is 1.0 only when x is 799, and that happens only at the rightmost pixel. Also, x/799 is zero on the left. An inversion would be simple, just replace x/799 by (799-x)/799. Also note tha

            B Offline
            B Offline
            Bradml
            wrote on last edited by
            #5

            Thank you very much for this, it is fantastic advise.


            Brad Australian - peterchen on "Who has the worst keyboard" Keyboard? Ha! I throw magnets over the RAM chips!

            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