Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1005377 // to332 - convert pixel to 332 format (byte) from int (24 bit RGB)

JavaX fragment (include)

static byte to332(Color color) {
  ret to332(colorToInt(color));
}

static byte to332(int rgb) {
  int r = (rgb >> 16) & 0xFF;
  int g = (rgb >> 8) & 0xFF;
  int b = rgb & 0xFF;
  //ret (byte) (((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6));
  ret (byte) ((iround(r*7.0/255) << 5) | (iround(g*7.0/255) << 2)
    | (iround(b*3.0/255)));
}

Author comment

Began life as a copy of #1005376

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1005377
Snippet name: to332 - convert pixel to 332 format (byte) from int (24 bit RGB)
Eternal ID of this version: #1005377/2
Text MD5: 2e1eaa2ffc60fa5d483f04f393178b32
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-29 14:18:19
Source code size: 349 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 545 / 542
Version history: 1 change(s)
Referenced in: [show references]