If you follow my example you can add the colors by adding the components and then recombining them into a color int.
int r = Color.red(bitmap1) + Color.red(bitmap2); int g = Color.green(bitmap1) + Color.green(bitmap2); int b = Color.blue(bitmap1) + Color.blue(bitmap2); int newPixel = Color.argb( 1, r, g, b); I think one of the PorterDuffXfermodes is for adding also. That would probably be faster. On Mar 16, 11:26 pm, Nithin <nithin.war...@gmail.com> wrote: > Thanks for all replies.. By merge I mean adding, one image with > another. > > Nithin > > On Mar 16, 6:28 pm, Warren <warrenba...@gmail.com> wrote: > > > I use something like the following function. It really depends what > > you mean by "merge". Do you mean average, alpha over, multiply, add, > > etc.? > > Anyway, you can change the arithmetic here to suit your needs. The > > important parts are that you copy the bitmap you wish to change so > > that you have a mutable/changeable bitmap, and that you call > > setPixel() to change the bitmap pixels to their new color. > > > In this example, I'm looping over all the pixels and assuming both > > bitmaps are the same size. > > > You can also do this with a canvas, but this approach is the most > > flexible. It is not terribly fast. I only use it at the startup of my > > program. But unless you are calling it repeatedly, it shouldn't slow > > you down too much. > > > private static Bitmap applyMask(Bitmap tileBitmap, Bitmap > > maskBitmap) > > { > > Bitmap workingBitmap = tileBitmap.copy(bitmapConfig, true); > > // > > IMPORTANT > > int width = tileBitmap.getWidth(); > > int height = tileBitmap.getHeight(); > > for(int x=0; x<width; x++){ > > for(int y=0; y<height; y++){ > > int maskPixel = maskBitmap.getPixel(x, y); > > int tilePixel = tileBitmap.getPixel(x, y); > > > //change this line for different color > > mixing types > > int newPixel = Color.argb( > > Color.red(maskPixel), > > Color.red(tilePixel), Color.green(tilePixel), Color.blue(tilePixel)); > > > workingBitmap.setPixel(x, y, newPixel); > > //IMPORTANT > > } > > } > > return workingBitmap; > > } > > > On Mar 16, 1:08 am, NapoleonLiu <liuwa...@neusoft.com> wrote: > > > > I am a new one in UI coding. So may be my way is not the best.. > > > > Panit mPaint = new Paint(); > > > mPaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); > > > mPaint.setAlpha(XX); > > > notice that Mode.DST_IN is important(Better to see it's api-doc.) > > > Use this paint to draw a "ALPHA_8" bitmap on your org bitmap ,then you can > > > get a Bitmap which have special alpha. > > > So you can get two special alpha bitmap ,then draw them with Mode.DST_IN. > > > I think you will get you want. > > > But there must be a nice way, to do a calculation on the alpha area of > > > bitmap. > > > hope it can help you. > > > > On Tue, 16 Mar 2010 13:20:01 +0800, BobG <bobgard...@aol.com> wrote: > > > > How about set the Alpha channel in each one to 50% so they are both > > > > half see through? > > > > --------------------------------------------------------------------------------------------------- > > > Confidentiality Notice: The information contained in this e-mail and any > > > accompanying attachment(s) > > > is intended only for the use of the intended recipient and may be > > > confidential and/or privileged of > > > Neusoft Corporation, its subsidiaries and/or its affiliates. If any > > > reader of this communication is > > > not the intended recipient, unauthorized use, forwarding, printing, > > > storing, disclosure or copying > > > is strictly prohibited, and may be unlawful.If you have received this > > > communication in error,please > > > immediately notify the sender by return e-mail, and delete the original > > > message and all copies from > > > your system. Thank you. > > > --------------------------------------------------------------------------------------------------- -- 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