Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::vector<int> colors(img.x*img.y);
- for(i = 0; i < img.x*img.y; ++i)
- colors[i] = *(int*)&img.colors[i];
- colors = colors.sort.unique()//whatever
- struct rgbega{
- int rgb;
- byte ega;
- rgbega(int rgb, byte ega):rgb(rgb), ega)ega){}
- bool operator<(int other) {
- return rgb < other;
- }
- };
- std::vector<rgbega> colorLUT(colors.size());
- for(i = 0; i < colors.size(); ++i)
- colorLUT[i] = rgbega(colors[i], closestEGA(colors[i]));
- byte getEGAFromRGB(Color _c) {
- int c = *(int*)&_c;
- return std::lower_bound(begin(colorLUT), end(colorLUT), c)->ega;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement