BGR555 Java Encoding -


i'm developing java application has decode , encode bgr555 color format.

the decode procedure works this:

short rgb; int r,g,b; r=(num & 0x001f) * 0x08; g=((num & 0x03e0) >> 5) * 0x08; b=((num & 0x7c00) >> 10) * 0x08; 

the problem when want encode starting r,g,b values. i'm not expert on bitwise operations , searched tutorials on web, didn't understand :(

my question how this? what's opposite of & , how concatenate values?

i've found solution! here snippet:

public static byte[] frombgr555(color[] p) {         bytebuffer b = bytebuffer.allocate(p.length * 2).order(                 byteorder.little_endian);         (int = 0; < p.length; i++) {             int num = 0;             num += (p[i].getred() / 0x08);             num += ((p[i].getgreen() / 0x08) << 5);             num += ((p[i].getblue() / 0x08) << 10);             b.putshort((short) num);         }         return b.array();     } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -