I do some operations with my Views that scale then trough:
imageView.setScaleX(2);
imageView.setScaleY(2);
On that ImageView I put a image that is two times greater than it, as expected when the scale is 1, the Bitmap is scaled down to the view size, my question is:
When the view is scaled up, the portion of the bitmap I see is the original image or the scaled-down image scaled up.
The difference is that if a tiny image is scaled up we lost contrast on letters, if it's the original image it wont.
When you scale an image up you're loosing quality. In you're case, you're doubling the width and height therefore, for each pixel you get 4 pixels assigned to it. The extra 3 pixels won't give you the quality you wanted.
If you want to go back to the original size you should decode the source again. This way you'll get the quality you're looking for.
Related
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.
I want to cut a piece of an Image with a fixed aspect ratio.
The user can choose the area which should be cutted out within a WYSIWYG view.
The final output should be a bitmap with fixed resolution (1300px * 1000px).
The aspect ratio of the WYSIWYG view and the output bitmap is the same.
Preview Image
Simple solution would be upscale the bitmap from the WYSIWYG view to output resolution (would work because aspect ratio is the same) but i want to cut the choosen area from the original input bitmap.
I think the cropper: Cropper is doing the same
How to do that ?
The question is this: I have a picture I want to use it in a costum view, so I have to use the Preparebitmap methode where I have to specify the picutres which I want to draw and the Width/Height that the picture will take.
I created the image for all the sizes, I mean there's the same picture with different resulotion (I placed them in the drawable folders (ldpi, mdpi...)); so the main question is how to draw the bitmap to be shown perfectly with all the screen, maybe the following example will clear my problem:
appLogo = prepareBitmap(getResources().getDrawable(R.drawable.applogo), 100, 100);
the bitmap will be drawn in 100X100 space, so in bigger screens, the image will be small, even if it exist in the xx-hdpi folder. Is there any way how to get the real size of the image whatever the screen was ? I want something like:
appLogo = prepareBitmap(getResources().getDrawable(R.drawable.applogo), Height, Width);
with Height/Width are the real Height/Width of the image.
Thank you
I have an activity which only has an ImageView on it. I'm setting an image bitmap for this view that is much taller than wider. So, for example, my activity has 720x950 and my image is 918x2077.
When I add the image in the imageView, both side parts of imageView stays white (read: no image in there).
If I call mImage.getWidth() it returns me the width of the entire imageView of 720 (which is the activity wide).
I would like to get the width of the image in specific, not of the view.. is that possible?
It sounds like the aspect ratio of your image is being kept. You want to know how much width the image is actually occupying.
You can calculate it!
if your bitmap is 918x2077 and your window size is 720x950, then to calculate your width, simply do:
(950/2077) * 918 = 419.8844...
Hope this helps :)
I am trying to get my images to appear in my image view so that if an image is say 600x400 and my image view is 200x200 that the image is scaled to 300x200 and then the extra width is cropped out so that the image appears as a 200x200 image. I have played with the various ScaleTypes but i can't find one that suits what i want. I want something like a combo of ScaleType.FIT_XY and ScaleType.CENTER_CROP
What you need to do is to scale down the image using the inSampleSize as shown here:
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
and then use ScaleType.CENTER_CROP to show the image in the view.