home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI05.ARJ / ictari.05 / C / GEM_TUT / GEMCL6.C < prev   
Text File  |  1987-10-05  |  5KB  |  148 lines

  1. >>>>>>>>>>>>>>>>>>>>>>>>>>>>> MFDB Structure <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  2.                     /* Memory Form Definition Block */
  3. typedef struct fdbstr
  4. {
  5.     long        fd_addr;    /* Form address            */
  6.     int        fd_w;        /* Form width in pixels        */
  7.     int        fd_h;        /* Form height in pixels    */
  8.     int        fd_wdwidth;    /* Form width in memory words    */
  9.     int        fd_stand;    /* Standard form flag        */
  10.     int        fd_nplanes;    /* Number of color planes    */
  11.     int        fd_r1;        /* Dummy locations:        */
  12.     int        fd_r2;        /* Reserved for future use    */
  13.     int        fd_r3;
  14. } MFDB;
  15.  
  16. >>>>>>>>>>>>>>>>>>>>>>> Resource Transform Utilities <<<<<<<<<<<<<<<<<<<<<
  17. /*------------------------------*/
  18. /*    vdi_fix            */
  19. /*------------------------------*/
  20.     VOID
  21. vdi_fix(pfd, theaddr, wb, h)        /* This routine loads the MFDB */
  22.     MFDB        *pfd;        /* Input values are the MFDB's */
  23.     LONG        theaddr;    /* address, the form's address,*/
  24.     WORD        wb, h;        /* the form's width in bytes,  */
  25.     {                /* and the height in pixels    */
  26.     pfd->fww = wb >> 1;
  27.     pfd->fwp = wb << 3;
  28.     pfd->fh = h;
  29.     pfd->np = 1;            /* Monochrome assumed           */
  30.     pfd->mp = theaddr;
  31.     }
  32.  
  33. /*------------------------------*/
  34. /*    vdi_trans        */
  35. /*------------------------------*/
  36.     WORD
  37. vdi_trans(saddr, swb, daddr, dwb, h)     /* Transform the standard form */
  38.     LONG        saddr;        /* pointed at by saddr and     */
  39.     UWORD        swb;        /* store in the form at daddr  */
  40.     LONG        daddr;        /* Byte widths and pixel height*/
  41.     UWORD        dwb;        /* are given               */
  42.     UWORD        h;
  43.     {
  44.     MFDB        src, dst;    /* These are on-the-fly MFDBs  */
  45.  
  46.     vdi_fix(&src, saddr, swb, h);    /* Load the source MFDB           */
  47.     src.ff = TRUE;            /* Set it's std form flag      */
  48.  
  49.     vdi_fix(&dst, daddr, dwb, h);    /* Load the destination MFDB   */
  50.     dst.ff = FALSE;            /* Clear the std flag           */
  51.     vr_trnfm(vdi_handle, &src, &dst );    /* Call the VDI           */
  52.     }
  53.  
  54. /*------------------------------*/
  55. /*    trans_bitblk        */
  56. /*------------------------------*/
  57.     VOID
  58. trans_bitblk(obspec)            /* Transform the image belonging */
  59.     LONG    obspec;            /* to the bitblk pointed to by   */
  60.     {                /* obspec.  This routine may also*/
  61.     LONG    taddr;            /* be used with free images     */
  62.     WORD    wb, hl;
  63.  
  64.     if ( (taddr = LLGET(BI_PDATA(obspec))) == -1L)
  65.         return;            /* Get and validate image address */
  66.     wb = LWGET(BI_WB(obspec));    /* Extract image dimensions      */
  67.     hl = LWGET(BI_HL(obspec));
  68.     vdi_trans(taddr, wb, taddr, wb, hl);    /* Perform a transform      */
  69.     }                    /* in place          */
  70.  
  71. /*------------------------------*/
  72. /*    trans_obj        */
  73. /*------------------------------*/
  74.     VOID
  75. trans_obj(tree, obj)            /* Examine the input object.  If  */
  76.     LONG    tree;            /* it is an icon or image, trans- */
  77.     WORD    obj;            /* form the associated raster      */
  78.     {                /* forms in place.          */
  79.     WORD    type, wb, hl;        /* This routine may be used with  */
  80.     LONG    taddr, obspec;        /* map_tree() to transform an     */
  81.                     /* entire resource tree          */
  82.  
  83.     type = LLOBT(LWGET(OB_TYPE(obj)));        /* Load object type */
  84.     if ( (obspec = LLGET(OB_SPEC(obj))) == -1L)    /* Load and check   */
  85.         return (TRUE);                /* ob_spec pointer  */
  86.     switch (type) {
  87.         case G_IMAGE:
  88.             trans_bitblk(obspec);        /* Transform image  */
  89.             return (TRUE);
  90.         case G_ICON:                /* Load icon size   */
  91.             hl = LWGET(IB_HICON(obspec));
  92.             wb = (LWGET(IB_WICON(obspec)) + 7) >> 3;
  93.                             /* Transform data   */
  94.             if ( (taddr = LLGET(IB_PDATA(obspec))) != -1L)
  95.                 vdi_trans(taddr, wb, taddr, wb, hl);
  96.                             /* Transform mask   */
  97.             if ( (taddr = LLGET(IB_PMASK(obspec))) != -1L)
  98.                 vdi_trans(taddr, wb, taddr, wb, hl);
  99.             return (TRUE);
  100.         default:
  101.             return (TRUE);
  102.         }
  103.     }
  104.  
  105. >>>>>>>>>>>>>>>>>>>  Macro definitions for the code above <<<<<<<<<<<<<<<<<<
  106.  
  107. #define BI_PDATA(x)    (x)
  108. #define BI_WB(x)    (x + 4)
  109. #define BI_HL(x)    (x + 6)
  110. #define OB_TYPE(x)     (tree + (x) * sizeof(OBJECT) + 6)
  111. #define OB_SPEC(x)     (tree + (x) * sizeof(OBJECT) + 12)
  112. #define IB_PMASK(x)    (x)
  113. #define IB_PDATA(x)    (x + 4)
  114. #define IB_WICON(x)    (x + 22)
  115. #define IB_HICON(x)    (x + 24)
  116.  
  117. >>>>>>>>>>>>>>>>>>>>>>>>>>> VDI Copy Mode Table <<<<<<<<<<<<<<<<<<<<<<<<<<<<
  118.  
  119. Symbols: N = new destination pixel value (0 or 1)
  120.      D = old destination pixel value (0 or 1)
  121.      S = source pixel value (0 or 1)
  122.      ~ = Boolean not (inversion)
  123.      & = Boolean and
  124.      | = Boolean or
  125.      ^ = Boolean xor (exclusive-or)
  126.  
  127. Mode Number    Action
  128. ----------    ------
  129.     0        N = 0        (USE V_BAR INSTEAD)
  130.     1        N = S & D
  131.     2        N = S & ~D
  132.     3        N = S        (REPLACE)
  133.     4        N = ~S & D    (ERASE)
  134.     5        N = D        (USELESS)
  135.     6        N = S ^ D    (XOR)
  136.     7        N = S | D    (TRANSPARENT)
  137.     8        N = ~ (S | D)
  138.     9        N = ~ (S ^ D)
  139.    10        N = ~D        (USE V_BAR INSTEAD)
  140.    11        N = S | ~D
  141.    12        N = ~S
  142.    13        N = ~S | D    (REVERSE TRANSPARENT)
  143.    14        N = ~ (S & D)
  144.    15        N = 1        (USE V_BAR INSTEAD)
  145.  
  146. >>>>>>>>>>>>>>>>>>>>>>>>>>> END OF DOWNLOAD <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  147.  
  148.