diff options
author | Sebastian Rasmussen <sebras@hotmail.com> | 2011-01-01 18:07:44 +0000 |
---|---|---|
committer | Sebastian Rasmussen <sebras@hotmail.com> | 2011-01-01 18:07:44 +0000 |
commit | b3e408df07788431d4460c444f563cc6c74e7386 (patch) | |
tree | b80ca51ba72cfca4769df367e5ca879f25f3b3b7 | |
parent | 2df8c37dd01d35820de3d42a571767461a7f628d (diff) | |
download | mupdf-b3e408df07788431d4460c444f563cc6c74e7386.tar.xz |
Support transformation and comparison of bounding boxes.
-rw-r--r-- | fitz/base_geometry.c | 24 | ||||
-rw-r--r-- | fitz/fitz.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c index e0466991..375de12d 100644 --- a/fitz/base_geometry.c +++ b/fitz/base_geometry.c @@ -202,3 +202,27 @@ fz_transformrect(fz_matrix m, fz_rect r) r.y1 = MAX4(s.y, t.y, u.y, v.y); return r; } + +fz_bbox +fz_transformbbox(fz_matrix m, fz_bbox b) +{ + fz_point s, t, u, v; + + if (fz_isinfinitebbox(b)) + return b; + + s.x = b.x0; s.y = b.y0; + t.x = b.x0; t.y = b.y1; + u.x = b.x1; u.y = b.y1; + v.x = b.x1; v.y = b.y0; + s = fz_transformpoint(m, s); + t = fz_transformpoint(m, t); + u = fz_transformpoint(m, u); + v = fz_transformpoint(m, v); + b.x0 = MIN4(s.x, t.x, u.x, v.x); + b.y0 = MIN4(s.y, t.y, u.y, v.y); + b.x1 = MAX4(s.x, t.x, u.x, v.x); + b.y1 = MAX4(s.y, t.y, u.y, v.y); + return b; + +} diff --git a/fitz/fitz.h b/fitz/fitz.h index 1cd4e3fa..f192daa4 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -218,6 +218,8 @@ extern const fz_bbox fz_infinitebbox; #define fz_isemptyrect(r) ((r).x0 == (r).x1) #define fz_isinfiniterect(r) ((r).x0 > (r).x1) +#define fz_isemptybbox(b) ((b).x0 == (b).x1) +#define fz_isinfinitebbox(b) ((b).x0 > (b).x1) struct fz_matrix_s { @@ -258,6 +260,7 @@ fz_bbox fz_unionbbox(fz_bbox a, fz_bbox b); fz_point fz_transformpoint(fz_matrix m, fz_point p); fz_point fz_transformvector(fz_matrix m, fz_point p); fz_rect fz_transformrect(fz_matrix m, fz_rect r); +fz_bbox fz_transformbbox(fz_matrix m, fz_bbox b); /* * Basic crypto functions. |