Android 位图,如何
因此,对于我正在制作的应用程序,我将整数值的二维数组转换为布局中图像视图中的颜色块(正方形),其中每个值(0,1,2,3..)对应于其颜色正方形(红色、绿色、蓝色...)。我对位图的经验几乎为零,并且在制作位图时遇到了一些困难。我遇到的第一个问题是创建位图。我正在查看的方法是: bitmap.createBitmap(sizex, sizey, config)
因为这允许我将其设置为视图的像素大小(x 和 y),但我不知道如何使用配置类(它不会让我传递配置而不给我“静态”错误。如何以这种方式实例化位图?
或者我是不是找错了树?有没有更简单的方法来做到这一点(我见过一些人谈论android.graphics.canvas
)?非常感谢任何帮助或想法,请记住我对任何图形都是新的,可能需要一些额外的解释,
谢谢。
So for an app I'm making I am converting a 2d array of integer values into blocks(squares) of color in an imageview in a layout where each value (0,1,2,3..) corresponds to a color for their square (red, green blue...). I have almost zero experience with bitmaps and am running into some difficulties in making one. The first issue I am running into is creating the bitmap. The method I'm looking at is: bitmap.createBitmap(sizex, sizey, config)
because this would allow me to make it the size (x and y) of pixels that the View is, but I cant figure out how to use the config class(it wont let me pass a config without giving me "static" errors. How can instantiate a bitmap this way?
Or am I barking up the wrong tree? Is there an easier way to do this (I've seen some people talk about android.graphics.canvas
)? Any help or ideas is much appreciated, and please remember I new at anything graphics and might take some extra explanation.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 Bitmap image = Bitmap.createBitmap(sizex, sizey, config);。由于该方法是静态的,因此您可以从类中调用它,而不是从类的现有对象中调用它。
Try
Bitmap image = Bitmap.createBitmap(sizex, sizey, config);
. Since the method is static, you call it from the class and not an existing object of the class.