Advertisement
p4r4digm

Untitled

Oct 29th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. std::vector<int> colors(img.x*img.y);
  2. for(i = 0; i < img.x*img.y; ++i)
  3.    colors[i] = *(int*)&img.colors[i];
  4.  
  5. colors = colors.sort.unique()//whatever
  6.  
  7. struct rgbega{
  8.    int rgb;
  9.    byte ega;
  10.    rgbega(int rgb, byte ega):rgb(rgb), ega)ega){}
  11.    bool operator<(int other) {
  12.       return rgb < other;
  13.    }
  14. };
  15.  
  16. std::vector<rgbega> colorLUT(colors.size());
  17.  
  18. for(i = 0; i < colors.size(); ++i)
  19.    colorLUT[i] = rgbega(colors[i], closestEGA(colors[i]));
  20.  
  21.  
  22. byte getEGAFromRGB(Color _c) {
  23.    int c = *(int*)&_c;
  24.    return std::lower_bound(begin(colorLUT), end(colorLUT), c)->ega;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement