rect.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Simple rectangle algebra.
  2. */
  3. /*
  4. This file is part of VIPS.
  5. VIPS is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  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 Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. */
  18. /*
  19. These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
  20. */
  21. #ifndef VIPS_RECT_H
  22. #define VIPS_RECT_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /*__cplusplus*/
  26. typedef struct _VipsRect {
  27. /*< public >*/
  28. int left;
  29. int top;
  30. int width;
  31. int height;
  32. } VipsRect;
  33. #define VIPS_RECT_RIGHT(R) ((R)->left + (R)->width)
  34. #define VIPS_RECT_BOTTOM(R) ((R)->top + (R)->height)
  35. #define VIPS_RECT_HCENTRE(R) ((R)->left + (R)->width / 2)
  36. #define VIPS_RECT_VCENTRE(R) ((R)->top + (R)->height / 2)
  37. gboolean vips_rect_isempty( const VipsRect *r );
  38. gboolean vips_rect_includespoint( const VipsRect *r, int x, int y );
  39. gboolean vips_rect_includesrect( const VipsRect *r1, const VipsRect *r2 );
  40. gboolean vips_rect_equalsrect( const VipsRect *r1, const VipsRect *r2 );
  41. gboolean vips_rect_overlapsrect( const VipsRect *r1, const VipsRect *r2 );
  42. void vips_rect_marginadjust( VipsRect *r, int n );
  43. void vips_rect_intersectrect( const VipsRect *r1, const VipsRect *r2,
  44. VipsRect *out );
  45. void vips_rect_unionrect( const VipsRect *r1, const VipsRect *r2,
  46. VipsRect *out );
  47. VipsRect *vips_rect_dup( const VipsRect *r );
  48. void vips_rect_normalise( VipsRect *r );
  49. #ifdef __cplusplus
  50. }
  51. #endif /*__cplusplus*/
  52. #endif /*VIPS_RECT_H*/