我已经将图像作为位图从设备存储中加载,并希望从其中检索像素rgb,但是getPixel(x,y)方法总是返回一个大的负数
我发现了类似的问题,我甚至找到了与答案相同的代码,但它对我不起作用,位图是可变的
代码
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
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发布于 2019-05-28 13:42:16
解决了
解决了,但仍然奇怪,在下面的日志中,我有随机的正/负信号,但绝对值是正确的,我所要做的就是保持它们的绝对值,它起作用了。
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 ````https://stackoverflow.com/questions/56342232
复制相似问题