1 /* 2 * Copyright 2006, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #ifndef LAB_CONVERT_H 10 #define LAB_CONVERT_H 11 12 #include <SupportDefs.h> 13 14 void lab2rgb(float L, float a, float b, uint8& R, uint8& G, uint8& B); 15 16 // lab2rgb 17 inline void 18 lab2rgb(uint8 L, uint8 a, uint8 b, uint8& R, uint8& G, uint8& B) 19 { 20 float CIEL = ((float)L / 255.0) * 100.0; 21 float CIEa = ((float)a - 128.0); 22 float CIEb = ((float)b - 128.0); 23 lab2rgb(CIEL, CIEa, CIEb, R, G, B); 24 } 25 26 void rgb2lab(uint8 R, uint8 G, uint8 B, float& L, float& a, float& b); 27 28 // rgb2lab 29 inline void 30 rgb2lab(uint8 R, uint8 G, uint8 B, uint8& L, uint8& a, uint8& b) 31 { 32 float CIEL, CIEa, CIEb; 33 rgb2lab(R, G, B, CIEL, CIEa, CIEb); 34 L = uint8((CIEL / 100.0) * 255.0); 35 a = uint8(CIEa + 128); 36 b = uint8(CIEb + 128); 37 } 38 39 void replace_luminance(uint8& r1, uint8& g1, uint8& b1, uint8 r2, uint8 g2, uint8 b2); 40 41 #endif // LAB_CONVERT_H 42