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: Enter image details here

This is a 32x32 png image that I have chosen to use as an example.

This is my output:

Enter image details here

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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -