Images size issue in UpdateTexture - android

I'm Trying to update the TextureRegion for a sprite dynamically.Following UpdateTextureExample
But the images that I have to replace with are different in size. Is there a work around for this??
The image replaced is stretched out, as the previous image was bigger in size!!

Related

ImageView image size

As far as I know, if image is too big, it can't be displayed in some fixed size ImageView. My question is how can I find out maximum size of image that can be displayed if I know width and height of ImageView.
Android can display bitmaps up to 2048x2048 pixels. It dependents on OpenGL implementation.
But the main issue with big images is a insufficient memory problem. Big images takes more memory and leads to OutOfMemoryError and app crash.
The best way is scale image before displaying to ImageView size. There is a lot of image loading frameworks that can help you. For example Fresco, Glide

Resize an image to square resolution

I am developing an android application which resizes android pictures. I was wondering if its possible to resize a file with resolution (1080X1920) to (500X500) square size.
Without looking too bad (quality and dimensions).
Let me show you an example.
First image:
Resized picture:
Answers using code will be appreciated
If you don't want to distort the image you have two options:
Crop the image
Implement the seam carving algorithm
Edit: this assumes you want to fill up the whole square. If not, just keep the width/height ratio and downscale the image properly so that the largest dimension fits in the side of the square.

Loading images into big size imageviews

I know that ,according to android docs, that if you have a big image. Then you scale it down to size of the image view you are loading it to (using the decodeResources and Options class).
Now my question is, lets say you want to load background picture and the source image is of similar size, do you just load the image? Or do you actually scale it down a bit and then using the FITXY to stretch it?
I am trying to avoid Out Of Memory exceptions here
Thank you

Scaling image without losing quality

Is it possible to scale image without loosing its quality?I have seen posts that say to use Ninepatch images but how can we download an image and convert it to ninepatch image so that i can show it in ImageView.
Is there any other way so that my images with smaller size can be scaled like in whats app
Everytime you scale an image it's losing quality, the only thing you can do to keep the quality is keeping a copy of the original image (which doesn't make much sense since you can just load it again from resources).
If you mean the problem was that android was scaling your images (and changing the quality) you can put images on a folder named "raw" inside res.
Ninepatch images can be made manually by you, you just paint an image that has two extra pixels on width and two on height, and when you save it , name it something.9.png
if you want to know how to draw them correctly follow this: http://developer.android.com/tools/help/draw9patch.html

How to prevent pixels from blending when enlarging images in ImageViews Android

I want to use 16x16 images and blow them up without the pixels blending in Android. I understand it will be very pixel-looking (that's what I want). How can I enlarge an image while keeping the pixel look intact?
Just make sure that before you import the image, it is already the size that you wanted so that if you use it on your image view, the quality of image will stay the same.
i have had the same problem
how to load image as pixel image in android java?
here is how i solved it
width of the pixel square =
width of the screen / num of pixels

Categories

Resources