I have an imageview where i have implemented the TouchImageView class for zoom functionality. But i'm not able to set the scaletype. I want the initial scaletype to be centercrop but i dosen't work.
When i try
img.setScaleType(ScaleType.CENTER_CROP);
the zoom functionality stops working and the image becomes center-cropped. I want both to work together.
How can i make the initial image to be center cropped that is being selected from my SDcard into an imageview with zoom functionality.
The patch for supporting scale types other than FIT_START and FIT_XY have been made. If anyone needs help with this please refer to this :
https://github.com/MikeOrtiz/TouchImageView/commit/475b552b468c1da10d6802cefaa00cf5e39b27d1
Has anyone tried this patch and the getZoomedImageFromSource() with scaleType centre crop
the bitmap it returns does not match the zoomed image.
Related
I cant scaletype for my PhotoView that lets me pan side to side on an image while being full-screen, without cropping the sides using Photo.ScaleType.CENTER_CROP. How would I go about doing this?
This is what I want (where the user can pan side to side to view the whole image):
This is what I get (when using ScaleType.CENTER_CROP, which is closest to what I'm going for but because of the CROP, doesnt allow panning side to side.):
you can use a this ImageViewZoom.
if you don't want to use lib see the codes and try to scale canvas
I fixed it by using a PhotoViewAttacher like this:
ImageView imageView = (ImageView) findViewById(R.id.preview);
PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(imageView);
photoViewAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP)
and then using an ImageView (id.preview) with the ScaleType in the XML set as Matrix. (otherwise it wont work)
Assume I have an image which is larger than an ImageView size (width and height) and the scaleType is set to CENTER or the scaleType is set to MATRIX and the bitmap is translated and scaled. Therefore parts of the image are not visible. How may I calculate the visible part of the bitmap and crop exact that part. I want to crop and store only the visible part.
How may I do that?
Any help will be appreciated.
So you want exactly what the image view shows? I'd enable the drawing cache and grab it from the view. That should be exactly what's on screen.
Hi Nicholas I've referred your answer posted here: https://stackoverflow.com/a/17649895/680488
I want to ask that how can I zoom image which has scaleType fitXY.
I am setting a imgage in an ImageView. I want to scale down the image size without reducing the imageview size. Please guide me step by step.
Use scaleType parameter for your imageviews and set the value to centerFit or centerCrop. More here: http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
Taken from this link: source
You should also see android:adjustViewBounds to make the ImageView resize itself to fit the rescaled image. For example, if you have a rectangular image in what would normally be a square ImageView, adjustViewBounds=true will make it resize the ImageView to be rectangular as well. This then affects how other Views are laid out around the ImageView.
Is there a way to set the ScaleType of a ImageView as CENTER using Matrix ScaleType?
I'm in need of Center orientation of an image in the ImageView. Problem occurs when I set the size of the ImageView larger than the screen say 1000dp. By doing so my image sticks to the corners.
If I use layout_margins, I'm not able to pinch and zoom the image properly.
Please help me find a solution.