mirror of https://github.com/GNOME/gimp.git
app: add gimp_gegl_rectangle_align_to_tile_grid()
... which expands a GeglRectangle, such that it's aligned to the tile grid of a given GeglBuffer.
This commit is contained in:
parent
f27b38808f
commit
69e5f783c5
|
@ -25,6 +25,8 @@
|
|||
#include <gegl.h>
|
||||
#include <gegl-plugin.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "gimp-gegl-types.h"
|
||||
|
||||
#include "core/gimpprogress.h"
|
||||
|
@ -154,3 +156,37 @@ gimp_gegl_param_spec_has_key (GParamSpec *pspec,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_gegl_rectangle_align_to_tile_grid (GeglRectangle *dest,
|
||||
const GeglRectangle *src,
|
||||
GeglBuffer *buffer)
|
||||
{
|
||||
gint shift_x;
|
||||
gint shift_y;
|
||||
gint tile_width;
|
||||
gint tile_height;
|
||||
GeglRectangle rect;
|
||||
|
||||
g_return_if_fail (dest != NULL);
|
||||
g_return_if_fail (src != NULL);
|
||||
g_return_if_fail (GEGL_IS_BUFFER (buffer));
|
||||
|
||||
g_object_get (buffer,
|
||||
"shift-x", &shift_x,
|
||||
"shift-y", &shift_y,
|
||||
"tile-width", &tile_width,
|
||||
"tile-height", &tile_height,
|
||||
NULL);
|
||||
|
||||
rect.x = (gint) floor ((gdouble) (src->x + shift_x) /
|
||||
tile_width) * tile_width;
|
||||
rect.y = (gint) floor ((gdouble) (src->y + shift_y) /
|
||||
tile_height) * tile_height;
|
||||
rect.width = (gint) ceil ((gdouble) (src->x + src->width + shift_x) /
|
||||
tile_width) * tile_width - rect.x;
|
||||
rect.height = (gint) ceil ((gdouble) (src->y + src->height + shift_y) /
|
||||
tile_height) * tile_height - rect.y;
|
||||
|
||||
*dest = rect;
|
||||
}
|
||||
|
|
|
@ -22,22 +22,26 @@
|
|||
#define __GIMP_GEGL_UTILS_H__
|
||||
|
||||
|
||||
GType gimp_gegl_get_op_enum_type (const gchar *operation,
|
||||
const gchar *property);
|
||||
GType gimp_gegl_get_op_enum_type (const gchar *operation,
|
||||
const gchar *property);
|
||||
|
||||
GeglColor * gimp_gegl_color_new (const GimpRGB *rgb,
|
||||
const Babl *space);
|
||||
GeglColor * gimp_gegl_color_new (const GimpRGB *rgb,
|
||||
const Babl *space);
|
||||
|
||||
void gimp_gegl_progress_connect (GeglNode *node,
|
||||
GimpProgress *progress,
|
||||
const gchar *text);
|
||||
void gimp_gegl_progress_connect (GeglNode *node,
|
||||
GimpProgress *progress,
|
||||
const gchar *text);
|
||||
|
||||
const Babl * gimp_gegl_node_get_format (GeglNode *node,
|
||||
const gchar *pad_name);
|
||||
const Babl * gimp_gegl_node_get_format (GeglNode *node,
|
||||
const gchar *pad_name);
|
||||
|
||||
gboolean gimp_gegl_param_spec_has_key (GParamSpec *pspec,
|
||||
const gchar *key,
|
||||
const gchar *value);
|
||||
gboolean gimp_gegl_param_spec_has_key (GParamSpec *pspec,
|
||||
const gchar *key,
|
||||
const gchar *value);
|
||||
|
||||
void gimp_gegl_rectangle_align_to_tile_grid (GeglRectangle *dest,
|
||||
const GeglRectangle *src,
|
||||
GeglBuffer *buffer);
|
||||
|
||||
|
||||
#endif /* __GIMP_GEGL_UTILS_H__ */
|
||||
|
|
Loading…
Reference in New Issue