I'm using ZoomableImageView https://github.com/jsibbold/zoomage/blob/master/zoomage/src/main/java/com/jsibbold/zoomage/ZoomageView.java.
And everything works fine.
But I have a problem. Suppose I setImageBitmap, and I scaled my picture, I did not reset the scale and at the same time I set a different bitmap in my view. Thus, my new bitmap scales the same as the previous one, although I expected that it would initially be the default state. Is it possible to reset the bitmap to its original state when installing a new bitmap without applying scaling?
Related
I need to to turn the actual values of the pixels of a Bitmap into greyscale.
I've found solutions where it adds a filter like here
The problem is: it just changes it on the screen for viewing while keeping it as is. I need to change the actual bitmap to work on the pixels later and saving.
I tried to read about the color theory but got lost more
What im trying to do is to save an edited bitmap that is composed by 2 bitmaps overlayed. My application allows the user to draw on top of a picture and save it.
My problem is: when i save the result image, it gets smaller, even setting the quality to 100. So, if the user saves and edit the image multiple times, the image will get smaller and smaller.
I save the bitmap with this:
result.compress(Bitmap.CompressFormat.JPEG, 100, fos);
I debugged the code, and at this point the width and height are fine, but after saving, the image shrinks.
I've researched for questions about this, but the ones i've found had no answers that could help me.
What i need is a way to save a bitmap without shrinking it, but i need it to be in image format, like JPG, PNG, etc.
Thanks in advance.
I guess is not at the time when you are saving the image, the issue is when you are editing the image (creating layers). Check that mechanism, maybe you are setting the image size there.
There are a lot of examples how to use ViewPager as an image slider, but I haven't seen any that handle the problem of correctly rotated images:
Now actually I have a solution for this, but the problem is that the image sliding is painfully slow when the image size is over about 3000*1500 pixel because of the extra rotation step:
The ImageView itself doesn't care about the correct orientation when setting an image via
setImageURI or setImageBitmap.
This means you first have to find out the correct orientation yourself and then eventually do a
matrix.postRotate(rotation)
and create a new bitmap using
Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(),
srcBitmap.getHeight(), matrix, true);
This additional bitmap creation really slows it down.
If the was a method to load an image "rotated on the fly" ? Sth. like BitmapFactory.decodeStream(stream,matrix) ?
I have also tried to increase the ViewPager.setOffscreenPageLimit value to 3, but with
the result of "java.lang.OutofMemoryError: bitmap size exceeds VM budget" errors.
Somehow it must be possible because with the default "Gallery" app the sliding is really fast even with very large images...But I guess this not a trivial task ?
Finally I found the solution: to get a responsive, fast & fluid image sliding behaviour two things need to be done:
Do the bitmap loading in the background using AsyncTask
https://developer.android.com/training/displaying-bitmaps/process-bitmap.html
Load a downsampled version of the bitmap using BitmapFactory.Options.inSampleSize (calculated using the ratio between ViewPager's and the Bitmap's dimensions)
https://developer.android.com/training/displaying-bitmaps/load-bitmap.html
For my application I need to load a bitmap which sometimes can be really large. I'm getting OutOfMemory errors even on devices like galaxy S2. I searched around and found that I need to recycle the bitmap.
Previously I was loading the bitmap with BitmapFactory, creating a new scaled bitmap, and creating a bitmapdrawable all in one line. By doing this am I loading two bitmaps into memory? Should I create the initial bitmap and then recycle it after creating the scaled bitmap?
If the activity will be launched frequently should I load the bitmap once to a static field or should I recycle and recreate every time?
Thanks
Split the process into multiple steps. If you are measuring the bitmap against the available screen space and then loading a scaled bitmap, you can do the first step without loading the bitmap into memory using BitmapFactory.Options.inJustDecodeBounds. This will give you a Bitmap object without the pixel data but with the width and height properties. Then use that to decode your scaled bitmap using BitmapFactory.Options.inSampleSize.
Google these terms and you'll find tons of sample code doing just this. And yes, don't forget to recycle when you're done with a Bitmap.
https://www.google.com/#q=BitmapFactory+Options+inJustDecodeBounds+inSampleSize
I have successfully included RemoteControlClient in my app. However, I was wondering if there is any way to prevent the bitmaps thrown at it from scaling On all aspects. I can do this in my activity, scaling the vertical, and preserving the aspect , but throwing the scaled bitmap to the client has no effect. It always scales to square, filling the view.
Any suggestions?
I guess, create a black (or transparent?) square bitmap background and center your album artwork or whatever it is on it... Then send a square image to RemoteControlClient.