Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Using createScaledBitmap, using a scaled matrix and calling createBit… #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blinkmacalahan
Copy link

@blinkmacalahan blinkmacalahan commented Apr 28, 2016

…map, and other methods involving scale always caused bad looking images. Using inSampleSize while decoding resulted in much better looking images. The only downside to using it is that you cannot get an exact dimension. This is because isSampleSize must be a power of 2. So if you aren't picky about the exact dimension of your final scaled image and want better quality, you can use withScaleMethod and specify BETTER_QUALITY_BEST_FIT. The default uses the traditional method.

I've attached two files. The file called matrixScaled.jpg is done with what the library originally does and sampleSizeDecoding.jpg in an image using my proposed code.
matrixscale
samplesizedecoding

…map, and other methods involving scale always caused bad looking images. Using inSampleSize while decoding resulted in much better looking images. The only downside to using it is that you cannot get an exact dimension. This is because isSampleSize must be a power of 2. So if you aren't picky about the exact dimension of your final scaled image and want better quality, you can use withScaleMethod and specify BETTER_QUALITY_BEST_FIT. The default uses the traditional method.
@Lawgrin
Copy link

Lawgrin commented Apr 28, 2016

How did you get around travis? i keep getting lint errors

@blinkmacalahan
Copy link
Author

@Lawgrin, um I don't know. I made a fork a few hours ago and made my code changes, committed, and then creating a pull request. Nothing special.

@Lawgrin
Copy link

Lawgrin commented Apr 28, 2016

@blinkmacalahan OK i obviously made to many changes on mine for it to just take it. Thnx

matrix.postScale((float) outWidth / rect.width(), (float) outHeight / rect.height());
croppedImage = Bitmap.createBitmap(croppedImage, 0, 0, croppedImage.getWidth(), croppedImage.getHeight(), matrix, true);
BitmapFactory.Options options = new BitmapFactory.Options();
if ((rect.width() > outWidth || rect.height() > outHeight)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outer parenthesis is redundant 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants