admin 管理员组

文章数量: 887021


2024年1月24日发(作者:变量作用范围c语言)

void HSVtoRGB(unsigned char *r, unsigned char *g, unsigned char *b, int h, int s, int v){ // convert from HSV/HSB to RGB color // R,G,B from 0-255, H from 0-260, S,V from 0-100 // ref / // The hue (H) of a color refers to which pure color it resembles // The saturation (S) of a color describes how white the color is // The value (V) of a color, also called its lightness, describes how dark the color is float RGB_min, RGB_max; RGB_max = v*2.55f; RGB_min = RGB_max*(100 - s)/ 100.0f; int i = h / 60; int difs = h % 60; // factorial part of h // RGB adjustment amount by hue

float RGB_Adj = (RGB_max - RGB_min)*difs / 60.0f; switch (i) { case 0: *r = RGB_max; *g = RGB_min + RGB_Adj; *b = RGB_min; break; case 1: *r = RGB_max - RGB_Adj; *g = RGB_max; *b = RGB_min; break; case 2: *r = RGB_min; *g = RGB_max; *b = RGB_min + RGB_Adj; break; case 3: *r = RGB_min; *g = RGB_max - RGB_Adj; *b = RGB_max; break; case 4: *r = RGB_min + RGB_Adj; *g = RGB_min; *b = RGB_max; break; default: // case 5: *r = RGB_max; *g = RGB_min; *b = RGB_max - RGB_Adj; break; }}代码测试结果


本文标签: 范围 变量 作用 结果 测试