I was expecting to find a way to handle sprites with a color-keyed background but I haven't found a way. This is certainly on my wish list for future SDKs.
There is AvoidXfermode but it does the opposite of what we want, keying off of a color on the destination instead of on the source. I've had to work around this missing feature by using sprites with an alpha channel, but this has a significant impact of speed. I believe that what you are doing with a ColorFilter is actually transforming the colors of your bitmap using your specified color as the source and your bitmap as the destination in the PorterDuff calculations. The result of this color transformation is then drawn on the canvas. On Mar 2, 7:33 pm, Bill <sax...@gmail.com> wrote: > I have some 2d character sprites, with a greenish background, that I'm > trying to display, without the background. > > Since the background is a consistent color, I assumed there'd be a way > to filter it out, thereby making the background transparent. I wonder > if I'm right in assuming this... > > Here is my code: > > Drawable d = mContext.getResources().getDrawable(R.drawable.queen); > d.setColorFilter(Color.parseColor("#585C38"), PorterDuff.Mode.DST_IN); > d.setBounds(0, 0, 100, 100); > d.draw(canvas); > > I've tried all of the PorterDuff modes and none of them seem to do the > right thing. In fact, it looks like the color is ignored all > together. > > Any ideas what I might be doing wrong? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---