コード例 #1
0
ファイル: map-object-image.c プロジェクト: jdburton/gimp-osx
GimpRGB
get_image_color (gdouble  u,
		 gdouble  v,
		 gint    *inside)
{
  gint    x1, y1, x2, y2;
  GimpRGB p[4];

  pos_to_int (u, v, &x1, &y1);

  if (mapvals.tiled == TRUE)
    {
      *inside = TRUE;

      if (x1 < 0) x1 = (width-1) - (-x1 % width);
      else        x1 = x1 % width;

      if (y1 < 0) y1 = (height-1) - (-y1 % height);
      else        y1 = y1 % height;

      x2 = (x1 + 1) % width;
      y2 = (y1 + 1) % height;

      p[0] = peek (x1, y1);
      p[1] = peek (x2, y1);
      p[2] = peek (x1, y2);
      p[3] = peek (x2, y2);

      return gimp_bilinear_rgba (u * width, v * height, p);
    }

  if (checkbounds (x1, y1) == FALSE)
    {
      *inside =FALSE;

      return background;
    }

  x2 = (x1 + 1);
  y2 = (y1 + 1);

  if (checkbounds (x2, y2) == FALSE)
   {
     *inside = TRUE;

     return peek (x1, y1);
   }

  *inside=TRUE;

  p[0] = peek (x1, y1);
  p[1] = peek (x2, y1);
  p[2] = peek (x1, y2);
  p[3] = peek (x2, y2);

  return gimp_bilinear_rgba (u * width, v * height, p);
}
コード例 #2
0
ファイル: map-object-image.c プロジェクト: jdburton/gimp-osx
GimpRGB
get_cylinder_image_color (gint    image,
			  gdouble u,
			  gdouble v)
{
  gint    w, h;
  gint    x1, y1, x2, y2;
  GimpRGB p[4];

  w = cylinder_drawables[image]->width;
  h = cylinder_drawables[image]->height;

  x1 = (gint) ((u * (gdouble) w));
  y1 = (gint) ((v * (gdouble) h));

  if (checkbounds_cylinder_image (image, x1, y1) == FALSE)
    return background;

  x2 = (x1 + 1);
  y2 = (y1 + 1);

  if (checkbounds_cylinder_image (image, x2, y2) == FALSE)
    return peek_cylinder_image (image, x1,y1);

  p[0] = peek_cylinder_image (image, x1, y1);
  p[1] = peek_cylinder_image (image, x2, y1);
  p[2] = peek_cylinder_image (image, x1, y2);
  p[3] = peek_cylinder_image (image, x2, y2);

  return gimp_bilinear_rgba (u * w, v * h, p);
}
コード例 #3
0
ファイル: gimpcolormodule.c プロジェクト: jiapei100/gimp
static PyObject *
pygimp_bilinear_color(PyObject *self, PyObject *args, PyObject *kwargs, gboolean with_alpha)
{
    gdouble x, y;
    GimpRGB values[4];
    GimpRGB rgb;
    PyObject *py_values, *v;
    int i, success;
    static char *kwlist[] = { "x", "y", "values", NULL };

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
                                     with_alpha ? "ddO:bilinear_rgba"
                                               : "ddO:bilinear_rgb",
                                     kwlist,
                                     &x, &y, &py_values))
        return NULL;

    if (!PySequence_Check(py_values) || PySequence_Size(py_values) != 4) {
        PyErr_SetString(PyExc_TypeError, "values is not a sequence of 4 items");
        return NULL;
    }

    for (i = 0; i < 4; i++) {
        v = PySequence_GetItem(py_values, i);
        success = pygimp_rgb_from_pyobject(v, &values[i]);
        Py_DECREF(v);
        if (!success) {
            PyErr_Format(PyExc_TypeError, "values[%d] is not a GimpRGB", i);
            return NULL;
        }
    }

    if (with_alpha)
        rgb = gimp_bilinear_rgba(x, y, values);
    else
        rgb = gimp_bilinear_rgb(x, y, values);

    return pygimp_rgb_new(&rgb);
}
コード例 #4
0
ファイル: van-gogh-lic.c プロジェクト: AdamGrzonkowski/gimp-1
static void
getpixel (GimpPixelRgn *src_rgn,
          GimpRGB      *p,
          gdouble       u,
          gdouble       v)
{
  register gint x1, y1, x2, y2;
  gint width, height;
  static GimpRGB pp[4];

  width = src_rgn->w;
  height = src_rgn->h;

  x1 = (gint)u;
  y1 = (gint)v;

  if (x1 < 0)
    x1 = width - (-x1 % width);
  else
    x1 = x1 % width;

  if (y1 < 0)
    y1 = height - (-y1 % height);
  else
    y1 = y1 % height;

  x2 = (x1 + 1) % width;
  y2 = (y1 + 1) % height;

  peek (src_rgn, x1, y1, &pp[0]);
  peek (src_rgn, x2, y1, &pp[1]);
  peek (src_rgn, x1, y2, &pp[2]);
  peek (src_rgn, x2, y2, &pp[3]);

  if (source_drw_has_alpha)
    *p = gimp_bilinear_rgba (u, v, pp);
  else
    *p = gimp_bilinear_rgb (u, v, pp);
}