Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何加载和获取16位单通道PNG图像的像素值?_Android_Png - Fatal编程技术网

Android 如何加载和获取16位单通道PNG图像的像素值?

Android 如何加载和获取16位单通道PNG图像的像素值?,android,png,Android,Png,我尝试在Android中加载一个16位单通道PNG图像,并获取每个像素的值 我使用函数“BitmapFactory.decodeStream”直接获取像素值。我得到的像素值像“-16250872” 如何在Android中获得这种类型图像的正确值 InputStream ist=null; 试一试{ ist=getAssets().open(pic_路径2); }捕获(IOE异常){ e、 printStackTrace(); } 位图bmp2=BitmapFactory.decodeStrea

我尝试在Android中加载一个16位单通道PNG图像,并获取每个像素的值

我使用函数“BitmapFactory.decodeStream”直接获取像素值。我得到的像素值像“-16250872”

如何在Android中获得这种类型图像的正确值


InputStream ist=null;
试一试{
ist=getAssets().open(pic_路径2);
}捕获(IOE异常){
e、 printStackTrace();
}
位图bmp2=BitmapFactory.decodeStream(ist);
int-width=bmp2.getWidth()//获取图像的宽度
int height=bmp2.getHeight()//获取图像的高度
浮动[]Px2=新浮动[宽度][高度];
对于(int i=0;i
我打赌您得到的是值
0xFFF7F7F8
,但您选择将其解释并显示为有符号整数。这是一个错误的选择,在中查看RGBA值(大概是这样)。但是…我们不能不看你的源代码就知道。谢谢你的重播。我已经编辑了我的问题。我认为我的图像不是rgb格式。它不能直接转换。我得到的像素值像-1.6777216E7,在原始图像中应该是0。
InputStream ist= null;
      try {
          ist = getAssets().open(pic_PATH2);
      } catch (IOException e) {
          e.printStackTrace();
      }
  Bitmap bmp2 = BitmapFactory.decodeStream(ist);
  int width = bmp2.getWidth();//get the width of the image
  int height = bmp2.getHeight();//get the height of the image
  float[][] Px2  = new float[width][height];
  for (int i = 0; i < height; i++)
      for (int j = 0; j < width; j++)
      {
          Px2[j][i] = bmp2.getPixel(j, i);
      }