Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - ScienceHill

Pages: [1]
Support / How can I get a bitmap from fb.getpixel()?
« on: November 29, 2017, 06:41:28 am »
Hello. Currently I am trying to take a screenshot use fb.getpixel() function. And here is my code:
int[] my_pixels = fb.getPixels();
Bitmap bitmap = Bitmap.createBitmap(fb.getWidth(), fb.getHeight(), Bitmap.Config.ARGB_4444);
But I just got a black image. And I also tried this:
int[] tmpPixels = fb.getPixels();
for (int i = 0; i < tmpPixels.length; i++){
   int tmpInt = ((tmpPixels & 0xf8) >> 3);
   tmpInt += ((tmpPixels & 0xfc00) >> 5);
   tmpInt += ((tmpPixels & 0xf80000) >> 11);
  tmpPixels = tmpInt;
Bitmap lastImage = Bitmap.createBitmap(tmpPixels, fb.getWidth(), fb.getHeight(), Bitmap.Config.RGB_565);
But it still did not work. I know that the fb.getPixels() function return an int array. And it contains R, G and B channels value. But how can I actually use it? Any answer is appreciated and thanks in advance.

Pages: [1]