int []testbufall = new int[WIDTH*HEIGHT];
int total =WIDTH*HEIGHT;
int imgWidth;
int imgHeight;
float widthscale,heightscale;
Bitmap image = BitmapFactory.decodeFile(strFilePath);
imgWidth = image.getWidth();
imgHeight = image.getHeight();
//计算缩放比例
Matrix matrix=new Matrix();
widthscale = (float)480/imgWidth;
heightscale=(float)272/imgHeight;
matrix.postScale(widthscale,heightscale);
Bitmap bmp=Bitmap.createBitmap(image,0,0,imgWidth,imgHeight,matrix,false);
bmp.getPixels(testbufall,0,WIDTH,0,0,WIDTH,HEIGHT);
testbufall保存的就是RGB8888的点阵数据了,每个int保存一个像素的数据 |
android获取图象点阵数组的方法
最新推荐文章于 2021-02-27 22:08:02 发布