Problem with image scaling
See original GitHub issueI came across two problems while working with the library:
- If the image is bigger than the max OpenGL texture size(which is different depending on the device), the image won’t be shown. I had this problem before when trying to display a large image in an ImageView. This is less a problem with the library but with Android itself, but nonetheless the library could handle that. My solution was to simply scale the image down to 2048px, this should work on most devices.
public static Bitmap transformBitmapTo2048px(Bitmap source){
if(source.getHeight() <= 2048 && source.getWidth() <= 2048)
return source;
int targetWidth;
int targetHeight;
double aspectRatio = (double) source.getHeight() / (double) source.getWidth();
if(source.getWidth() >= source.getHeight()){
targetWidth = 2048;
targetHeight = (int)(2048 * aspectRatio);
} else {
targetHeight = 2048;
targetWidth = (int)(2048 / aspectRatio);
}
Bitmap result = Bitmap.createScaledBitmap(source, targetWidth, targetHeight, false);
if (result != source) {
// Same bitmap is returned if sizes are the same
source.recycle();
}
return result;
}
- The current implementation for editing an image works basically by doing the image processing on the screen and the taking the contents of that to save the image. The problem with that is that the image get scaled down, possibly a lot. For example, if you have a picture in landscape, it will be scaled down quite a lot to fit into the ImageView. In my case, the PhotoEditorView fits the whole screen, so if I save the image, it will be exactly the size of my screen, and the actual (landscape) image is only a small part of that image. The correct approach would be to have an internal representation of the image and do all the processing on that. This would allow to keep the original size of the image (you can still show the image scaled down to fix problem 1).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:17 (5 by maintainers)
Top Results From Across the Web
NIS (NVIDIA Image Scaling) Not Working? Here's How to Fix It
NIS (NVIDIA Image Scaling) Not Working? Here's How to Fix It · First things first, start by ensuring that the game you're having...
Read more >NVIDIA Image Scaling not showing or working in Windows 11/10
In this article, we will see some possible fixes to resolve this problem. NVIDIA Image Scaling not showing or working.
Read more >How to Enable NVIDIA Image Scaling
NVIDIA Image Scaling is a driver-based spatial upscaler and sharpener for GeForce GPUs for all games. This feature is accessible both from ...
Read more >Nvidia Image Scaling have some problem - Linus Tech Tips
I have 1080 monitor and those are my resolutions in Geforce Experience at Scaling (photo) and i think because of that my image...
Read more >Nvidia Image Scaling not showing up in control panel. - Reddit
My laptop has a 1050ti. It also has optimus which might be the reason for this. Anyone else have this problem? I has...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hi @burhanrashid52 i’ve done some quick combination between your project and https://github.com/siwangqishiq/ImageEditor-Android so that i can save a big resolution image with stickers. Check it out at: https://github.com/fandygotama-tokobagus/PhotoEditor, please note that this is not 100% done as the project still missing some feature like e.g.: undo/redo brush, typeface and other things 😃
this worked for me https://github.com/tauseefrehman2/pinch-to-zoom-linear-layout (when using a big image it puts it half of screen for some reason though, and when zooming if you release the finger you touched the screen first with first it jumps cuz it mixes up your fingers or something so if anyone knows how to fix that that would be great) edit: i changed a few things and now it works perfectly