使用double值而不是int android创建位图 [英] Create a bitmap using double values ​​instead of int android

查看:188
本文介绍了使用double值而不是int android创建位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的代码中,我需要使用double值创建一个Bitmap。重要的是使用正确的值。

In my code i need create a Bitmap using double values. It´s important use the correct value.

我正在使用:

Bitmap bmp = Bitmap.createBitmap(int, int, Bitmap.Config.ARGB_8888);

...当我需要类似的东西时:

... When i would need something like:

Bitmap bmp = Bitmap.createBitmap(double, double, Bitmap.Config.ARGB_8888);

我尝试进行转换的所有内容(可能?)只返回初始值或整数

Everything I've trying to make the conversion ( possible ? ) Only returns the initial value or integer

创建位图时如何使用double值?

How I can use double values ​​when creating the bitmap ?

提前致谢。

问候。

推荐答案

也许我误解了这个问题,但是位图是完整的栅格像素。您不能拥有像素的分数,因此在createBitmap的参数中只能包含整数个行和列。

Perhaps I misunderstand the question, but bitmaps are rasters of whole pixels. You can't have fractions of pixels, so you can only have integer numbers of rows and columns in the parameters for createBitmap.

话虽如此,您可以重新调整使用通过Matrix drawBitmap方法应用的浮点比例因子绘制位图,例如

Having said that, you can rescale how the bitmap is drawn using float scale factors applied via Matrix drawBitmap methods, e.g.

Canvas.drawBitmap(位图位图,矩阵矩阵,油漆颜料)

Matrix matrix = new android.graphics.Matrix();
matrix.postScale(3.14f, 3.14f);
canvas.drawBitmap(bitmap, matrix, paint);

然而,当涉及到在屏幕上渲染时,它将再次仅绘制整个像素,所以你仍然没有显示小数像素。

However, when it comes to rendering this on screen, it will again draw only whole pixels, so you still don't get fractional pixels displayed.

这篇关于使用double值而不是int android创建位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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