android - Get new Bitmap of scaled and visible image -
i'm display image in custom view:
public class customimageview extends view to arrange picture user has opportunity set key fullscreen. image scaled width , height of display, maintaining aspect ratio:

in order of scaling process image wider display (in of cases). user can set focal points: coordinate has displayed centered possible. in case of picture 1 focal points x: 50% , y: 50% --> image centered. reached through
@override protected void ondraw(canvas canvas) { super.ondraw(canvas); if (bitmapdrawable != null) { bitmapdrawable.setbounds(bounds); bitmapdrawable.draw(canvas); } } the bounds contain values of scaled edges.
now tricky part:
i want add padding scaled image, ends in scaling process of scaled image:

image 2 shows undesired effect. image shrinked again, no way add left or right padding in case.
but want display shown in next picture:

i tried visible part of scaled image via getdrawingcache(). returned bitmap in fact isn't null, neither takes effect.
i thought overlay create padding, cut parts of image should displayed.
the best way scaled , visible image in new bitmap or bitmapdrawable, found no successful operation..
edit:
to make little bit more understandable, made drawing you:
padding image http://fs1.directupload.net/images/150702/wpttzjcq.png
Comments
Post a Comment