1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef __GIMP_DISPLAY_SHELL_TRANSFORM_H__ 19 #define __GIMP_DISPLAY_SHELL_TRANSFORM_H__ 20 21 22 /* zoom: functions to transform from image space to unrotated display 23 * space and back, taking into account scroll offset and scale 24 */ 25 26 void gimp_display_shell_zoom_coords (GimpDisplayShell *shell, 27 const GimpCoords *image_coords, 28 GimpCoords *display_coords); 29 void gimp_display_shell_unzoom_coords (GimpDisplayShell *shell, 30 const GimpCoords *display_coords, 31 GimpCoords *image_coords); 32 33 void gimp_display_shell_zoom_xy (GimpDisplayShell *shell, 34 gdouble x, 35 gdouble y, 36 gint *nx, 37 gint *ny); 38 void gimp_display_shell_unzoom_xy (GimpDisplayShell *shell, 39 gint x, 40 gint y, 41 gint *nx, 42 gint *ny, 43 gboolean round); 44 45 void gimp_display_shell_zoom_xy_f (GimpDisplayShell *shell, 46 gdouble x, 47 gdouble y, 48 gdouble *nx, 49 gdouble *ny); 50 void gimp_display_shell_unzoom_xy_f (GimpDisplayShell *shell, 51 gdouble x, 52 gdouble y, 53 gdouble *nx, 54 gdouble *ny); 55 56 void gimp_display_shell_zoom_segments (GimpDisplayShell *shell, 57 const GimpBoundSeg *src_segs, 58 GimpSegment *dest_segs, 59 gint n_segs, 60 gdouble offset_x, 61 gdouble offset_y); 62 63 64 /* rotate: functions to transform from unrotated and unflipped but 65 * zoomed display space to rotated and filpped display space and back 66 */ 67 68 void gimp_display_shell_rotate_coords (GimpDisplayShell *shell, 69 const GimpCoords *image_coords, 70 GimpCoords *display_coords); 71 void gimp_display_shell_unrotate_coords (GimpDisplayShell *shell, 72 const GimpCoords *display_coords, 73 GimpCoords *image_coords); 74 75 void gimp_display_shell_rotate_xy (GimpDisplayShell *shell, 76 gdouble x, 77 gdouble y, 78 gint *nx, 79 gint *ny); 80 void gimp_display_shell_unrotate_xy (GimpDisplayShell *shell, 81 gint x, 82 gint y, 83 gint *nx, 84 gint *ny); 85 86 void gimp_display_shell_rotate_xy_f (GimpDisplayShell *shell, 87 gdouble x, 88 gdouble y, 89 gdouble *nx, 90 gdouble *ny); 91 void gimp_display_shell_unrotate_xy_f (GimpDisplayShell *shell, 92 gdouble x, 93 gdouble y, 94 gdouble *nx, 95 gdouble *ny); 96 97 void gimp_display_shell_rotate_bounds (GimpDisplayShell *shell, 98 gdouble x1, 99 gdouble y1, 100 gdouble x2, 101 gdouble y2, 102 gdouble *nx1, 103 gdouble *ny1, 104 gdouble *nx2, 105 gdouble *ny2); 106 void gimp_display_shell_unrotate_bounds (GimpDisplayShell *shell, 107 gdouble x1, 108 gdouble y1, 109 gdouble x2, 110 gdouble y2, 111 gdouble *nx1, 112 gdouble *ny1, 113 gdouble *nx2, 114 gdouble *ny2); 115 116 117 /* transform: functions to transform from image space to rotated 118 * display space and back, taking into account scroll offset, scale, 119 * rotation and flipping 120 */ 121 122 void gimp_display_shell_transform_coords (GimpDisplayShell *shell, 123 const GimpCoords *image_coords, 124 GimpCoords *display_coords); 125 void gimp_display_shell_untransform_coords (GimpDisplayShell *shell, 126 const GimpCoords *display_coords, 127 GimpCoords *image_coords); 128 129 void gimp_display_shell_transform_xy (GimpDisplayShell *shell, 130 gdouble x, 131 gdouble y, 132 gint *nx, 133 gint *ny); 134 void gimp_display_shell_untransform_xy (GimpDisplayShell *shell, 135 gint x, 136 gint y, 137 gint *nx, 138 gint *ny, 139 gboolean round); 140 141 void gimp_display_shell_transform_xy_f (GimpDisplayShell *shell, 142 gdouble x, 143 gdouble y, 144 gdouble *nx, 145 gdouble *ny); 146 void gimp_display_shell_untransform_xy_f (GimpDisplayShell *shell, 147 gdouble x, 148 gdouble y, 149 gdouble *nx, 150 gdouble *ny); 151 152 void gimp_display_shell_transform_bounds (GimpDisplayShell *shell, 153 gdouble x1, 154 gdouble y1, 155 gdouble x2, 156 gdouble y2, 157 gdouble *nx1, 158 gdouble *ny1, 159 gdouble *nx2, 160 gdouble *ny2); 161 void gimp_display_shell_untransform_bounds (GimpDisplayShell *shell, 162 gdouble x1, 163 gdouble y1, 164 gdouble x2, 165 gdouble y2, 166 gdouble *nx1, 167 gdouble *ny1, 168 gdouble *nx2, 169 gdouble *ny2); 170 171 void gimp_display_shell_transform_bounds_with_scale (GimpDisplayShell *shell, 172 gdouble scale, 173 gdouble x1, 174 gdouble y1, 175 gdouble x2, 176 gdouble y2, 177 gdouble *nx1, 178 gdouble *ny1, 179 gdouble *nx2, 180 gdouble *ny2); 181 void gimp_display_shell_untransform_bounds_with_scale (GimpDisplayShell *shell, 182 gdouble scale, 183 gdouble x1, 184 gdouble y1, 185 gdouble x2, 186 gdouble y2, 187 gdouble *nx1, 188 gdouble *ny1, 189 gdouble *nx2, 190 gdouble *ny2); 191 192 void gimp_display_shell_untransform_viewport (GimpDisplayShell *shell, 193 gboolean clip, 194 gint *x, 195 gint *y, 196 gint *width, 197 gint *height); 198 199 200 #endif /* __GIMP_DISPLAY_SHELL_TRANSFORM_H__ */ 201