Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. bool closeToBackgroundColor(uint Pixel, uint backgroundColour, uint approximation)
  2. {
  3. uint redPixel = 0, greenPixel = 0, bluePixel = 0, redBckgrnd = 0, greenBckgrnd = 0, blueBckgrnd = 0;
  4. uint distance = 0;
  5. redPixel = (Pixel >> 16) & 0xFF;
  6. greenPixel = (Pixel >> 8) & 0xFF;
  7. bluePixel = Pixel & 0xFF;
  8. redBckgrnd = (backgroundColour >> 16) & 0xFF;
  9. greenBckgrnd = (backgroundColour >> 8) & 0xFF;
  10. blueBckgrnd= backgroundColour & 0xFF;
  11. distance = (redPixel - redBckgrnd)*(redPixel - redBckgrnd) + (greenPixel - greenBckgrnd)*(greenPixel - greenBckgrnd) + (bluePixel - blueBckgrnd)*(bluePixel - blueBckgrnd);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement