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

Linux Cross Reference
Tina6/tina-tools/tinatool/draw/drawTv_mask.c

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

  1 /*********
  2  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  3  * University of Manchester, UK.  All rights reserved.
  4  * 
  5  * Redistribution and use in source and binary forms, with or without modification, 
  6  * are permitted provided that the following conditions are met:
  7  * 
  8  *   . Redistributions of source code must retain the above copyright notice, 
  9  *     this list of conditions and the following disclaimer.
 10  *    
 11  *   . Redistributions in binary form must reproduce the above copyright notice,
 12  *     this list of conditions and the following disclaimer in the documentation 
 13  *     and/or other materials provided with the distribution.
 14  * 
 15  *   . Neither the name of the University of Manchester nor the names of its
 16  *     contributors may be used to endorse or promote products derived from this 
 17  *     software without specific prior written permission.
 18  * 
 19  * 
 20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 30  * POSSIBILITY OF SUCH DAMAGE.
 31  *
 32  **********
 33  *
 34  * Program :    TINA
 35  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/draw/drawTv_mask.c,v $
 36  * Date    :  $Date: 2003/10/01 16:02:47 $
 37  * Version :  $Revision: 1.2 $
 38  * CVS Id  :  $Id: drawTv_mask.c,v 1.2 2003/10/01 16:02:47 tony Exp $
 39  *
 40  * Author  :  Legacy TINA, paul.bromiley@manchester.ac.uk
 41  *
 42  * Notes :    The corresponding gdk file (gphxGdk_mask.c) has some problems: it 
 43  *            contains files that do not check for NULL arguments.  All of the
 44  *            mask stuff will have to be changed in the near future anyway, in 
 45  *            order to upgrade to Gtk 3 (which will eliminate all of the gdk 
 46  *            image, pixmap and bitmap stuff in favour of Cairo surfaces) and 
 47  *            so I have temporarily fixed the problems here by checking all 
 48  *            Tvs, Tv_screens and masks.
 49  *
 50  *********
 51 */
 52 
 53 #include "drawTv_mask.h"
 54 
 55 #if HAVE_CONFIG_H
 56   #include <config.h>
 57 #endif
 58 
 59 #include <tina/sys/sysDef.h>
 60 #include <tina/sys/sysPro.h>
 61 #include <tina/math/mathDef.h>
 62 #include <tina/math/mathPro.h>
 63 #include <tinatool/draw/draw_TvDef.h>
 64 #include <tinatool/gphx/gphxPro.h>
 65 
 66 extern Ipos tv_proj2(Tv *, Vec2);
 67 
 68 void   *tv_mask_get(Tv * tv, int lx, int ly, int ux, int uy)
 69 {
 70     if (tv == NULL) return NULL;
 71     if (tv->tv_screen==NULL) return NULL;
 72 
 73     return ((void *) tv_screen_mask_get(tv->tv_screen, lx, ly, ux, uy));
 74 }
 75 
 76 void    tv_mask_use(Tv * tv, void *mask)
 77 {
 78     if (tv == NULL || mask==NULL) return;
 79     if (tv->tv_screen==NULL) return;
 80 
 81     tv_screen_mask_use(tv->tv_screen, mask);
 82 }
 83 
 84 void    tv_mask_point(Tv * tv, void *mask, Ipos pos, int bit)
 85 {
 86     if (tv == NULL || mask==NULL) return;
 87     if (tv->tv_screen==NULL) return;
 88 
 89     tv_screen_mask_point(tv->tv_screen, mask, pos, bit);
 90 }
 91 
 92 void *tv_clip_mask_get(Tv * tv, int lx, int ly, int ux, int uy)
 93 {
 94     void *mask = tv_mask_get(tv, lx, ly, ux, uy);
 95     int x, y;
 96 
 97     if(mask==NULL) return NULL;
 98 
 99     for(x = lx; x < ux; x++)
100         for(y = ly; y < uy; y++)
101             tv_mask_point(tv, mask, ipos(x, y), 1);
102     return(mask);
103 }
104 
105 void *tv_clip_mask2_get(Tv * tv, Vec2 p1, Vec2 p2)
106 {
107     Ipos q1 = tv_proj2(tv, p1);
108     Ipos q2 = tv_proj2(tv, p2);
109     int lx = ipos_x(q1);
110     int ly = ipos_y(q1);
111     int ux = ipos_x(q2);
112     int uy = ipos_y(q2), x, y;
113     void *mask;
114     if(lx > ux)
115         SWAP(int, lx, ux);
116     if(ly > uy)
117         SWAP(int, ly, uy);
118     mask = tv_mask_get(tv, lx, ly, ux, uy);
119 
120     if(mask==NULL) return NULL;
121 
122     for(x = lx; x < ux; x++)
123         for(y = ly; y < uy; y++)
124             tv_mask_point(tv, mask, ipos(x, y), 1);
125     return(mask);
126 }
127 
128 void    tv_mask_free(Tv * tv, void *mask)
129 {
130     if (tv == NULL || mask==NULL) return;
131     if (tv->tv_screen==NULL) return;
132 
133     tv_screen_mask_free(tv->tv_screen, mask);
134 }
135 

~ [ 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.