Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00019 * All rights reserved. 00020 * 00021 * The Original Code is: some of this file. 00022 * 00023 * ***** END GPL LICENSE BLOCK ***** 00024 * */ 00025 00026 #ifndef BLI_MATH_COLOR_H 00027 #define BLI_MATH_COLOR_H 00028 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif 00036 00037 #include "BLI_math_inline.h" 00038 00039 /* primaries */ 00040 #define BLI_XYZ_SMPTE 0 00041 #define BLI_XYZ_REC709_SRGB 1 00042 #define BLI_XYZ_CIE 2 00043 00044 /* built-in profiles */ 00045 #define BLI_PR_NONE 0 00046 #define BLI_PR_SRGB 1 00047 #define BLI_PR_REC709 2 00048 00049 /* YCbCr */ 00050 #define BLI_YCC_ITU_BT601 0 00051 #define BLI_YCC_ITU_BT709 1 00052 #define BLI_YCC_JFIF_0_255 2 00053 00054 /******************* Conversion to RGB ********************/ 00055 00056 void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b); 00057 void hex_to_rgb(char *hexcol, float *r, float *g, float *b); 00058 void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb); 00059 void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb, int colorspace); 00060 void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b, int colorspace); 00061 void cpack_to_rgb(unsigned int col, float *r, float *g, float *b); 00062 00063 /***************** Conversion from RGB ********************/ 00064 00065 void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv); 00066 void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr, int colorspace); 00067 void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv); 00068 void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv); 00069 unsigned int rgb_to_cpack(float r, float g, float b); 00070 unsigned int hsv_to_cpack(float h, float s, float v); 00071 00072 float rgb_to_grayscale(const float rgb[3]); 00073 unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]); 00074 float rgb_to_luma(const float rgb[3]); 00075 unsigned char rgb_to_luma_byte(const unsigned char rgb[3]); 00076 00077 /**************** Profile Transformations *****************/ 00078 00079 void gamma_correct(float *c, float gamma); 00080 float rec709_to_linearrgb(float c); 00081 float linearrgb_to_rec709(float c); 00082 float srgb_to_linearrgb(float c); 00083 float linearrgb_to_srgb(float c); 00084 00085 MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3]); 00086 MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3]); 00087 00088 MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4]); 00089 MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4]); 00090 00091 MINLINE void srgb_to_linearrgb_predivide_v4(float linear[4], const float srgb[4]); 00092 MINLINE void linearrgb_to_srgb_predivide_v4(float srgb[4], const float linear[4]); 00093 00094 void BLI_init_srgb_conversion(void); 00095 00096 /************************** Other *************************/ 00097 00098 int constrain_rgb(float *r, float *g, float *b); 00099 void minmax_rgb(short c[3]); 00100 00101 void rgb_float_set_hue_float_offset(float * rgb, float hue_offset); 00102 void rgb_byte_set_hue_float_offset(unsigned char * rgb, float hue_offset); 00103 00104 void rgb_byte_to_float(const unsigned char in[3], float out[3]); 00105 void rgb_float_to_byte(const float in[3], unsigned char out[3]); 00106 00107 /***************** lift/gamma/gain / ASC-CDL conversion *****************/ 00108 00109 void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power); 00110 00111 #ifdef BLI_MATH_INLINE_H 00112 #include "intern/math_color_inline.c" 00113 #endif 00114 00115 #ifdef __cplusplus 00116 } 00117 #endif 00118 00119 #endif /* BLI_MATH_COLOR_H */ 00120