android - Get pixels from bitmap, display them results in wrong order -
I have just written some code that captures an image, it stores pixels in an array and every pixel Displays again, so the ending image should be shown.
I took the following picture:
This is a 32x32 png image that I have chosen to use as an example.
This is my output:
As you can see, the result is more pixels than 32x32.
Here my code looks:
First of all, an array was created, which should get all pixel notifications of the image:
Private bitmap B = bitrive (getResources), undertroadable. Test); Private int = b.getWidth; Private int H = BGhatite; Private int pixels = w * h;
Then I used a method to store the bitmap pixels in the array:
b.getPixels (pixels, 0, w, 0) , 0, w, h);
I thought it should be, now I can drag the pixels into my view:
Public Waste On Draw (Canvas Canvas) {Super. Canvas); Paint P = new paint (); For (int i = 0; i
I do not know what my error is, maybe someone can help me?
Your algorithm is incorrect, and often a little bit of YTF-Y There is no reason for String.format to come here, I do not even know where you are going there. And the drawback is not the way to do this. Try:
for (int i = 0; i & lt; w; i ++) {for (int j = 0; j & lt; h; j ++) { P.setcolor (pixels [i * bmp.getWidth () + j]); Canvas.drawPoint (J, I, Paint); }}
Comments
Post a Comment