RGB pixel array only one dimension not 3 in vector

Hi. I want rgb values in this format: In a 1d vector I want first R values, then G values, and then B Values. I tried to use this code: pixels = new int[bitmap.getHeight() * bitmap.getWidth()]; bitmap.getPixels(pixels, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight()); // int R, G, B,Y; for (int y = 0; y < bitmap.getHeight(); y++) { for (int x = 0; x < bitmap.getWidth(); x++) { int index = y * bitmap.getHeight() + x; int R = (pixels[index] >> 16) & 0xff; // bitwise shifting int G = (pixels[index] >> 8) & 0xff; int B = pixels[index] & 0xff; // R,G.B - Red, Green, Blue // to restore the values after RGB modification, use // next statement pixels[index] = 0xff000000 | (R << 16) | (G << 8) | B; } } bitmap.recycle(); } catch (NullPointerException exception) { Log.e("Error Utils", "Photo is damaged or does not support this format!"); } return pixels; But, I still have only a 300*200 1d array. Not 300*200*3 1d array!
Please clarify your question i did not fully understand what you really want.

以上就是RGB pixel array only one dimension not 3 in vector的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏