在调整图像画布 [英] Resize Images in Canvas

查看:160
本文介绍了在调整图像画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在里面ImageView的显示位图和使用Canvas。

I'm displaying a bitmap on Inside the ImageView and using the Canvas .

ImageView的:它显示整个图像没有多么大的图像,它融为一体preSS的ImageView的宽度/高度内的位图

ImageView : it display the whole image not matter how large the image, it compress bitmap within the width/height of Imageview.

画布:画布绘制位图,但如果该位是大它超出屏幕

Canvas : canvas draw the bitmap but if the bitmap is larger it goes out of screen.

如何同为像ImageView的显示帆布位图的行为?

How to same behavior for bitmap on canvas like Imageview display.?

推荐答案

要调整位图
看看<一个href=\"http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28int%5B%5D,%20int,%20int,%20float,%20float,%20int,%20int,%20boolean,%20android.graphics.Paint%29\"相对=nofollow> drawBitmap 在画布方法,每个重载方法允许你指定一个尺寸。例如,下面是其中的一种方法的签名

To resize a bitmap take a look at drawBitmap method in the canvas, Each overloaded method allows you to specify a size. For example here is the signature of one of the methods

公共无效drawBitmap(INT []的色彩,诠释抵消,诠释步幅,诠释的x,INT Y,INT宽度,INT的高度,布尔hasAlpha,油漆涂料)

它允许您指定的宽度和高度。

It allows you specify the width and height .

或者

使用<一个href=\"http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28android.graphics.Bitmap,%20android.graphics.Matrix,%20android.graphics.Paint%29\"相对=nofollow> 公共无效drawBitmap(位图的位图,矩阵的矩阵,涂料粉刷) 以及

使用<一个href=\"http://developer.android.com/reference/android/graphics/Matrix.html#setScale%28float,%20float%29\"相对=nofollow> 公共无效setScale(浮点SX,SY浮动) 来调整

使用此重新大小根据你的需要的图片

Use this to re-size the image based on your needs

这篇关于在调整图像画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆