Thanks, there were some helpful examples in the API Demos (I guess that's
the purpose).

For those curious, here's how I solved my problem:

    int targetWidth = 100;
    int targetHeight = 100;
    Bitmap targetBitmap = Bitmap.createBitmap(
        targetWidth,
        targetHeight,
        Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(targetBitmap);
    Path path = new Path();
    path.addCircle(
        ((float)targetWidth - 1) / 2,
        ((float)targetHeight - 1) / 2,
        (Math.min(((float)targetWidth), ((float)targetHeight)) / 2),
        Path.Direction.CCW);
    canvas.clipPath(path);
    Bitmap sourceBitmap = BitmapFactory.decodeResource(
        getResources(),
        R.drawable.my_image);
    canvas.drawBitmap(
        sourceBitmap,
        new Rect(0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight()),
        new Rect(0, 0, targetWidth, targetHeight),
        null);
    ImageView imageView = (ImageView)findViewById(R.id.my_image_view);
    imageView.setImageBitmap(targetBitmap);



On Thu, Mar 26, 2009 at 5:31 PM, clark <[email protected]> wrote:

>
> I haven't done this myself, however I know that the API Demos have an
> application demonstrating clipping.  You may want to take a look at
> that code and go from there as I noticed they have a circlular region
> displayed.
>
>
> ~clark
>
> On Mar 26, 5:26 pm, "geoff.stromberg" <[email protected]>
> wrote:
> > Hello,
> >
> > In my Java code I am setting the content of an ImageView to a Bitmap.
> > However, before doing so I want to clip the Bitmap to a circular
> > region. How would I go about this? I've been looking for some API that
> > would let me set the alpha channel of the Bitmap to fully transparent
> > for all pixels outside the circular region. Any pointers would be
> > appreciated. Thanks!
> >
>

--~--~---------~--~----~------------~-------~--~----~
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