Monday, April 2, 2012

Re: [android-developers] Re: How to set the bitmap to Transparent

Are you sure that it is the bitmap that has the black background?  How are you using the bitmap?  Is it the background or foreground of an ImageView?

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Mon, Apr 2, 2012 at 10:33 AM, Perry <perrypkk@gmail.com> wrote:
hi,
thank you for help. but the background still black.

On 4月3日, 上午12時05分, Justin Anderson <magouyaw...@gmail.com> wrote:
> First, you should use ARGB_8888... ARGB_4444 is deprecated:http://developer.android.com/reference/android/graphics/Bitmap.Config...
>
> Next, here is how to do it:
>
> temp = Bitmap.createBitmap(thisWidth, thisHeight, Config.ARGB_8888);
>
> //Clear the canvas
> Canvas canvas = new Canvas(temp);
>
> Paint transPainter = new Paint();
> transPainter.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
>
> canvas.DrawRect(0, 0, temp.Width, temp.Height, transPainter);
>
> Hope that helps...
>
> Thanks,
> Justin Anderson
> MagouyaWare Developerhttp://sites.google.com/site/magouyaware
>
>
>
> On Mon, Apr 2, 2012 at 9:54 AM, Perry <perry...@gmail.com> wrote:
> > hi,
>
> > I used following method to create a canvas.
>
> > temp = Bitmap.createBitmap(thisWidth, thisHeight, Config.ARGB_4444);
> > Canvas thisCanvas = new Canvas(temp);
>
> > I don't know why the canvas has a black background. How to create a
> > Transparent background for use?
>
> > Thanks a lot!
>
> > --
> > 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+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment