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:

scaled image

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:

padding 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:

padding image

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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -