RGB to PixelIt-Integer #346
-
Hello, How to convert a rgb-value - like the icon editor - to an integer in JavaScrpt? Thanks a lot |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
To convert an RGB value to an integer in JavaScript, you can use bit shifting and bitwise OR operations. For example, if you have an RGB value like Here's a function that does this conversion: function rgbToInt(red, green, blue) {
return (red << 16) | (green << 8) | blue;
}
var intValue = rgbToInt(255, 0, 0); // Converts rgb(255, 0, 0) to an integer This function shifts the red value 16 bits to the left, the green value 8 bits to the left, and then combines them with the blue value using the bitwise OR operation. The resulting integer for |
Beta Was this translation helpful? Give feedback.
-
I´am working already on such a thing :) http://dev.spaps.de/pixelit/ |
Beta Was this translation helpful? Give feedback.
You search for RGB565, PixelIt use this representation for images.