【发布时间】:2017-12-01 22:20:38
【问题描述】:
我使用Bitmap.getPixels 和下面的代码在位图图像中间获得一行 1 像素高度:
int width = source.getWidth();
int height = source.getHeight();
int[] horizontalMiddleArray = new int[width];
source.getPixels(horizontalMiddleArray, 0, width, 0, height / 2, width, 1);
结果是这样的:
现在我想做同样的事情,但在垂直方向:
我尝试了相同的逻辑,但它不起作用,我看不出我做错了什么:
int[] verticalMiddleArray = new int[height];
source.getPixels(verticalMiddleArray, 0, width, width / 2, 0, 1, height -1 );
使用此代码,我收到 ArrayIndexOutOfBoundsException 异常。
现在位图的大小是 32x32。
【问题讨论】:
标签: java android android-image android-bitmap