Hi all! While playing with colors for pairtaghighlighter plugin, I saw that Scintilla is using BGR instead of normal RGB. I found existing code in Geany source to use it in my plugin.
utils_invert_color from utils.c deals with replacing blue with red, but with mistake. Below are results of my testing with random color: 11111111 11001100 10011001 - input color 10011001 11001100 11111111 - result of my function (rgb2bgr) 00000000 00110011 01100110 - result of utils_invert_color A little source file is attached. If it is really mistake (maybe I don't know something), I will do commit and pull request. Any comments about this? -- Best regards, Volodymyr Kononenko http://kononenko.ws
#include <stdio.h> int rgb2bgr(int color) { int r, g, b; r = color >> 16; g = (0x00ff00 & color) >> 8; b = (0x0000ff & color); color = (r | (g << 8) | (b << 16)); return color; } int utils_invert_color(int color) { int r, g, b; r = 0xffffff - color; g = 0xffffff - (color >> 8); b = 0xffffff - (color >> 16); return (r | (g << 8) | (b << 16)); } void print_bin(int n) { int i; for (i=1; i<=24; i++) { (n & (1<<23)) == 0x800000 ? printf("1") : printf("0"); if((0 == i%8) && (0 != i)) printf(" "); n = n << 1; } printf("\n"); } int main(void) { int color = 0xffcc99; print_bin(color); print_bin(rgb2bgr(color)); print_bin(utils_invert_color(color)); }
_______________________________________________ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel