0

I have a linear byte array whose values I want to set as pixels of an image. The byte array length is 4800 and I want it to be displayed as a 80x60 image with pixel values set row-wise one after the other. I know that BitmapFactory helps to handle such tasks but how do I specify the height and width of the image?

1
  • 1
    "whose values I want to set as pixels of an image" So you have one pixel = 1 byte? What format is that? Grayscale? Palette? Commented Jan 30, 2013 at 21:12

1 Answer 1

1

It sounds like what you've got is a byte array with the colors for the pixels in a Bitmap. If so, you will probably want to use the setPixels() method:

Bitmap bmp = Bitmap.createBitmap(80, 60, myConfig);

bmp.setPixels(myPixelData, 0, 80, 0, 0, 80, 60);
Sign up to request clarification or add additional context in comments.

2 Comments

But this requires, not a array of bytes but an array of ints, each of which represents a packed color.
ah, good point, I overlooked that, guess we need clarification from the OP

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.