Try following code.

               if (b1 == null) {
                       return null;
               }
               Paint p = new Paint();
               p.setAntiAlias(true);
               p.setAlpha(150);

               byte[] chunk = b1.getNinePatchChunk();

               Bitmap b2 = Bitmap.createBitmap(b1.getWidth(),
b1.getHeight(), b1.getConfig());

               Canvas canvas = new Canvas(b2);
               canvas.drawBitmap(b1, 0, 0, p);





On Mon, May 14, 2012 at 2:19 PM, viktor <[email protected]> wrote:

> Please help me with exception.
>
> I have single resources folder. /res/drawable
>
> I create a custom button from one of the resource with some color
> effect.
>
> This works for ldpi, hdpi, xdpi devices, but when I run an app on the
> mdpi device it crashes.
>
>
> My code:
>
> Bitmap b1 = BitmapFactory.decodeResource(context.getResources(),
> drawableResourceId);
>                if (b1 == null) {
>                        return null;
>                }
>                Paint p = new Paint();
>                p.setAntiAlias(true);
>                p.setAlpha(150);
>
>                byte[] chunk = b1.getNinePatchChunk();
>
>                Bitmap b2 = Bitmap.createBitmap(b1.getWidth(),
> b1.getHeight(),
> b1.getConfig());  // this line fails,
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> 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

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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

Reply via email to