Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
crop.c File Reference
#include "bauhaus/bauhaus.h"
#include "common/debug.h"
#include "common/imagebuf.h"
#include "common/interpolation.h"
#include "common/math.h"
#include "common/opencl.h"
#include "control/conf.h"
#include "control/control.h"
#include "develop/develop.h"
#include "develop/imageop.h"
#include "develop/imageop_gui.h"
#include "dtgtk/expander.h"
#include "gui/draw.h"
#include "gui/gtk.h"
#include "gui/guides.h"
#include "gui/presets.h"
#include "iop/iop_api.h"
#include <assert.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
+ Include dependency graph for crop.c:

Go to the source code of this file.

Data Structures

struct  dt_iop_crop_aspect_t
 
struct  dt_iop_crop_params_t
 
struct  dt_iop_crop_gui_data_t
 
struct  dt_iop_crop_data_t
 

Typedefs

typedef enum dt_iop_crop_flip_t dt_iop_crop_flip_t
 
typedef struct dt_iop_crop_aspect_t dt_iop_crop_aspect_t
 
typedef struct dt_iop_crop_params_t dt_iop_crop_params_t
 
typedef enum _grab_region_t _grab_region_t
 
typedef struct dt_iop_crop_gui_data_t dt_iop_crop_gui_data_t
 
typedef struct dt_iop_crop_data_t dt_iop_crop_data_t
 

Enumerations

enum  dt_iop_crop_flip_t {
  FLAG_FLIP_HORIZONTAL = 1 << 0 ,
  FLAG_FLIP_VERTICAL = 1 << 1
}
 
enum  _grab_region_t {
  GRAB_CENTER = 0 ,
  GRAB_LEFT = 1 << 0 ,
  GRAB_TOP = 1 << 1 ,
  GRAB_RIGHT = 1 << 2 ,
  GRAB_BOTTOM = 1 << 3 ,
  GRAB_TOP_LEFT = GRAB_TOP | GRAB_LEFT ,
  GRAB_TOP_RIGHT = GRAB_TOP | GRAB_RIGHT ,
  GRAB_BOTTOM_RIGHT = GRAB_BOTTOM | GRAB_RIGHT ,
  GRAB_BOTTOM_LEFT = GRAB_BOTTOM | GRAB_LEFT ,
  GRAB_HORIZONTAL = GRAB_LEFT | GRAB_RIGHT ,
  GRAB_VERTICAL = GRAB_TOP | GRAB_BOTTOM ,
  GRAB_ALL = GRAB_LEFT | GRAB_TOP | GRAB_RIGHT | GRAB_BOTTOM ,
  GRAB_NONE = 1 << 4
}
 

Functions

int legacy_params (dt_iop_module_t *self, const void *const old_params, const int old_version, void *new_params, const int new_version)
 
const char * name ()
 
const char * aliases ()
 
const char ** description (struct dt_iop_module_t *self)
 
int default_group ()
 
int flags ()
 
int operation_tags ()
 
int operation_tags_filter ()
 
int default_colorspace (dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
 
static void _params_to_gui (dt_iop_crop_params_t *p, dt_iop_crop_gui_data_t *g)
 
static void _commit_box (dt_iop_module_t *self, dt_iop_crop_gui_data_t *g, dt_iop_crop_params_t *p)
 
static gboolean _set_max_clip (dt_dev_pixelpipe_t *pipe, struct dt_iop_module_t *self)
 this function initializes the maximum clip rectangle from crop parameters and correct the clip rectangle accordingly in gui.
 
int distort_transform (dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *const restrict points, size_t points_count)
 
int distort_backtransform (dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, float *const restrict points, size_t points_count)
 
void distort_mask (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, const float *const in, float *const out, const dt_iop_roi_t *const roi_in, const dt_iop_roi_t *const roi_out)
 
void modify_roi_out (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, dt_iop_roi_t *roi_out, const dt_iop_roi_t *roi_in)
 
void modify_roi_in (struct dt_iop_module_t *self, const struct dt_dev_pixelpipe_t *pipe, struct dt_dev_pixelpipe_iop_t *piece, const dt_iop_roi_t *roi_out, dt_iop_roi_t *roi_in)
 
int process (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, const void *const ivoid, void *const ovoid)
 
int process_cl (struct dt_iop_module_t *self, const dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece, cl_mem dev_in, cl_mem dev_out)
 
void commit_params (struct dt_iop_module_t *self, dt_iop_params_t *p1, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
gboolean runtime_data_hash (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, const dt_dev_pixelpipe_iop_t *piece)
 
void init_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
void cleanup_pipe (struct dt_iop_module_t *self, dt_dev_pixelpipe_t *pipe, dt_dev_pixelpipe_iop_t *piece)
 
static float _aspect_ratio_get (dt_iop_module_t *self, GtkWidget *combo)
 
static void _aspect_apply (dt_iop_module_t *self, _grab_region_t grab)
 
void reload_defaults (dt_iop_module_t *self)
 
gboolean has_defaults (struct dt_iop_module_t *self)
 
static void _float_to_fract (const char *num, int *n, int *d)
 
static void _event_aspect_presets_changed (GtkWidget *combo, dt_iop_module_t *self)
 
void gui_changed (dt_iop_module_t *self, GtkWidget *w, void *previous)
 
void gui_reset (struct dt_iop_module_t *self)
 
void gui_update (struct dt_iop_module_t *self)
 
static void _event_key_swap (dt_iop_module_t *self)
 
static void _enter_edit_mode (GtkToggleButton *button, struct dt_iop_module_t *self)
 
static void _event_commit_clicked (GtkButton *button, dt_iop_module_t *self)
 
static void _event_aspect_flip (GtkWidget *button, dt_iop_module_t *self)
 
static gint _aspect_ratio_cmp (const dt_iop_crop_aspect_t *a, const dt_iop_crop_aspect_t *b)
 
static gchar * _aspect_format (gchar *original, int adim, int bdim)
 
void gui_init (struct dt_iop_module_t *self)
 
static void _aspect_free (gpointer data)
 
void gui_cleanup (struct dt_iop_module_t *self)
 
static _grab_region_t _gui_get_grab (float pzx, float pzy, dt_iop_crop_gui_data_t *g, const float border, const float wd, const float ht)
 
void gui_post_expose (struct dt_iop_module_t *self, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
 
int mouse_moved (struct dt_iop_module_t *self, double x, double y, double pressure, int which)
 
int button_released (struct dt_iop_module_t *self, double x, double y, int which, uint32_t state)
 
int button_pressed (struct dt_iop_module_t *self, double x, double y, double pressure, int which, int type, uint32_t state)
 
int mouse_leave (struct dt_iop_module_t *self)
 

Typedef Documentation

◆ _grab_region_t

◆ dt_iop_crop_aspect_t

◆ dt_iop_crop_data_t

◆ dt_iop_crop_flip_t

flip guides H/V

◆ dt_iop_crop_gui_data_t

◆ dt_iop_crop_params_t

Enumeration Type Documentation

◆ _grab_region_t

Enumerator
GRAB_CENTER 
GRAB_LEFT 
GRAB_TOP 
GRAB_RIGHT 
GRAB_BOTTOM 
GRAB_TOP_LEFT 
GRAB_TOP_RIGHT 
GRAB_BOTTOM_RIGHT 
GRAB_BOTTOM_LEFT 
GRAB_HORIZONTAL 
GRAB_VERTICAL 
GRAB_ALL 
GRAB_NONE 

Definition at line 86 of file crop.c.

◆ dt_iop_crop_flip_t

flip guides H/V

Enumerator
FLAG_FLIP_HORIZONTAL 
FLAG_FLIP_VERTICAL 

Definition at line 64 of file crop.c.

Function Documentation

◆ _aspect_apply()

◆ _aspect_format()

static gchar * _aspect_format ( gchar *  original,
int  adim,
int  bdim 
)
static

Definition at line 1102 of file crop.c.

Referenced by gui_init().

◆ _aspect_free()

static void _aspect_free ( gpointer  data)
static

Definition at line 1300 of file crop.c.

References dt_free, and dt_iop_crop_aspect_t::name.

Referenced by gui_cleanup().

◆ _aspect_ratio_cmp()

static gint _aspect_ratio_cmp ( const dt_iop_crop_aspect_t a,
const dt_iop_crop_aspect_t b 
)
static

Definition at line 1081 of file crop.c.

References dt_iop_crop_aspect_t::d, MAX, MIN, and dt_iop_crop_aspect_t::n.

Referenced by gui_init().

◆ _aspect_ratio_get()

◆ _commit_box()

◆ _enter_edit_mode()

◆ _event_aspect_flip()

static void _event_aspect_flip ( GtkWidget button,
dt_iop_module_t self 
)
static

Definition at line 1076 of file crop.c.

References _event_key_swap().

Referenced by gui_init().

◆ _event_aspect_presets_changed()

◆ _event_commit_clicked()

static void _event_commit_clicked ( GtkButton *  button,
dt_iop_module_t self 
)
static

◆ _event_key_swap()

static void _event_key_swap ( dt_iop_module_t self)
static

Definition at line 1002 of file crop.c.

References _aspect_apply(), GRAB_ALL, gui_changed(), p, and dt_iop_module_t::params.

Referenced by _event_aspect_flip().

◆ _float_to_fract()

static void _float_to_fract ( const char *  num,
int *  n,
int *  d 
)
static

Definition at line 714 of file crop.c.

References d, FALSE, k, n, p, and TRUE.

Referenced by _event_aspect_presets_changed().

◆ _gui_get_grab()

static _grab_region_t _gui_get_grab ( float  pzx,
float  pzy,
dt_iop_crop_gui_data_t g,
const float  border,
const float  wd,
const float  ht 
)
static

Definition at line 1316 of file crop.c.

References g, GRAB_BOTTOM, GRAB_CENTER, GRAB_LEFT, GRAB_NONE, GRAB_RIGHT, and GRAB_TOP.

Referenced by button_pressed(), gui_post_expose(), and mouse_moved().

◆ _params_to_gui()

static void _params_to_gui ( dt_iop_crop_params_t p,
dt_iop_crop_gui_data_t g 
)
static

Definition at line 192 of file crop.c.

References g, and p.

Referenced by _enter_edit_mode(), and gui_update().

◆ _set_max_clip()

static gboolean _set_max_clip ( dt_dev_pixelpipe_t pipe,
struct dt_iop_module_t self 
)
static

this function initializes the maximum clip rectangle from crop parameters and correct the clip rectangle accordingly in gui.

WARNING: this function assumes that the current gui modification are committed to params.

Parameters
selfthe current module data
Returns
gboolean TRUE on success, FALSE otherwise

Definition at line 262 of file crop.c.

References dt_dev_pixelpipe_iop_t::buf_out, dt_dev_pixelpipe_t::dev, dt_dev_coordinates_preview_abs_to_image_norm(), dt_dev_distort_get_iop_pipe(), dt_dev_distort_transform_plus(), DT_DEV_TRANSFORM_DIR_FORW_EXCL, FALSE, g, dt_iop_module_t::gui_data, dt_iop_roi_t::height, dt_iop_module_t::iop_order, IS_NULL_PTR, p, dt_iop_module_t::params, TRUE, and dt_iop_roi_t::width.

Referenced by gui_post_expose(), and mouse_moved().

◆ aliases()

const char * aliases ( )

Definition at line 153 of file crop.c.

◆ button_pressed()

◆ button_released()

int button_released ( struct dt_iop_module_t self,
double  x,
double  y,
int  which,
uint32_t  state 
)
Todo:
: is this the right cursor? there should be a "restore_cursor" function

Definition at line 1634 of file crop.c.

References dt_control_change_cursor, FALSE, g, GRAB_CENTER, gui_changed(), and dt_iop_module_t::gui_data.

◆ cleanup_pipe()

void cleanup_pipe ( struct dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

Definition at line 449 of file crop.c.

References dt_dev_pixelpipe_iop_t::data, and dt_free_align.

◆ commit_params()

void commit_params ( struct dt_iop_module_t self,
dt_iop_params_t p1,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

Definition at line 409 of file crop.c.

References CLAMPF, d, dt_dev_pixelpipe_iop_t::data, g, dt_iop_module_t::gui_data, IS_NULL_PTR, and p.

◆ default_colorspace()

int default_colorspace ( dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece 
)

Definition at line 187 of file crop.c.

References IOP_CS_RGB.

◆ default_group()

int default_group ( )

Definition at line 165 of file crop.c.

References IOP_GROUP_EFFECTS.

◆ description()

const char ** description ( struct dt_iop_module_t self)

Definition at line 158 of file crop.c.

References dt_iop_set_description().

◆ distort_backtransform()

int distort_backtransform ( dt_iop_module_t self,
const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
float *const restrict  points,
size_t  points_count 
)

◆ distort_mask()

void distort_mask ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
struct dt_dev_pixelpipe_iop_t piece,
const float *const  in,
float *const  out,
const dt_iop_roi_t *const  roi_in,
const dt_iop_roi_t *const  roi_out 
)

Definition at line 333 of file crop.c.

References dt_iop_copy_image_roi(), out, TRUE, and void().

◆ distort_transform()

int distort_transform ( dt_iop_module_t self,
const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
float *const restrict  points,
size_t  points_count 
)

◆ flags()

◆ gui_changed()

◆ gui_cleanup()

void gui_cleanup ( struct dt_iop_module_t self)

Definition at line 1307 of file crop.c.

References _aspect_free(), g, dt_iop_module_t::gui_data, and IOP_GUI_FREE.

◆ gui_init()

◆ gui_post_expose()

◆ gui_reset()

void gui_reset ( struct dt_iop_module_t self)

Definition at line 942 of file crop.c.

References dt_conf_set_int().

◆ gui_update()

◆ has_defaults()

gboolean has_defaults ( struct dt_iop_module_t self)

Definition at line 706 of file crop.c.

References d, dt_iop_module_t::default_params, p, and dt_iop_module_t::params.

◆ init_pipe()

void init_pipe ( struct dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
dt_dev_pixelpipe_iop_t piece 
)

◆ legacy_params()

int legacy_params ( dt_iop_module_t self,
const void *const  old_params,
const int  old_version,
void new_params,
const int  new_version 
)

Definition at line 142 of file crop.c.

◆ modify_roi_in()

void modify_roi_in ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
struct dt_dev_pixelpipe_iop_t piece,
const dt_iop_roi_t roi_out,
dt_iop_roi_t roi_in 
)

◆ modify_roi_out()

void modify_roi_out ( struct dt_iop_module_t self,
const struct dt_dev_pixelpipe_t pipe,
struct dt_dev_pixelpipe_iop_t piece,
dt_iop_roi_t roi_out,
const dt_iop_roi_t roi_in 
)

◆ mouse_leave()

int mouse_leave ( struct dt_iop_module_t self)

Definition at line 1728 of file crop.c.

References dt_control_change_cursor, FALSE, g, GRAB_NONE, and dt_iop_module_t::gui_data.

◆ mouse_moved()

◆ name()

const char * name ( )

Definition at line 148 of file crop.c.

Referenced by gui_init().

◆ operation_tags()

int operation_tags ( )

Definition at line 176 of file crop.c.

References IOP_TAG_CLIPPING, and IOP_TAG_DISTORT.

◆ operation_tags_filter()

int operation_tags_filter ( )

Definition at line 181 of file crop.c.

References IOP_TAG_DECORATION.

◆ process()

int process ( struct dt_iop_module_t self,
const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
const void *const  ivoid,
void *const  ovoid 
)

◆ process_cl()

int process_cl ( struct dt_iop_module_t self,
const dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece,
cl_mem  dev_in,
cl_mem  dev_out 
)

◆ reload_defaults()

void reload_defaults ( dt_iop_module_t self)

◆ runtime_data_hash()

gboolean runtime_data_hash ( struct dt_iop_module_t self,
dt_dev_pixelpipe_t pipe,
const dt_dev_pixelpipe_iop_t piece 
)

Definition at line 434 of file crop.c.

References TRUE, and void().