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
Related
I have png images that have drop shadow. There is no unproportional images scaling problem, scaling are according to the aspect ratio.
When I using Image.asset() for placing images on phone screen, they're and their shadows looks low quality and not soft.
Original image looks: http://prnt.sc/p93vo2
Image on Android App: https://prnt.sc/p93vz3
Example images are same and 700x400, 96dpi.
You should see quality difference between images.
There is also a strange stuation. The shadow density on right and bottom side is more than shadow of original image on android app.
I've tried FilterQuality.high but no change, how to fix it?
In my case, the problem was due to a bad configuration of the image resolution system.
Full answer SO: Images loose quality when using image.asset in flutter
.
I am saving three imageviews to one bitmap after the user edits the image(s). The problem is that once the final result is saved, the resulting saved image doesn't always look the same on different screen resolutions.
On my phone, which is a Asus Padfone X, the saved image comes out perfectly. On my partners phone, Note 6, the positioning of the saved images on the resulting bitmap are off. (See example below)
I am using the following code to save the imageviews to a single image:
Bitmap mainBmp = backImage.getDrawingCache();
Bitmap centerBmp = centerImage.getDrawingCache();
Bitmap handleBmp = handleImage.getDrawingCache();
Canvas canvas = new Canvas(mainBmp);
canvas.drawBitmap(centerBmp, 17, 95, null);
canvas.drawBitmap(handleBmp, 17, 85, null);
Which saves properly on my phone but not one with a bigger screen/higher resolution. How do I ensure the resulting saved image looks the same regardless of the device it is saved on?
EXAMPLE OF DIFFERENCE
You need to scale. For example, lets say that device 1 is 500x1000 pixels and device 2 is 600x1200. Lets say the bitmap is 300x400 and starts at an offset of 30 pixels in x and 100 in y.
The bitmap needs to grow in size by the ratio of the two screens sizes. So it would need to be 300*(600/500) pixels wide and 400*(1200/1000) pixels big. The offset would need to scale as well- to 30*(600/500) and 100*(1200/1000).
Please note that when scaling you may get stretching, pixelation, and other image defects. The more you stretch the worse it will be. Shrinking can also give defects, but these tend to be more minor.
This is the simple case- the two screens I gave have the same aspect ratio (ratio of width:height). In the case of different aspect ratios, you need to choose:
1)Keep the aspect ratio of the image the same. This will mean you'll have blank space in 1 direction, but the image won't be effected.
2)Allow the aspect ratio of the image to change. This will leave no blank space, but will skew the image.
For #2, use the same code as above. For #1, figure out which dimension needs to scale the least, and use that to scale x and y.
It is not possible to scale from any size phone to any size phone without any defects on a generic image. You'll have to choose between the two options above.
I also found that if I instead use imageview.getWidth() and imageview.getHeight(), I can position each "layer" where I need it to be no matter the screen size. I tested this method on a small android device all the way up to a tablet and the saved image came out perfect across all devices.
What I did was determine the pixel size of each image("layer") using Photoshop. I then used an online px to dp calculator/converter to determine the correct dp size of each layer. I set specific dp width and height for each layer in the layout. For each layer I needed to save to the main image, I calculated the x and y dimensions by taking the mainimageviews height and width and subtracting the pixels needed from the edge to the respective edge of that layer. Through trial and error, I ran the app a few times to get the exact positioning of each layer I wanted. The result of the saved image was exactly the way it looked to the user. Hope this helps someone else in the future.
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.
App has a ViewPager with several Fragment in it.
When user scrolls to the end of pages, there's this Android gradient effect that indicates there's no more pages (instead of iOS's bounce effect).
When this effect occurs, apps become unresponsive and frames are dropped, while in the log there these lines -
Trying to scale down bitmap for texture (2560x4544 -> 2307x4096)
Scaled bitmap has been successfully created
There's no bitmap in the app of this size and it's running on a QHD (1440 x 2560 pixels) LG G3 display, so I guess some bitmap is scaled up to fit this xxxhdpi resolution, then for some reason scaled down a bit.
Question is - why is it trying to scale down a bitmap when this effect occurs? Can this be avoided?
Is it the gradient effect rendering that is being scaled down?
It stopped when I turned off the over scroll effect (iOS's bounce equivalent). Maybe this effect is an image that's resized before shown, though I don't understand why they don't cache it, if it's true.
viewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
The problem is with loading some image in your page:
Solutions:
1. if you must load the image use a library named Picasso http://square.github.io/picasso/ to load it
2. if the image is a shape try to make the shape yourself in android.
At all costs avoid loading big images in the xml. even in the newest phones this has a big impact on performance.
As part of this application I am making, I want to change my wallpaper on my android device based on a bitmap that the user has selected.
I am able to change the background. However, the background is a completely distorted version of the bitmap. Any idea as to why this would happen?Here is my code:
Bitmap bitmap = ((BitmapDrawable)currentDrawable).getBitmap();
this.setWallpaper(bitmap);
My bitmap has a width of 240px and height of 180px. My emulator is of a size 480px by 800px.
I can scale my bitmap to 480px. However, the bitmap still ends up being distorted on the android wallpaper. Any thoughts on how this can be fixed?
Thanks in advance
You should create multiple images, for each potential (and common) resolution. You don't want any scaling, or the image will be distorted.
UPDATE:
Here is a ton of good information on support multiple screen sizes:
http://developer.android.com/guide/practices/screens_support.html
The wallpaper used by the default Launcher is bigger than the actual screen, that's why you can scroll the content and the wallpaper too.