That's obscure enough to be intriguing -- do you
have a link to the rules Java works within on shifts?
Because the (>> 31) looks a little magical.

I will also be searching the docs....

[EMAIL PROTECTED] wrote:
if(r < 0) r = 0;
if(r > 255) r = 255;
if(g < 0) g = 0;
if(g > 255) g = 255;
if(b < 0) b = 0;
if(b > 255) b = 255;

Clumsy and awkward.  Is there a better way to clamp
the values?
Maybe with a mask or something?


If your "better" meant "faster", you might like to take a look at this:
https://jai-core.dev.java.net/source/browse/jai-core/src/share/classes/com/sun/media/jai/opimage/AddOpImage.java?rev=1.1&view=markup
under computeRectByte()

                    //
                    // The next two lines are a fast way to do
                    // an add with saturation on U8 elements.
                    // It eliminates the need to do clamping.
                    //
                    sum = (s1[s1PixelOffset]&0xFF) + (s2[s2PixelOffset]&0xFF);
                    d[dPixelOffset] = (byte)((((sum<<23) >> 31) | sum) & 0xFF);

HTH,
-James
[Message sent by forum member 'jxc' (jxc)]

http://forums.java.net/jive/thread.jspa?messageID=230881

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".



===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to