I wanted to get a list of pixels for the bit map that I have.
I got the bitmap to show on the screen but for some reason every time I try to get the list of pixels the array is always 0.
I am not sure why. I have been searching and trying different answers for a few days. the length of the array is there, and it is not null. So I am not sure why this isnt working.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
line = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.line);
sun = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.circle);
line = Bitmap.createBitmap(line, 0, 0, line.getWidth(), line.getHeight());
canvas.drawBitmap(line, 0, 0, null);
canvas.drawBitmap(sun, 0,0, null);
Log.d("BITMAP","WIDTH:"+line.getWidth()+" HEIGHT:"+line.getHeight());
pixelAmount = new int[line.getHeight()*line.getRowBytes()];
line.getPixels(pixelAmount,0,line.getWidth(),0,0,line.getWidth()-1,line.getHeight()-1);
Log.d("Line", "Pixel: " + pixelAmount.length + " Index" + 0);
Log.d("Line", "Pixel: " + pixelAmount[10] + " Index" + 0);
Log.d("Line", "Pixel: " + pixelAmount[100] + " Index" + 0);
Log.d("Line", "Pixel: " + pixelAmount[56] + " Index" + 0);
Log.d("Line", "Pixel: " + pixelAmount[76] + " Index" + 0);
}
}