~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/sys/image/region.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)Region handling.
  2  * @(#)Imregion is {int lx, ly; int ux, uy; }
  3  * @(#)Ie (top left), (bottom right)
  4  */
  5 
  6 #include <stdio.h>
  7 #include <tina/sys.h>
  8 #include <tina/sys_types.h>
  9 #include <tina/sys_gen.h>
 10 #include <tina/sysfuncs.h>
 11 #include <tina/math.h>
 12 
 13 Imregion *roi_alloc(int lx, int ly, int ux, int uy)
 14 {
 15     Imregion *roi = ts_ralloc(Imregion);
 16 
 17     roi->lx = lx;
 18     roi->ly = ly;
 19     roi->ux = ux;
 20     roi->uy = uy;
 21     return (roi);
 22 }
 23 
 24 Imregion *roi_copy(Imregion * roi)
 25 {
 26     Imregion *copy;
 27 
 28     if (roi == NULL)
 29         return (NULL);
 30 
 31     copy = ts_ralloc(Imregion);
 32 
 33     copy->lx = roi->lx;
 34     copy->ly = roi->ly;
 35     copy->ux = roi->ux;
 36     copy->uy = roi->uy;
 37     return (copy);
 38 }
 39 
 40 void    roi_update(Imregion * roi, Imregion * copy)
 41 {
 42     if (roi == NULL || copy == NULL)
 43         return;
 44 
 45     copy->lx = roi->lx;
 46     copy->ly = roi->ly;
 47     copy->ux = roi->ux;
 48     copy->uy = roi->uy;
 49 }
 50 
 51 Imregion *roi_inter(Imregion * r1, Imregion * r2)
 52 {
 53     int     lx, ly, ux, uy;
 54 
 55     if (r1 == NULL || r2 == NULL)
 56         return (NULL);
 57 
 58     lx = MAX(r1->lx, r2->lx);
 59     ly = MAX(r1->ly, r2->ly);
 60     ux = MIN(r1->ux, r2->ux);
 61     uy = MIN(r1->uy, r2->uy);
 62 
 63     if (lx >= ux || ly >= uy)
 64         return (NULL);
 65     return (roi_alloc(lx, ly, ux, uy));
 66 }
 67 
 68 Imregion *roi_outer(Imregion * r1, Imregion * r2)
 69 {
 70     int     lx, ly, ux, uy;
 71 
 72     if (r1 == NULL || r2 == NULL)
 73         return (NULL);
 74 
 75     lx = MIN(r1->lx, r2->lx);
 76     ly = MIN(r1->ly, r2->ly);
 77     ux = MAX(r1->ux, r2->ux);
 78     uy = MAX(r1->uy, r2->uy);
 79 
 80     if (lx >= ux || ly >= uy)
 81         return (NULL);
 82     return (roi_alloc(lx, ly, ux, uy));
 83 }
 84 
 85 int     roi_inregion(Imregion * region, int x, int y)
 86 {
 87     if (region == NULL)
 88         return (0);
 89 
 90     return (x >= region->lx && x < region->ux && y >= region->ly && y < region->uy);
 91 }
 92 
 93 
 94 /* Fill in the fields of a region of interest. */
 95 void    roi_fill(Imregion * roi, int lx, int ly, int ux, int uy)
 96 {
 97     roi->lx = lx;
 98     roi->ly = ly;
 99     roi->ux = ux;
100     roi->uy = uy;
101 }
102 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.