Esempio n. 1
0
static void
compute_image (GimpDrawable *drawable)
{
  GimpDrawable *effect;
  guchar       *scalarfield = NULL;

  /* Get some useful info on the input drawable */
  /* ========================================== */
  if (! gimp_drawable_mask_intersect (drawable->drawable_id,
                                      &border_x, &border_y, &border_w, &border_h))
    return;

  gimp_progress_init (_("Van Gogh (LIC)"));

  if (licvals.effect_convolve == 0)
    generatevectors ();

  if (licvals.filtlen < 0.1)
    licvals.filtlen = 0.1;

  l = licvals.filtlen;
  dx = dy = licvals.noisemag;
  minv = licvals.minv / 10.0;
  maxv = licvals.maxv / 10.0;
  isteps = licvals.intsteps;

  source_drw_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);

  effect = gimp_drawable_get (licvals.effect_image_id);

  effect_width = effect->width;
  effect_height = effect->height;

  switch (licvals.effect_channel)
    {
      case 0:
        scalarfield = rgb_to_hsl (effect, LIC_HUE);
        break;
      case 1:
        scalarfield = rgb_to_hsl (effect, LIC_SATURATION);
        break;
      case 2:
        scalarfield = rgb_to_hsl (effect, LIC_BRIGHTNESS);
        break;
    }

  compute_lic (drawable, scalarfield, licvals.effect_operator);

  g_free (scalarfield);

  /* Update image */
  /* ============ */

  gimp_drawable_flush (drawable);
  gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
  gimp_drawable_update (drawable->drawable_id, border_x, border_y,
                        border_w, border_h);

  gimp_displays_flush ();
}
Esempio n. 2
0
// calculate new brighter color using rgb_color
//
COLORREF GetLighterColor(COLORREF rgb_color, float percent)
{
	float h, s, l;
	rgb_to_hsl(GetRValue(rgb_color) / 255.0f, GetGValue(rgb_color) / 255.0f, GetBValue(rgb_color) / 255.0f, &h, &s, &l);

//	l += (l + 0.01f) * percent / 100.0f;
	l += percent / 100.0f;
	if (l < 0.0f)
		l = 0.0f;
	else if (l > 1.0f)
		l = 1.0f;

	float r, g, b;
	hsl_to_rgb(h, s, l, &r, &g, &b);

	return RGB(uint8(r * 255), uint8(g * 255), uint8(b * 255));
}
vector color_hslimage(vector v, vector margin)
{
	vector pos;
	v = rgb_to_hsl(v);
	if (v_y)
	{
		pos_x = v_x / 6;
		pos_y = v_z * 0.875;
	}
	else // grey scale
	{
		pos_x = v_z;
		pos_y = 0.875 + 0.07;
	}
	pos_x = margin_x + pos_x * (1 - 2 * margin_x);
	pos_y = margin_y + pos_y * (1 - 2 * margin_y);
	return pos;
}
static PyObject *
pyrgb_to_hsl(PyObject *self, PyObject *args)
{
    double r,g,b,a=1.0,h,l,s;
    if(!PyArg_ParseTuple(
	   args,
	   "ddd|d",
	   &r,&g,&b,&a))
    {
	return NULL;
    }

    rgb_to_hsl(r,g,b,&h,&s,&l);

    return Py_BuildValue(
	"(dddd)",
	h,s,l,a);
}
Esempio n. 5
0
/// @brief Constructor 
/// @param _fps    
/// @param frames  
/// @param _width  
/// @param _height 
/// @param colour  
/// @param pattern 
///
void DummyVideoProvider::Create(double _fps, int frames, int _width, int _height, const wxColour &colour, bool pattern) {
	lastFrame = -1;
	framecount = frames;
	fps = _fps;
	width = _width;
	height = _height;

	frame = AegiVideoFrame(width,height);
	unsigned char *dst = frame.data;
	unsigned char r = colour.Red(), g = colour.Green(), b = colour.Blue();

	unsigned char h, s, l, lr, lg, lb; // light variants
	rgb_to_hsl(r, g, b, &h, &s, &l);
	l += 24;
	if (l < 24) l -= 48;
	hsl_to_rgb(h, s, l, &lr, &lg, &lb);

	if (pattern) {
		int ppitch = frame.pitch / frame.GetBpp();
		for (unsigned int y = 0; y < frame.h; ++y) {
			if ((y / 8) & 1) {
				for (int x = 0; x < ppitch; ++x) {
					if ((x / 8) & 1) {
						*dst++ = b;
						*dst++ = g;
						*dst++ = r;
						*dst++ = 0;
					}
					else {
						*dst++ = lb;
						*dst++ = lg;
						*dst++ = lr;
						*dst++ = 0;
					}
				}
			}
			else {
				for (int x = 0; x < ppitch; ++x) {
					if ((x / 8) & 1) {
						*dst++ = lb;
						*dst++ = lg;
						*dst++ = lr;
						*dst++ = 0;
					}
					else {
						*dst++ = b;
						*dst++ = g;
						*dst++ = r;
						*dst++ = 0;
					}
				}
			}
		}
	}
	else {
		for (int i=frame.pitch*frame.h/frame.GetBpp();--i>=0;) {
			*dst++ = b;
			*dst++ = g;
			*dst++ = r;
			*dst++ = 0;
		}
	}
}