本文整理汇总了C++中rgb_to_hsv函数的典型用法代码示例。如果您正苦于以下问题:C++ rgb_to_hsv函数的具体用法?C++ rgb_to_hsv怎么用?C++ rgb_to_hsv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rgb_to_hsv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rgb_to_hsv
void MixValueOperation::executePixelSampled(float output[4],
float x,
float y,
PixelSampler sampler)
{
float inputColor1[4];
float inputColor2[4];
float inputValue[4];
this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
float value = inputValue[0];
if (this->useValueAlphaMultiply()) {
value *= inputColor2[3];
}
float valuem = 1.0f - value;
float rH, rS, rV;
float colH, colS, colV;
rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
hsv_to_rgb(rH, rS, (valuem * rV + value * colV), &output[0], &output[1], &output[2]);
output[3] = inputColor1[3];
clampIfNeeded(output);
}
示例2: TweenerALLHSV
uint32 TweenerALLHSV( uint16_t count, uint32 from,uint32 to,uint32 delay)
{
int i;
led_color frgb,trgb;
hsv_color src, target,result;
trgb.rgb = to;
frgb.rgb = from;
src = rgb_to_hsv( frgb ) ;
target = rgb_to_hsv( trgb );
result = src;
for( i = 1 ; i < count; i ++ )
{
result.h.h = TweenU8toU8(src.h.h, target.h.h, i);
StripLights_DisplayClearHSV( result );
if(delay){
CyDelay( delay );
}
BOOT_CHECK();
}
return result.hsv;
}
示例3: rgb_to_hsv
void worm::render_flip(BITMAP* where, int frame, int _x, int _y)
{
int r,g,c,R,G,B,i;
float h1,s1,v1,h,s,v;
for (i=0;i<skin->img[frame]->w;i++)
{
for (r=0;r<skin->img[frame]->h;r++)
{
g=getpixel(skin->img[frame],i,r);
c=getpixel(mask->img[frame],i,r);
if(g!=makecol(255,0,255))
{
if(c!=makecol(255,0,255))
{
c=color;
rgb_to_hsv(getr(c), getg(c), getb(c), &h1, &s1, &v1);
R = getr(g);
G = getg(g);
B = getb(g);
rgb_to_hsv(R, G, B, &h, &s, &v);
h = h1;
s = s1;
v -= (1-v1)/1.4;
if (v<0)v=0;
hsv_to_rgb(h,s,v, &R, &G, &B);
g = makecol(R,G,B);
putpixel(where,_x+skin->img[frame]->w-1-i,_y+r,g);
}else putpixel(where,_x+skin->img[frame]->w-1-i,_y+r,g);
};
};
};
};
示例4: FadeToColor
void FadeToColor( uint16_t startx, uint16_t count, uint32 target, uint32 delay, int direction)
{
int j,i;
int offset,oldoffset;
led_color frgb,trgb;
hsv_color src,target_hsv,result;
frgb.rgb = target;
src = rgb_to_hsv( frgb ) ;
offset = startx;
for ( j = 0 ; j < 100 ; j ++ ) {
oldoffset = offset;
for( i = 0 ; i < count; i ++ ){
// get colour of current LED at offset
trgb.rgb = StripLights_GetPixel(offset,0);
// convert current led color to hsv
target_hsv = rgb_to_hsv( trgb );
result = target_hsv;
// tween, what we want to what it is at percentage i
result.h.h = TweenU8toU8( target_hsv.h.h, src.h.h, j );
// update pixel
StripLights_PixelHSV(offset, 0, result );
// handle travel direction of pixel
offset += direction;
if (offset < (int)StripLights_MIN_X ) offset = startx ;
if (offset > startx+count ) offset = StripLights_MIN_X ;
}
// check bootloader mode
BOOT_CHECK();
// if wants a delay, update led strip and delay
if(delay) {
while( StripLights_Ready() == 0);
StripLights_Trigger(1);
CyDelay( delay );
}
offset = oldoffset;
}
}
示例5: TweenerHSV
uint32 TweenerHSV( uint16_t startx, uint16_t count, uint32 from,uint32 to,uint32 delay,int direction)
{
int i;
int offset;
led_color frgb,trgb;
hsv_color src, target,result;
trgb.rgb = to;
frgb.rgb = from;
src = rgb_to_hsv( frgb ) ;
target = rgb_to_hsv( trgb );
result = src;
offset = startx;
for( i = 1 ; i < count; i ++ )
{
result.h.h = TweenU8toU8(src.h.h, target.h.h, i);
StripLights_PixelHSV(offset, 0, result );
offset += direction;
if (offset < (int)StripLights_MIN_X ) offset = startx ;
if (offset > startx+count ) offset = StripLights_MIN_X ;
BOOT_CHECK();
if(delay) {
while( StripLights_Ready() == 0);
StripLights_Trigger(1);
CyDelay( delay );
}
}
while( StripLights_Ready() == 0);
StripLights_Trigger(1);
CyDelay( 5 );
return result.hsv;
}
示例6: setupColormap
/* set up the colormap */
static void setupColormap (struct state *st, XWindowAttributes *xgwa)
{
int n;
XGCValues gcv;
XColor *colors = (XColor *) calloc (sizeof (XColor), st->colorCount + 1);
unsigned short r, g, b;
int h1, h2;
double s1, s2, v1, v2;
r = RAND_FLOAT_01 * 0x10000;
g = RAND_FLOAT_01 * 0x10000;
b = RAND_FLOAT_01 * 0x10000;
rgb_to_hsv (r, g, b, &h1, &s1, &v1);
v1 = 1.0;
s1 = 1.0;
r = RAND_FLOAT_01 * 0x10000;
g = RAND_FLOAT_01 * 0x10000;
b = RAND_FLOAT_01 * 0x10000;
rgb_to_hsv (r, g, b, &h2, &s2, &v2);
s2 = 0.7;
v2 = 0.7;
colors[0].pixel = get_pixel_resource (st->dpy, xgwa->colormap,
"background", "Background");
make_color_ramp (xgwa->screen, xgwa->visual, xgwa->colormap,
h1, s1, v1, h2, s2, v2,
colors + 1, &st->colorCount, False, True, False);
if (st->colorCount < 1)
{
fprintf (stderr, "%s: couldn't allocate any colors\n", progname);
exit (-1);
}
st->gcs = (GC *) calloc (sizeof (GC), st->colorCount + 1);
for (n = 0; n <= st->colorCount; n++)
{
gcv.foreground = colors[n].pixel;
gcv.line_width = st->lineWidth;
st->gcs[n] = XCreateGC (st->dpy, st->window, GCForeground | GCLineWidth, &gcv);
}
free (colors);
}
示例7: get_color
static void get_color (gint i, gfloat * r, gfloat * g, gfloat * b)
{
static GdkRGBA c;
static bool_t valid = FALSE;
gfloat h, s, v, n;
if (! valid)
{
/* we want a color that matches the current theme
* selected color of a GtkEntry should be reasonable */
GtkStyleContext * style = gtk_style_context_new ();
GtkWidgetPath * path = gtk_widget_path_new ();
gtk_widget_path_append_type (path, GTK_TYPE_ENTRY);
gtk_style_context_set_path (style, path);
gtk_widget_path_free (path);
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, & c);
g_object_unref (style);
valid = TRUE;
}
rgb_to_hsv (c.red, c.green, c.blue, & h, & s, & v);
if (s < 0.1) /* monochrome theme? use blue instead */
{
h = 5;
s = 0.75;
}
n = i / (gfloat) (bands - 1);
s = 1 - 0.9 * n;
v = 0.75 + 0.25 * n;
hsv_to_rgb (h, s, v, r, g, b);
}
示例8: do_huecorrect
static void do_huecorrect(bNode *node, float *out, float *in)
{
float hsv[3], f;
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
/* adjust hue, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
hsv[0] += f-0.5f;
/* adjust saturation, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 1, hsv[0]);
hsv[1] *= (f * 2.f);
/* adjust value, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 2, hsv[0]);
hsv[2] *= (f * 2.f);
hsv[0] = hsv[0] - floor(hsv[0]); /* mod 1.0 */
CLAMP(hsv[1], 0.f, 1.f);
/* convert back to rgb */
hsv_to_rgb(hsv[0], hsv[1], hsv[2], out, out+1, out+2);
out[3]= in[3];
}
示例9: gtk_plot_surface_lighting
static void
gtk_plot_surface_lighting (GdkColor *a, GdkColor *b,
gdouble normal, gdouble ambient)
{
gdouble red, green, blue;
gdouble h, s, v;
if(normal == 1.0){
*b = *a;
return;
}
normal = MIN(fabs(normal), 1.0);
red = a->red;
green = a->green;
blue = a->blue;
rgb_to_hsv(red, green, blue, &h, &s, &v);
s *= normal;
v *= normal;
s += ambient;
v += ambient;
hsv_to_rgb(h, MIN(s, 1.0), MIN(v, 1.0), &red, &green, &blue);
b->red = red;
b->green = green;
b->blue = blue;
}
示例10: do_huecorrect_fac
static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac)
{
float hsv[3], rgb[3], f;
const float mfac = 1.f-*fac;
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv+1, hsv+2);
/* adjust hue, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 0, hsv[0]);
hsv[0] += f-0.5f;
/* adjust saturation, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 1, hsv[0]);
hsv[1] *= (f * 2.f);
/* adjust value, scaling returned default 0.5 up to 1 */
f = curvemapping_evaluateF(node->storage, 2, hsv[0]);
hsv[2] *= (f * 2.f);
hsv[0] = hsv[0] - floor(hsv[0]); /* mod 1.0 */
CLAMP(hsv[1], 0.f, 1.f);
/* convert back to rgb */
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
out[0]= mfac*in[0] + *fac*rgb[0];
out[1]= mfac*in[1] + *fac*rgb[1];
out[2]= mfac*in[2] + *fac*rgb[2];
out[3]= in[3];
}
示例11: exposure_image
void exposure_image(image im, float sat)
{
rgb_to_hsv(im);
scale_image_channel(im, 2, sat);
hsv_to_rgb(im);
constrain_image(im);
}
示例12: saturate_image
void saturate_image(image im, float sat)
{
rgb_to_hsv(im);
scale_image_channel(im, 1, sat);
hsv_to_rgb(im);
constrain_image(im);
}
示例13: setTo
void setTo(const gif::Palette &pal) override {
mColors.clear();
for (const auto& c : pal.mColors) {
HSV hsv;
rgb_to_hsv(c, hsv.h, hsv.s, hsv.v);
mColors.push_back(Lookup(hsv, c));
}
}
示例14: getBright
unsigned char getBright(unsigned short color)
{
float h,s,v;
rgb_to_hsv(GET16R(color),GET16G(color),GET16B(color),&h,&s,&v);
return v*255;
}
示例15: V_Colorize
byte V_Colorize (byte *playpal, int cr, byte source, boolean keepgray109)
{
vect rgb, hsv;
// [crispy] preserve gray drop shadow in IWAD status bar numbers
if (cr == CR_NONE || (keepgray109 && source == 109))
return source;
rgb.x = playpal[3 * source + 0] / 255.;
rgb.y = playpal[3 * source + 1] / 255.;
rgb.z = playpal[3 * source + 2] / 255.;
rgb_to_hsv(&rgb, &hsv);
if (cr == CR_DARK)
hsv.z *= 0.5;
else
if (cr == CR_GRAY)
hsv.y = 0;
else
{
// [crispy] hack colors to full saturation
hsv.y = 1.0;
if (cr == CR_GREEN)
{
// hsv.x = 135./360.;
hsv.x = (150. * hsv.z + 120. * (1. - hsv.z))/360.;
}
else
if (cr == CR_GOLD)
{
// hsv.x = 45./360.;
// hsv.x = (50. * hsv.z + 30. * (1. - hsv.z))/360.;
hsv.x = (7.0 + 53. * hsv.z)/360.;
hsv.y = 1.0 - 0.4 * hsv.z;
hsv.z = 0.2 + 0.8 * hsv.z;
}
else
if (cr == CR_RED)
{
hsv.x = 0.;
}
else
if (cr == CR_BLUE)
{
hsv.x = 240./360.;
}
}
hsv_to_rgb(&hsv, &rgb);
rgb.x *= 255.;
rgb.y *= 255.;
rgb.z *= 255.;
return I_GetPaletteIndex2(playpal, (int) rgb.x, (int) rgb.y, (int) rgb.z);
}