Hi,
I am trying to crop an image on a key for a soft keyboard.
i want to do the following:
1.create a key with an icon (from a Bitmap)
2.take that Bitmap and crop it
3.set the new Bitmap back on the key as an icon
Optional:
4.do some or most of this from the XML using the parser (i could not get a
hook to the res/drawable/<image name> looking at the Xml Parser)

here is what i do:

   protected Key createKeyFromXml(Resources res, Row parent, int x, int y,
            XmlResourceParser parser) {
         Key key = new MyKey(res, parent, x, y, parser);//create a normal
key
        Bitmap orgBmp = BitmapFactory.decodeResource(res,
R.drawable.sym_keyboard_delete);//i took a new hard-coded image here, but
prefer this to be coming from the xml instead, in the MyKey constructor)
        Bitmap  cropedBitmap = Bitmap.createBitmap(orgBmp, 0, 0, 20, 10);
//crop the image
        Canvas canvas = new Canvas(cropedBitmap);//put it in a canvas, since
draw() only accepts canvas
        if(key.icon!=null){ //if icon exists, draw it back on the key
            key.icon.draw(canvas);
        }
        return key;
    }

Any ideas why this does not work?
any simpler solutions for this?
Thanks,

-- 




-- 
Yaron Spektor

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

Reply via email to