如何解决位图缩放而不失真

时间:2016-03-02 05:20:11

标签: android android-bitmap

执行:

private static void drawWatermark(Canvas canvas, Bitmap watermark, Paint paint{
    int canvasWidth = canvas.getWidth();
    int canvasHeight = canvas.getHeight();
    int watermarkWidth = watermark.getWidth();
    int watermarkHeight = watermark.getHeight();

    Rect src = new Rect(0, 0, watermarkWidth, watermarkHeight);
    int dstHeight = (int)(canvasHeight * 0.08f);
    int dstWidth = watermarkWidth * dstHeight / watermarkHeight;
    Rect dst = new Rect(canvasWidth - dstWidth, canvasHeight - dstHeight, canvasWidth, canvasHeight);

    canvas.drawBitmap(watermark, src, dst, paint);
}

图片很模糊。

0 个答案:

没有答案