简体   繁体   English

creatScaled位图质量低

[英]creatScaled Bitmap low quality

hello guys i'm having a problem with scaling an image to square size. 大家好,我在将图片缩放到正方形时遇到问题。 612 * 612 612 * 612

first i'm getting the image as cache from the imageview and then i'm converting it to Bitmap image. 首先,我从imageview获取图像作为缓存,然后将其转换为Bitmap图像。

    view.setDrawingCacheEnabled(true);
    view.buildDrawingCache();
    save = view.getDrawingCache();

then i'm using Bitmap.createScaledBitmap as below 然后我正在使用Bitmap.createScaledBitmap如下

     Bitmap a = Bitmap.createScaledBitmap(save, 612, 612, true);

it works as i want it but when the image scaled it lose its quality 它按我想要的方式工作,但是当图像缩放时会失去质量

here is how i compress the image to save it / share it 这是我compress图像以保存/共享的方式

        a.compress(Bitmap.CompressFormat.PNG, 100, out);

i'm sharing it through my application to Instagram to fit inside instagram cropping tool but the image always will be low quality. 我通过我的应用程序将其共享到Instagram,以适合instagram裁剪工具,但图像始终是低质量的。 can anyone tell me how do i scale / resize the image dimension without losing its quality or to fit inside instagram cropping tool without losing quality. 谁能告诉我如何在不损失图像质量的情况下缩放图像尺寸或调整其尺寸,或者如何在不损失质量的情况下放入instagram裁剪工具。 thanks 谢谢

If you scale the bitmap you lose quality as well . 如果缩放位图,那么质量也会下降。 what i prefer You can use BitmapFactory 我更喜欢你可以使用BitmapFactory

BitmapFactory.Options option = new BitmapFactory.Options();
        option.inJustDecodeBounds = true;

        option.inSampleSize = 4;
Bitmap bm = BitmapFactory.decodeFile(root.getPath() + "/" + imageName, option);

refer below links for more details 请参阅下面的链接以获取更多详细信息

this this this this 这个 这个 这个 这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM