Mike, Thanks for the explanation. Is there a way (method that I could call) that I can convert the raw bitmap to the multiplied version because doing the setPixel?
Thanks, Kurt On Tue, Sep 23, 2008 at 11:34 AM, Mike Reed <[EMAIL PROTECTED]> wrote: > > The confusion (and I will try to update the dox to make this clearer) > is that the color int is in unpremultipled form, but the internal > format for Bitmap pixels is premultiplied. > > "premultiplied" means that the r,g,b components have already been > multiplied by their respective alpha value. Thus 50% transparent Red > would be stored as 0x80800000 > > "unpremultipled" means that the r,g,b components are stored in their > raw form, independent of the alpha value. Thus 50% transparent Red > would be stored as 0x80FF0000 > > Thus when you specify 0x08040201 in unpremultiplied form (as you > should for the input to setPixels), that color is internally converted > to its premultiplied equivalent, which in this case happens to be > 0x08000000. When you call getPixels(), the values are converted back > to unpremultiplied form automatically, but in this case there is no > change. > > mike > > On Sep 23, 2008, at 10:40 AM, JakeMaui wrote: > > > I have a bitmap issue. I created a simple PNG that was 1 pixel high, > 16 wide pure white. > I loaded the bitmap, extracted the pixels, changed the first one and > then created a bitmap > from the altered data. The issue is that I thought that until I save > it, I would have a raw bitmap will all the bits set as I had set > them. I found that the bits changed. > Does anybody know what I need to do to preserve the bitmap with the > bits that I set > into it? > > sample code ... > int picw= bitmap.getWidth(); > int pich=bitmap.getHeight(); > int[] pix = new int[picw*pich]; > bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich); > > // It's pure white at this point. > // I set the first byte to this but when I pull it out of the newly > constructed > // bitmap, it's 0x8000000 > pix[0]=0x08040201; > createdBitmap = Bitmap.createBitmap(picw, pich, > Bitmap.Config.ARGB_8888); > createdBitmap.setPixels(pix, 0, picw, 0, 0, picw, pich); > > // get pixels of newly created bitmap > int picw= embeddedBitmap.getWidth(); > int pich=embeddedBitmap.getHeight(); > int[] pix = new int[picw*pich]; > createdBitmap.getPixels(pix, 0, picw, 0, 0, picw, pich); > > Results .... > 00001000 00000100 00000010 00000001 before > 00001000 00000000 00000000 0000000 > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---