第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

調(diào)整大小/縮放位圖后圖像質(zhì)量不佳

調(diào)整大小/縮放位圖后圖像質(zhì)量不佳

喵喵時(shí)光機(jī) 2019-08-26 14:35:25
調(diào)整大小/縮放位圖后圖像質(zhì)量不佳我正在寫一個(gè)紙牌游戲,需要我的卡在不同的情況下有不同的尺寸。我將我的圖像存儲(chǔ)為位圖,以便可以快速繪制和重繪(用于動(dòng)畫)。我的問題是,無(wú)論我如何嘗試和縮放我的圖像(無(wú)論是通過matrix.postScale,matrix.preScale還是createScaledBitmap函數(shù)),它們總是出現(xiàn)像素化和模糊。我知道它導(dǎo)致問題的縮放因?yàn)樵跊]有調(diào)整大小的情況下繪制時(shí)圖像看起來很完美。但還是沒有到達(dá)任何地方。我用這段代碼存儲(chǔ)我的位圖(到一個(gè)hashmap):cardImages = new HashMap<Byte, Bitmap>();cardImages.put(GameUtil.hearts_ace, BitmapFactory.decodeResource(r, R.drawable.hearts_ace));并使用此方法繪制它們(在Card類中):public void drawCard(Canvas c){     //retrieve the cards image (if it doesn't already have one)     if (image == null)         image = Bitmap.createScaledBitmap(GameUtil.cardImages.get(ID),              (int)(GameUtil.standardCardSize.X*scale), (int)(GameUtil.standardCardSize.Y*scale), false);         //this code (non-scaled) looks perfect         //image = GameUtil.cardImages.get(ID);     matrix.reset();     matrix.setTranslate(position.X, position.Y);     //These methods make it look worse     //matrix.preScale(1.3f, 1.3f);     //matrix.postScale(1.3f, 1.3f);     //This code makes absolutely no difference     Paint drawPaint = new Paint();     drawPaint.setAntiAlias(false);     drawPaint.setFilterBitmap(false);     drawPaint.setDither(true);     c.drawBitmap(image, matrix, drawPaint);}任何見解將不勝感激。謝謝
查看完整描述

3 回答

?
不負(fù)相思意

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超10個(gè)贊

我在低屏幕分辨率下有blury圖像,直到我禁用了來自資源的位圖加載縮放:

Options options = new BitmapFactory.Options();
    options.inScaled = false;
    Bitmap source = BitmapFactory.decodeResource(a.getResources(), path, options);


查看完整回答
反對(duì) 回復(fù) 2019-08-26
?
千巷貓影

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

使用createScaledBitmap會(huì)使您的圖像看起來非常糟糕。我遇到了這個(gè)問題,我已經(jīng)解決了。下面的代碼將解決問題:

public Bitmap BITMAP_RESIZER(Bitmap bitmap,int newWidth,int newHeight) {    
    Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Config.ARGB_8888);

    float ratioX = newWidth / (float) bitmap.getWidth();
    float ratioY = newHeight / (float) bitmap.getHeight();
    float middleX = newWidth / 2.0f;
    float middleY = newHeight / 2.0f;

    Matrix scaleMatrix = new Matrix();
    scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);

    Canvas canvas = new Canvas(scaledBitmap);
    canvas.setMatrix(scaleMatrix);
    canvas.drawBitmap(bitmap, middleX - bitmap.getWidth() / 2, middleY - bitmap.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));

    return scaledBitmap;

    }


查看完整回答
反對(duì) 回復(fù) 2019-08-26
?
慕妹3146593

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超9個(gè)贊

createScaledBitmap有一個(gè)標(biāo)志,您可以設(shè)置是否應(yīng)過濾縮放的圖像。那個(gè)標(biāo)志改善了位圖的質(zhì)量......


查看完整回答
反對(duì) 回復(fù) 2019-08-26
  • 3 回答
  • 0 關(guān)注
  • 475 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)