Francesco Scarfato <[EMAIL PROTECTED]> wrote: > hello everybody, i've a trouble with getPixel. > if fill the stage with shapes that have the follow color > > rgb(255, 000, 000) --> red > rgb(000, 255, 000) --> green > rgb(000, 000, 255) --> blu > > than i copy some shapes on the stage with fill (o simple drag on the stage > cast member that have these parameters). > when i try to read the color of pixel on the stage with getPixel, as in > follow > > on mouseUp > put (the stage).image.getPixel(the mouseLoc) > end > > i've these result > > instead of rgb(255, 000, 000) getPixel return rgb(248, 000, 000) > " rgb(000, 255, 000) " " rgb(000, 248, 000) > " rgb(000, 000, 255) " " rgb(000, 000, 248) > > and so on for every pure colors likes rgb(255, 255, 000) even rgb (255, 255, > 255) --> white is return as rgb(248, 248, 248) > > someone have a solution?
Hi Francesco, My guess is that your monitor is set to 16-bit (High Color or Thousands of Colors). In 16-bit mode, each color is coded as 5 bits of red data, 5 bits of green data and 5 bits of blue data, plus 1 unused bit: arrrrrgggggbbbbb This means that you can have values between 0 and 31 (32 values in all) for each color channel. In 24- and 32-bit depth, can have values between 0 and 255 (256 values in all) for each color channel. How big is the gap between each channel value in 16-bit color? Not 256 / 32 but 255. / 31, or 8.2258... (Think about it). As you may already know, computer processors work fast when performing calculations in powers of 2 (2, 4, 8, 16, 32, ... 256, and so on). On the other hand, floating point calculations, such as multiplying by 8.2258... are much slower. As a result, when Director expresses a 16-bit color in its rgb() format (which is designed for 32-bits), it does so by multiplying the 16-bit values by 8: rgb16{0, 16, 31} => rgb( 0, 128, 248 ) In other words, your results are consistent with performance optimizatios for 16-bit mode. Cheers, James [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]