Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a new Bitmap in xml by cropping an existing image

 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In Android ApiDemos, there are examples of creating new images from existing images in xml.
For example,


Is it possible to create a new image by cropping an existing image?

- Sonny
 
Imran Mohd
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. convert the image in to Bitmap

2. Than the Crop the obtained 'bitmap'
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Imran.
But, what I am trying to find out is whether there is a way of doing that when defining a resource in the xml file in res/drawable.
Then I can use the cropped image in a layout xml.
 
pavanr ramadugula
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. You can't define a cropped image in the static xml. If you have the cropped image available, you can use it similar to any other image. To get this done at runtime, using Bitmap is the way. Hope it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic