Thanks for the quick response and sorry for the unneccesary use of the word bug.
I was clearly confused wrrt signed ints and 'unsigned' bytes (the values shown in the eclipse debugger), all cleared up now! Cheers, Gav On Fri, May 22, 2009 at 9:43 PM, Romain Guy <romain...@google.com> wrote: > > Bytes are signed in Java, so 137 is not what you want. Also, > Color.rgb() take ints, not bytes. So (byte) 137 cast as an int results > in rg == -119. > > On Fri, May 22, 2009 at 1:09 PM, Gavin Aiken <gavin.ai...@imperial.ac.uk> > wrote: > > Hey all, > > > > Before I submit this I just wanted to check it's not a java nuiance. > > > > The Color class can be used to extract rgb values from a pixel (32 bit > int). > > > > I implemented a lookup table filter and used a byte to store each > individual > > r g & b value to save a bit of space. > > > > Long story short; > > > > public void testColor(){ > > > > int nr = (byte)0; // Simulation of lookup in array of byte values > > representing individual bands > > int ng = (byte)0; > > int nb = (byte)0; > > int nc = Color.rgb(nr, ng, nb); > > > > assertEquals(nr,Color.red(nc)); > > assertEquals(ng,Color.green(nc)); > > assertEquals(ng,Color.blue(nc)); > > > > nr = (byte)0; > > ng = (byte)137; > > nb = (byte)0; > > nc = Color.rgb(nr, ng, nb); > > > > assertEquals(nr,Color.red(nc)); // FAIL HERE > > assertEquals(ng,Color.green(nc)); > > assertEquals(nb,Color.blue(nc)); > > } > > > > Failure in testColor: > > junit.framework.AssertionFailedError: expected:<0> but was:<255> > > at > uk.ac.ic.doc.gea05.miffed.os.ColorTest.testColor(ColorTest.java:44) > > > > > > Any ideas? > > > > 137 is the magic number causing the error in my case, there may be more. > > > > > > Cheers! > > > > Gav > > > > > > > > > > > > > > > > > -- > Romain Guy > Android framework engineer > romain...@android.com > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---