ALPHA_8位图和getPixel [英] ALPHA_8 bitmaps and getPixel

查看:116
本文介绍了ALPHA_8位图和getPixel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图加载从一个PNG图像,采用移动地图。为了节省内存  之后我加载位图我做这样的事情。

I am trying to load a movement map from a PNG image. In order to save memory after I load the bitmap I do something like that.

 
 `Bitmap mapBmp = tempBmp.copy(Bitmap.Config.ALPHA_8, false);` 
 

如果我画的mapBmp我可以看到地图,当我使用与getPixel(),我得到  总是0(零)。

If I draw the mapBmp I can see the map but when I use getPixel() I get always 0 (zero).

有没有一种方法来检索位图比其他α信息  用与getPixel()?

Is there a way to retrieve ALPHA information from a bitmap other than with getPixel() ?

推荐答案

我能找到一个很好的和那种干净的方式来创建边界地图。我创建一个从开始的ALPHA_8位图。我画我的边界地图与路径。然后,我使用 copyPixelsToBuffer()和字节调成的ByteBuffer。我使用缓冲区从的getPixels。 我认为这是一个很好的解决方案,因为你可以缩小或向上的路径(),并提请在所需的屏幕分辨率规模,没有IO +的code业务的边界地图。 Bitmap.getPixel()是没有用的ALPHA_8位图,它总是返回0。

I was able to find a nice and sort of clean way to create boundary maps. I create an ALPHA_8 bitmap from the start. I paint my boundry map with paths. Then I use the copyPixelsToBuffer() and transfer the bytes into a ByteBuffer. I use the buffer to "getPixels" from. I think is a good solution since you can scale down or up the path() and draw the boundary map at the desired screen resolution scale and no IO + decode operations. Bitmap.getPixel() is useless for ALPHA_8 bitmaps, it always returns 0.

这篇关于ALPHA_8位图和getPixel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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