首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >位图get像素总是返回一个负数。

位图get像素总是返回一个负数。
EN

Stack Overflow用户
提问于 2019-05-28 12:25:19
回答 1查看 491关注 0票数 0

我已经将图像作为位图从设备存储中加载,并希望从其中检索像素rgb,但是getPixel(x,y)方法总是返回一个大的负数

我发现了类似的问题,我甚至找到了与答案相同的代码,但它对我不起作用,位图是可变的

代码

代码语言:javascript
复制
inputBitmap=inputBitmap.copy( Bitmap.Config.ARGB_8888 , true);
int pixel;
byte r, g, b;
pixel =inputBitmap.getPixel(j, i);
Log.e("pixel","j "+j+" i "+i+" "+pixel);
r = (byte)Color.red(pixel);
g = (byte)Color.green(pixel);
b = (byte)Color.blue(pixel);
Log.e("COLOR","\n"+"Red : "+r+"\n"+"Green : "+g+"\n"+"Blue : "+b);

Logcat

代码语言:javascript
复制
05-28 13:02:51.335 20379-20379/pfe.steganography E/COLOR:
    Red : -1
    Green : -1
    Blue : -1
05-28 13:02:51.335 20379-20379/pfe.steganography E/pixel:  -1
05-28 13:02:51.335 20379-20379/pfe.steganography E/COLOR: 
    Red : -1
    Green : -1
    Blue : -1
05-28 13:02:51.335 20379-20379/pfe.steganography E/pixel:  -1
05-28 13:02:51.335 20379-20379/pfe.steganography E/COLOR: 
    Red : -1
    Green : -1
    Blue : -1
05-28 13:02:51.335 20379-20379/pfe.steganography E/pixel:  -460552
05-28 13:02:51.335 20379-20379/pfe.steganography E/COLOR: 
    Red : -8
    Green : -8
    Blue : -8
05-28 13:02:51.336 20379-20379/pfe.steganography E/pixel:  -1381654
05-28 13:02:51.336 20379-20379/pfe.steganography E/COLOR: 
    Red : -22
    Green : -22
    Blue : -22
05-28 13:02:51.336 20379-20379/pfe.steganography E/pixel:  -1315861
05-28 13:02:51.336 20379-20379/pfe.steganography E/COLOR: 
    Red : -21
    Green : -21
    Blue : -21
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-28 13:42:16

解决了

解决了,但仍然奇怪,在下面的日志中,我有随机的正/负信号,但绝对值是正确的,我所要做的就是保持它们的绝对值,它起作用了。

代码语言:javascript
复制
05-28 14:35:21.225 15064-15064/pfe.steganography E/pixel:  -16743306
05-28 14:35:21.225 15064-15064/pfe.steganography E/COLOR: Red : 0
    Green : -124
    Blue : 118
05-28 14:35:21.649 15064-15064/pfe.steganography E/pixel:  -13920116
05-28 14:35:21.649 15064-15064/pfe.steganography E/COLOR: Red : 43
    Green : -104
    Blue : -116
05-28 14:35:22.057 15064-15064/pfe.steganography E/pixel:  -48066684
05-28 14:35:22.057 15064-15064/pfe.steganography E/COLOR: Red : 34
    Green : -113
    Blue : -124 ````
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56342232

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档