#include <stdio.h>
#define Max(a, b, c) (a) > (b)? ((a) > (c)? (a) : (c)) : ((b) > (c) ? (b):(c))
#define Min(a, b, c) (a) < (b)?((a) < (c)?(a):(c)) : ((b) < (c)?(b):(c))
typedef struct{
unsigned char R;
unsigned char G;
unsigned char B;
}COLOR_RGB;
typedef struct{
float H;
float S;
float V;
}COLOR_HSV;
//rgb TO hsv
void RGB_TO_HSV(const COLOR_RGB *input,COLOR_HSV *output)
{
float r,g,b,minRGB,maxRGB,deltaRGB;
r = input->R/255.0f;
g = input->G/255.0f;
b = input->B/255.0f;
minRGB = Min(r,g,b);
maxRGB = Max(r,g,b);
deltaRGB = maxRGB - minRGB;
if(maxRGB != 0.0)
output
RGB和HSV相互转化
最新推荐文章于 2025-07-31 15:22:31 发布