home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 98 / af098a.adf / archives / HDProgs.lzx / AGA-Morph-V1.3 / Source / AGA-Morph-Gfx.c < prev    next >
C/C++ Source or Header  |  1997-04-14  |  33KB  |  1,006 lines

  1. /*----------------------------------------------------------------------------*
  2.  *                                                                            *
  3.  *  AGA-Morph-Gfx.c V1.3                                                      *
  4.  *                                                                            *
  5.  *----------------------------------------------------------------------------*/
  6.  
  7. /*----------------------------------------------------------------------------*/
  8.  
  9. #include <libraries/diskfont.h>
  10. #include <intuition/intuition.h>
  11. #include <intuition/classes.h>
  12. #include <intuition/pointerclass.h>
  13. #include <datatypes/pictureclass.h>
  14. #include <datatypes/pictureclassext.h>
  15. #include <graphics/gfx.h>
  16. #include <exec/memory.h>
  17. #include <libraries/asl.h>
  18. #include <clib/macros.h>
  19.  
  20. #include "AGA-Morph-Language.h"
  21. #include "AGA-Morph-Struct.h"
  22.  
  23. /*----------------------------------------------------------------------------*/
  24.  
  25. #define mm 0x80808080
  26. #define md 0x10101010
  27. #define mb 0xf0f0f0f0
  28. #define pl 0xd7d7d7d7
  29. #define pm 0x7f7f7f7f
  30. #define pd 0x17171717
  31.  
  32. /*----------------------------------------------------------------------------*/
  33.  
  34. extern struct DPoint Points;
  35. extern struct Gadget EditWindowBar1,EditWindowBar2,InfoCloseButton,PointsButton,
  36.               ViewWindowBar1,ViewWindowBar2,ZoomButton;
  37. extern struct Image InfoImage;
  38. extern struct IntuiText InfoError,MemoryError,InfoText,InfoText06,InfoText07,
  39.               InfoText10,InfoText11,InfoText14,InfoText15,InfoText18,InfoText20;
  40. extern struct MPoint *Point1;
  41. extern struct Pic Picture1,Picture2,Picture3;
  42. extern struct PropInfo EditWindowBar1p,EditWindowBar2p,ViewWindowBar1p,
  43.               ViewWindowBar2p;
  44. extern struct RastPort temprp;
  45. extern struct Screen *MorphScreen;
  46. extern struct StringInfo PointsBp;
  47. extern struct Window *CommandWindow,*EditWindow,*ErrorWindow,*ViewWindow;
  48. extern LONG i,x,x1,x2,xmax,xstart,y,y1,y2,ymax,ystart;
  49. extern UBYTE Matrix[64],Array[2048];
  50. extern ULONG b,c,d,g,Height,r,Width;
  51.  
  52. /*----------------------------------------------------------------------------*/
  53.  
  54. void ShowInfo();
  55. void SetPlatte();
  56. void MouseColors(BYTE Pal);
  57. void RethinkSliderView(struct Pic *Picture);
  58. void RethinkSliderEdit(struct Pic *Picture);
  59. void RethinkSliderSpinEdit();
  60. struct Pic *DisplayPic(struct Pic *Picture,struct Window *DWin);
  61. struct Pic *DisplaySpinPic(struct Pic *Picture1,struct Pic *Picture2,struct Window *DWin);
  62.  
  63. /*----------------------------------------------------------------------------*/
  64.  
  65. void
  66. ShowInfo()
  67. {
  68.   struct IntuiMessage *Mess2;
  69.   if (ErrorWindow=(struct Window *) OpenWindowTags(NULL,
  70.                                                    WA_Left,          (Width-334)/2,
  71.                                                    WA_Top,           (Height-234)/2,
  72.                                                    WA_Width,         334,
  73.                                                    WA_Height,        234,
  74.                                                    WA_Title,         InfoHeader,
  75.                                                    WA_CustomScreen,  MorphScreen,
  76.                                                    WA_Gadgets,       &InfoCloseButton,
  77.                                                    WA_Activate,      TRUE,
  78.                                                    WA_GimmeZeroZero, TRUE,
  79.                                                    WA_IDCMP,         IDCMP_GADGETUP,
  80.                                                    TAG_END))
  81.   {
  82.     DisableAll();
  83.     while (Mess2=(struct IntuiMessage *) GetMsg(CommandWindow->UserPort))
  84.     {
  85.       ReplyMsg((struct Message *) Mess2);
  86.     }
  87.     WDez((char *)InfoText06.IText,Picture1.width);
  88.     WDez((char *)InfoText06.IText+8,Picture1.height);
  89.     Dez((char *)InfoText07.IText+3,3*Picture1.width*Picture1.height);
  90.  
  91.     WDez((char *)InfoText10.IText,Picture2.width);
  92.     WDez((char *)InfoText10.IText+8,Picture2.height);
  93.     Dez((char *)InfoText11.IText+3,3*Picture2.width*Picture2.height);
  94.  
  95.     WDez((char *)InfoText14.IText,Picture3.width);
  96.     WDez((char *)InfoText14.IText+8,Picture3.height);
  97.     Dez((char *)InfoText15.IText+3,3*Picture3.width*Picture3.height);
  98.  
  99.     Dez((char *)InfoText18.IText+3,AvailMem(0));
  100.     Dez((char *)InfoText20.IText+3,AvailMem(MEMF_LARGEST));
  101.     DrawImage(ErrorWindow->RPort,&InfoImage,3,3);
  102.     PrintIText(ErrorWindow->RPort,&InfoText,3,3);
  103.   }
  104.   else
  105.   {
  106.     ShowError(&InfoError);
  107.   }
  108. }
  109.  
  110. /*----------------------------------------------------------------------------*/
  111.  
  112. void
  113. SetPalette()
  114. {
  115.   SetRGB32(&MorphScreen->ViewPort,0,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  116.   SetRGB32(&MorphScreen->ViewPort,1,0x00000000,0x00000000,0x00000000);
  117.   SetRGB32(&MorphScreen->ViewPort,2,0xffffffff,0xffffffff,0xffffffff);
  118.   SetRGB32(&MorphScreen->ViewPort,3,0x66666666,0x88888888,0xbbbbbbbb);
  119.   SetRGB32(&MorphScreen->ViewPort,4,0xd7d7d7d7,0xd7d7d7d7,0xd7d7d7d7);
  120.   for (b=0;b<6;b++)
  121.   {
  122.     for (g=0;g<6;g++)
  123.     {
  124.       for (r=0;r<6;r++,c++)
  125.       {
  126.         SetRGB32(&MorphScreen->ViewPort,c+40,0x33333333*r,0x33333333*g,0x33333333*b);
  127.       }
  128.     }
  129.   }
  130. }
  131.  
  132. /*----------------------------------------------------------------------------*/
  133.  
  134. void
  135. MouseColors(BYTE Pal)
  136. {
  137.   switch(Pal)
  138.   {
  139.     case 0:
  140.     {
  141.       SetRGB32(&MorphScreen->ViewPort,4,pl,pl,pl);
  142.       SetRGB32(&MorphScreen->ViewPort,5,pm,pm,pm);
  143.       SetRGB32(&MorphScreen->ViewPort,17,mm,mm,mm);
  144.       SetRGB32(&MorphScreen->ViewPort,18,md,md,md);
  145.       SetRGB32(&MorphScreen->ViewPort,19,mb,mb,mb);
  146.       break;
  147.     }
  148.     case 1:
  149.     {
  150.       SetRGB32(&MorphScreen->ViewPort,4,pl,pd,pd);
  151.       SetRGB32(&MorphScreen->ViewPort,5,pm,pd,pd);
  152.       SetRGB32(&MorphScreen->ViewPort,17,mm,0,0);
  153.       SetRGB32(&MorphScreen->ViewPort,18,md,0,0);
  154.       SetRGB32(&MorphScreen->ViewPort,19,mb,0,0);
  155.       break;
  156.     }
  157.     case 2:
  158.     {
  159.       SetRGB32(&MorphScreen->ViewPort,4,pd,pl,pd);
  160.       SetRGB32(&MorphScreen->ViewPort,5,pd,pm,pd);
  161.       SetRGB32(&MorphScreen->ViewPort,17,0,mm,0);
  162.       SetRGB32(&MorphScreen->ViewPort,18,0,md,0);
  163.       SetRGB32(&MorphScreen->ViewPort,19,0,mb,0);
  164.       break;
  165.     }
  166.     case 3:
  167.     {
  168.       SetRGB32(&MorphScreen->ViewPort,4,pd,pd,pl);
  169.       SetRGB32(&MorphScreen->ViewPort,5,pd,pd,pm);
  170.       SetRGB32(&MorphScreen->ViewPort,17,0,0,mm);
  171.       SetRGB32(&MorphScreen->ViewPort,18,0,0,md);
  172.       SetRGB32(&MorphScreen->ViewPort,19,0,0,mb);
  173.       break;
  174.     }
  175.     case 4:
  176.     {
  177.       SetRGB32(&MorphScreen->ViewPort,4,pl,pl,pd);
  178.       SetRGB32(&MorphScreen->ViewPort,5,pm,pm,pd);
  179.       SetRGB32(&MorphScreen->ViewPort,17,mm,mm,0);
  180.       SetRGB32(&MorphScreen->ViewPort,18,md,md,0);
  181.       SetRGB32(&MorphScreen->ViewPort,19,mb,mb,0);
  182.       break;
  183.     }
  184.     case 5:
  185.     {
  186.       SetRGB32(&MorphScreen->ViewPort,4,pl,pd,pl);
  187.       SetRGB32(&MorphScreen->ViewPort,5,pm,pd,pm);
  188.       SetRGB32(&MorphScreen->ViewPort,17,mm,0,mm);
  189.       SetRGB32(&MorphScreen->ViewPort,18,md,0,md);
  190.       SetRGB32(&MorphScreen->ViewPort,19,mb,0,mb);
  191.       break;
  192.     }
  193.     case 6:
  194.     {
  195.       SetRGB32(&MorphScreen->ViewPort,4,pd,pl,pl);
  196.       SetRGB32(&MorphScreen->ViewPort,5,pd,pm,pm);
  197.       SetRGB32(&MorphScreen->ViewPort,17,0,mm,mm);
  198.       SetRGB32(&MorphScreen->ViewPort,18,0,md,md);
  199.       SetRGB32(&MorphScreen->ViewPort,19,0,mb,mb);
  200.       break;
  201.     }
  202.   }
  203. }
  204.  
  205. /*----------------------------------------------------------------------------*/
  206.  
  207. void
  208. RethinkSliderView(struct Pic *Picture)
  209. {
  210.   if (Picture)
  211.   {
  212.     if (ZoomButton.Flags & GFLG_SELECTED)
  213.     {
  214.       xmax=4*Picture->width;
  215.       ymax=4*Picture->height;
  216.     }
  217.     else
  218.     {
  219.       xmax=Picture->width;
  220.       ymax=Picture->height;
  221.     }
  222.     if (ymax<=ViewWindow->GZZHeight)
  223.     {
  224.       NewModifyProp(&ViewWindowBar2,ViewWindow,0,
  225.                     AUTOKNOB | FREEVERT | PROPBORDERLESS | PROPNEWLOOK,
  226.                     0,0,
  227.                     MAXBODY,MAXBODY,
  228.                     0);
  229.     }
  230.     else
  231.     {
  232.       NewModifyProp(&ViewWindowBar2,ViewWindow,0,
  233.                     AUTOKNOB | FREEVERT | PROPBORDERLESS | PROPNEWLOOK,
  234.                     0,ViewWindowBar2p.VertPot,
  235.                     MAXBODY,(MAXBODY*ViewWindow->GZZHeight)/ymax,
  236.                     0);
  237.     }
  238.     if (xmax<=ViewWindow->GZZWidth)
  239.     {
  240.       NewModifyProp(&ViewWindowBar1,ViewWindow,0,
  241.                     AUTOKNOB | FREEHORIZ | PROPBORDERLESS | PROPNEWLOOK,
  242.                     0,0,
  243.                     MAXBODY,MAXBODY,
  244.                     0);
  245.     }
  246.     else
  247.     {
  248.       NewModifyProp(&ViewWindowBar1,ViewWindow,0,
  249.                     AUTOKNOB | FREEHORIZ | PROPBORDERLESS | PROPNEWLOOK,
  250.                     ViewWindowBar1p.HorizPot,0,
  251.                     (MAXBODY*ViewWindow->GZZWidth)/xmax,MAXBODY,
  252.                     0);
  253.     }
  254.   }
  255. }
  256.  
  257. /*----------------------------------------------------------------------------*/
  258.  
  259. void
  260. RethinkSliderEdit(struct Pic *Picture)
  261. {
  262.   if (Picture)
  263.   {
  264.     if (ZoomButton.Flags & GFLG_SELECTED)
  265.     {
  266.       xmax=4*Picture->width;
  267.       ymax=4*Picture->height;
  268.     }
  269.     else
  270.     {
  271.       xmax=Picture->width;
  272.       ymax=Picture->height;
  273.     }
  274.     if (ymax<=EditWindow->GZZHeight)
  275.     {
  276.       NewModifyProp(&EditWindowBar2,EditWindow,0,
  277.                     AUTOKNOB | FREEVERT | PROPBORDERLESS | PROPNEWLOOK,
  278.                     0,0,
  279.                     MAXBODY,MAXBODY,
  280.                     0);
  281.     }
  282.     else
  283.     {
  284.       NewModifyProp(&EditWindowBar2,EditWindow,0,
  285.                     AUTOKNOB | FREEVERT | PROPBORDERLESS | PROPNEWLOOK,
  286.                     0,EditWindowBar2p.VertPot,
  287.                     MAXBODY,(MAXBODY*EditWindow->GZZHeight)/ymax,
  288.                     0);
  289.     }
  290.     if (xmax<=EditWindow->GZZWidth)
  291.     {
  292.       NewModifyProp(&EditWindowBar1,EditWindow,0,
  293.                     AUTOKNOB | FREEHORIZ | PROPBORDERLESS | PROPNEWLOOK,
  294.                     0,0,
  295.                     MAXBODY,MAXBODY,
  296.                     0);
  297.     }
  298.     else
  299.     {
  300.       NewModifyProp(&EditWindowBar1,EditWindow,0,
  301.                     AUTOKNOB | FREEHORIZ | PROPBORDERLESS | PROPNEWLOOK,
  302.                     EditWindowBar1p.HorizPot,0,
  303.                     (MAXBODY*EditWindow->GZZWidth)/xmax,MAXBODY,
  304.                     0);
  305.     }
  306.   }
  307. }
  308.  
  309. /*----------------------------------------------------------------------------*/
  310.  
  311. void
  312. RethinkSliderSpinEdit()
  313. {
  314.   if (ZoomButton.Flags & GFLG_SELECTED)
  315.   {
  316.     xmax=4*MAX(Picture1.width,Picture2.width);
  317.     ymax=4*MAX(Picture1.height,Picture2.height);
  318.   }
  319.   else
  320.   {
  321.     xmax=MAX(Picture1.width,Picture2.width);
  322.     ymax=MAX(Picture1.height,Picture2.height);
  323.   }
  324.   if (ymax<=EditWindow->GZZHeight)
  325.   {
  326.     NewModifyProp(&EditWindowBar2,EditWindow,0,
  327.                   AUTOKNOB | FREEVERT | PROPBORDERLESS | PROPNEWLOOK,
  328.                   0,0,
  329.                   MAXBODY,MAXBODY,
  330.                   0);
  331.   }
  332.   else
  333.   {
  334.     NewModifyProp(&EditWindowBar2,EditWindow,0,
  335.                   AUTOKNOB | FREEVERT | PROPBORDERLESS | PROPNEWLOOK,
  336.                   0,EditWindowBar2p.VertPot,
  337.                   MAXBODY,(MAXBODY*EditWindow->GZZHeight)/ymax,
  338.                   0);
  339.   }
  340.   if (xmax<=EditWindow->GZZWidth)
  341.   {
  342.     NewModifyProp(&EditWindowBar1,EditWindow,0,
  343.                   AUTOKNOB | FREEHORIZ | PROPBORDERLESS | PROPNEWLOOK,
  344.                   0,0,
  345.                   MAXBODY,MAXBODY,
  346.                   0);
  347.   }
  348.   else
  349.   {
  350.     NewModifyProp(&EditWindowBar1,EditWindow,0,
  351.                   AUTOKNOB | FREEHORIZ | PROPBORDERLESS | PROPNEWLOOK,
  352.                   EditWindowBar1p.HorizPot,0,
  353.                   (MAXBODY*EditWindow->GZZWidth)/xmax,MAXBODY,
  354.                   0);
  355.   }
  356. }
  357.  
  358. /*----------------------------------------------------------------------------*/
  359.  
  360. struct Pic *
  361. DisplayPic(struct Pic *Picture,struct Window *DWin)
  362. {
  363.   BYTE OPoints;
  364.   CopyMemQuick(DWin->RPort,&temprp,sizeof(temprp));
  365.   temprp.Layer=0;
  366.   if (Picture)
  367.   {
  368.     if (temprp.BitMap=(struct BitMap *)AllocBitMap(DWin->GZZWidth,1,8,BMF_DISPLAYABLE,DWin->RPort->BitMap))
  369.     {
  370.       if (ZoomButton.Flags & GFLG_SELECTED)
  371.       {
  372.         if (DWin==ViewWindow)
  373.         {
  374.           if (DWin->GZZWidth<=4*Picture->width)
  375.           {
  376.             xstart=((4*Picture->width-DWin->GZZWidth)*ViewWindowBar1p.HorizPot)/65535;
  377.           }
  378.           else
  379.           {
  380.             xstart=0;
  381.           }
  382.           if (DWin->GZZHeight<=4*Picture->height)
  383.           {
  384.             ystart=((4*Picture->height-DWin->GZZHeight)*ViewWindowBar2p.VertPot)/65535;
  385.           }
  386.           else
  387.           {
  388.             ystart=0;
  389.           }
  390.           if ((Picture==&Picture3) || (!(PointsButton.Flags & GFLG_SELECTED)))
  391.           {
  392.             OPoints=0;
  393.           }
  394.           else
  395.           {
  396.             OPoints=1;
  397.           }
  398.         }
  399.         else
  400.         {
  401.           if (DWin->GZZWidth<=4*Picture->width)
  402.           {
  403.             xstart=((4*Picture->width-DWin->GZZWidth)*EditWindowBar1p.HorizPot)/65535;
  404.           }
  405.           else
  406.           {
  407.             xstart=0;
  408.           }
  409.           if (DWin->GZZHeight<=4*Picture->height)
  410.           {
  411.             ystart=((4*Picture->height-DWin->GZZHeight)*EditWindowBar2p.VertPot)/65535;
  412.           }
  413.           else
  414.           {
  415.             ystart=0;
  416.           }
  417.           OPoints=1;
  418.         }
  419.         xstart=(xstart >> 2) << 2;
  420.         ystart=(ystart >> 2) << 2;
  421.         xmax=DWin->GZZWidth-1+xstart;
  422.         ymax=DWin->GZZHeight-1+ystart;
  423.         y=ystart;
  424.         for (y1=(ystart >> 2);(y1<Picture->height) && (y1*4<=ymax);y1++)
  425.         {
  426.           for (y2=0;(y2<4) && (y1*4+y2<=ymax);y2++)
  427.           {
  428.             y=y1*4+y2;
  429.             for (x1=(xstart >> 2);(x1<Picture->width) && (x1*4<=xmax);x1++)
  430.             {
  431.               c=x1+y1*(Picture->width);
  432.               for (x2=0;(x2<4) && (x1*4+x2<=xmax);x2++)
  433.               {
  434.                 x=x1*4+x2;
  435.                 r=*((Picture->r)+c);
  436.                 g=*((Picture->g)+c);
  437.                 b=*((Picture->b)+c);
  438.                 r=r+Matrix[x%8+(y%8)*8]; r=r/51;
  439.                 g=g+Matrix[x%8+(y%8)*8]; g=g/51;
  440.                 b=b+Matrix[x%8+(y%8)*8]; b=b/51;
  441.                 Array[x-xstart]=40+r+g*6+b*36;
  442.               }
  443.             }
  444.             WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  445.           }
  446.         }
  447.         if (y<=ymax-1)
  448.         {
  449.           for (x=xstart;(x<=xmax) && (x<Picture->width);x++)
  450.           {
  451.             Array[x-xstart]=0;
  452.           }
  453.           for (;y<=ymax;y++)
  454.           {
  455.             WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  456.           }
  457.         }
  458.         if (OPoints)
  459.         {
  460.           Point1=Points.First;
  461.           SetAPen(DWin->RPort,4);
  462.           i=0;
  463.           while (Point1)
  464.           {
  465.             i++;
  466.             if (Picture==&Picture1)
  467.             {
  468.               x=Point1->P.x1*4;
  469.               y=Point1->P.y1*4;
  470.             }
  471.             else
  472.             {
  473.               x=Point1->P.x2*4;
  474.               y=Point1->P.y2*4;
  475.             }
  476.             Point1=Point1->Next;
  477.             if (x>=xstart)
  478.             {
  479.               if (x<=xmax)
  480.               {
  481.                 if (y>=ystart)
  482.                 {
  483.                   if (y<=ymax)
  484.                   {
  485.                     x=x-xstart;
  486.                     y=y-ystart;
  487.                     if (i==PointsBp.LongInt)
  488.                     {
  489.                       WritePixel(DWin->RPort,x+1,y-2);
  490.                       WritePixel(DWin->RPort,x+2,y-2);
  491.                       WritePixel(DWin->RPort,x+1,y-1);
  492.                       WritePixel(DWin->RPort,x+2,y-1);
  493.                       WritePixel(DWin->RPort,x+1,y);
  494.                       WritePixel(DWin->RPort,x+2,y);
  495.                       WritePixel(DWin->RPort,x-2,y+1);
  496.                       WritePixel(DWin->RPort,x-1,y+1);
  497.                       WritePixel(DWin->RPort,x,y+1);
  498.                       WritePixel(DWin->RPort,x+3,y+1);
  499.                       WritePixel(DWin->RPort,x+4,y+1);
  500.                       WritePixel(DWin->RPort,x+5,y+1);
  501.                       WritePixel(DWin->RPort,x-2,y+2);
  502.                       WritePixel(DWin->RPort,x-1,y+2);
  503.                       WritePixel(DWin->RPort,x,y+2);
  504.                       WritePixel(DWin->RPort,x+3,y+2);
  505.                       WritePixel(DWin->RPort,x+4,y+2);
  506.                       WritePixel(DWin->RPort,x+5,y+2);
  507.                       WritePixel(DWin->RPort,x+1,y+3);
  508.                       WritePixel(DWin->RPort,x+2,y+3);
  509.                       WritePixel(DWin->RPort,x+1,y+4);
  510.                       WritePixel(DWin->RPort,x+2,y+4);
  511.                       WritePixel(DWin->RPort,x+1,y+5);
  512.                       WritePixel(DWin->RPort,x+2,y+5);
  513.                     }
  514.                     else
  515.                     {
  516.                       WritePixel(DWin->RPort,x,y);
  517.                       WritePixel(DWin->RPort,x+1,y);
  518.                       WritePixel(DWin->RPort,x+2,y);
  519.                       WritePixel(DWin->RPort,x+3,y);
  520.                       WritePixel(DWin->RPort,x,y+1);
  521.                       WritePixel(DWin->RPort,x+3,y+1);
  522.                       WritePixel(DWin->RPort,x,y+2);
  523.                       WritePixel(DWin->RPort,x+3,y+2);
  524.                       WritePixel(DWin->RPort,x,y+3);
  525.                       WritePixel(DWin->RPort,x+1,y+3);
  526.                       WritePixel(DWin->RPort,x+2,y+3);
  527.                       WritePixel(DWin->RPort,x+3,y+3);
  528.                     }
  529.                   }
  530.                 }
  531.               }
  532.             }
  533.           }
  534.         }
  535.       }
  536.       else
  537.       {
  538.         if (DWin==ViewWindow)
  539.         {
  540.           if (DWin->GZZWidth<=Picture->width)
  541.           {
  542.             xstart=((Picture->width-DWin->GZZWidth)*ViewWindowBar1p.HorizPot)/65535;
  543.           }
  544.           else
  545.           {
  546.             xstart=0;
  547.           }
  548.           if (DWin->GZZHeight<=Picture->height)
  549.           {
  550.             ystart=((Picture->height-DWin->GZZHeight)*ViewWindowBar2p.VertPot)/65535;
  551.           }
  552.           else
  553.           {
  554.             ystart=0;
  555.           }
  556.           if ((Picture==&Picture3) || (!(PointsButton.Flags & GFLG_SELECTED)))
  557.           {
  558.             OPoints=0;
  559.           }
  560.           else
  561.           {
  562.             OPoints=1;
  563.           }
  564.         }
  565.         else
  566.         {
  567.           if (DWin->GZZWidth<=Picture->width)
  568.           {
  569.             xstart=((Picture->width-DWin->GZZWidth)*EditWindowBar1p.HorizPot)/65535;
  570.           }
  571.           else
  572.           {
  573.             xstart=0;
  574.           }
  575.           if (DWin->GZZHeight<=Picture->height)
  576.           {
  577.             ystart=((Picture->height-DWin->GZZHeight)*EditWindowBar2p.VertPot)/65535;
  578.           }
  579.           else
  580.           {
  581.             ystart=0;
  582.           }
  583.           OPoints=1;
  584.         }
  585.         xmax=DWin->GZZWidth-1+xstart;
  586.         ymax=DWin->GZZHeight-1+ystart;
  587.         for (y=ystart;(y<Picture->height) && (y<=ymax);y++)
  588.         {
  589.           for (x=xstart;(x<Picture->width) && (x<=xmax);x++)
  590.           {
  591.             c=x+y*(Picture->width);
  592.             r=*((Picture->r)+c);
  593.             g=*((Picture->g)+c);
  594.             b=*((Picture->b)+c);
  595.             r=r+Matrix[x%8+(y%8)*8]; r=r/51;
  596.             g=g+Matrix[x%8+(y%8)*8]; g=g/51;
  597.             b=b+Matrix[x%8+(y%8)*8]; b=b/51;
  598.             Array[x-xstart]=40+r+g*6+b*36;
  599.           }
  600.           WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  601.         }
  602.         if (y<=ymax-1)
  603.         {
  604.           for (x=xstart;(x<=xmax) && (x<Picture->width);x++)
  605.           {
  606.             Array[x-xstart]=0;
  607.           }
  608.           for (;y<=ymax;y++)
  609.           {
  610.             WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  611.           }
  612.         }
  613.         if (OPoints)
  614.         {
  615.           Point1=Points.First;
  616.           SetAPen(DWin->RPort,4);
  617.           i=0;
  618.           while (Point1)
  619.           {
  620.             i++;
  621.             if (Picture==&Picture1)
  622.             {
  623.               x=Point1->P.x1;
  624.               y=Point1->P.y1;
  625.             }
  626.             else
  627.             {
  628.               x=Point1->P.x2;
  629.               y=Point1->P.y2;
  630.             }
  631.             Point1=Point1->Next;
  632.             if (x>=xstart)
  633.             {
  634.               if (x<=xmax)
  635.               {
  636.                 if (y>=ystart)
  637.                 {
  638.                   if (y<=ymax)
  639.                   {
  640.                     x=x-xstart;
  641.                     y=y-ystart;
  642.                     if (i==PointsBp.LongInt)
  643.                     {
  644.                       WritePixel(DWin->RPort,x,y-2);
  645.                       WritePixel(DWin->RPort,x,y-1);
  646.                       WritePixel(DWin->RPort,x-2,y);
  647.                       WritePixel(DWin->RPort,x-1,y);
  648.                       WritePixel(DWin->RPort,x+1,y);
  649.                       WritePixel(DWin->RPort,x+2,y);
  650.                       WritePixel(DWin->RPort,x,y+1);
  651.                       WritePixel(DWin->RPort,x,y+2);
  652.                     }
  653.                     else
  654.                     {
  655.                       WritePixel(DWin->RPort,x-1,y-1);
  656.                       WritePixel(DWin->RPort,x,y-1);
  657.                       WritePixel(DWin->RPort,x+1,y-1);
  658.                       WritePixel(DWin->RPort,x-1,y);
  659.                       WritePixel(DWin->RPort,x+1,y);
  660.                       WritePixel(DWin->RPort,x-1,y+1);
  661.                       WritePixel(DWin->RPort,x,y+1);
  662.                       WritePixel(DWin->RPort,x+1,y+1);
  663.                     }
  664.                   }
  665.                 }
  666.               }
  667.             }
  668.           }
  669.         }
  670.       }
  671.       FreeBitMap(temprp.BitMap);
  672.     }
  673.     else
  674.     {
  675.       ShowError(&MemoryError);
  676.     }
  677.   }
  678.   return(Picture);
  679. }
  680.  
  681. /*----------------------------------------------------------------------------*/
  682.  
  683. struct Pic *
  684. DisplaySpinPic(struct Pic *Picture1,struct Pic *Picture2,struct Window *DWin)
  685. {
  686.   xstart=0;
  687.   ystart=0;
  688.   xmax=DWin->GZZWidth-1+xstart;
  689.   ymax=DWin->GZZHeight-1+ystart;
  690.   CopyMemQuick(DWin->RPort,&temprp,sizeof(temprp));
  691.   temprp.Layer=0;
  692.   if ((Picture1) && (Picture2))
  693.   {
  694.     if (temprp.BitMap=(struct BitMap *)AllocBitMap(xmax,1,8,BMF_DISPLAYABLE,DWin->RPort->BitMap))
  695.     {
  696.       if (ZoomButton.Flags & GFLG_SELECTED)
  697.       {
  698.         if (DWin->GZZWidth<=4*MAX(Picture1->width,Picture2->width))
  699.         {
  700.           xstart=((4*MAX(Picture1->width,Picture2->width)-DWin->GZZWidth)*EditWindowBar1p.HorizPot)/65535;
  701.         }
  702.         else
  703.         {
  704.           xstart=0;
  705.         }
  706.         if (DWin->GZZHeight<=4*MAX(Picture1->height,Picture1->height))
  707.         {
  708.           ystart=((4*MAX(Picture1->height,Picture2->height)-DWin->GZZHeight)*EditWindowBar2p.VertPot)/65535;
  709.         }
  710.         else
  711.         {
  712.           ystart=0;
  713.         }
  714.         xstart=(xstart >> 2) << 2;
  715.         ystart=(ystart >> 2) << 2;
  716.         xmax=DWin->GZZWidth-1+xstart;
  717.         ymax=DWin->GZZHeight-1+ystart;
  718.         y=ystart;
  719.         for (y1=(ystart >> 2);(y1<MAX(Picture1->height,Picture2->height)) && (y1*4<=ymax);y1++)
  720.         {
  721.           for (y2=0;(y2<4) && (y1*4+y2<=ymax);y2++)
  722.           {
  723.             y=y1*4+y2;
  724.             for (x1=(xstart >> 2);(x1<MAX(Picture1->width,Picture2->width)) && (x1*4<=xmax);x1++)
  725.             {
  726.               c=x1+y1*(Picture1->width);
  727.               d=x1+y1*(Picture2->width);
  728.               for (x2=0;(x2<4) && (x1*4+x2<=xmax);x2++)
  729.               {
  730.                 x=x1*4+x2;
  731.                 if ((x1<Picture1->width) && (y1<Picture1->height))
  732.                 {
  733.                   if ((x1<Picture2->width) && (y1<Picture2->height))
  734.                   {
  735.                     r=(*((Picture1->r)+c)+*((Picture2->r)+d)) >> 1;
  736.                     g=(*((Picture1->g)+c)+*((Picture2->g)+d)) >> 1;
  737.                     b=(*((Picture1->b)+c)+*((Picture2->b)+d)) >> 1;
  738.                   }
  739.                   else
  740.                   {
  741.                     r=(*((Picture1->r)+c)+128) >> 1;
  742.                     g=(*((Picture1->g)+c)+128) >> 1;
  743.                     b=(*((Picture1->b)+c)+128) >> 1;
  744.                   }
  745.                 }
  746.                 else
  747.                 {
  748.                   r=(*((Picture2->r)+d)+128) >> 1;
  749.                   g=(*((Picture2->g)+d)+128) >> 1;
  750.                   b=(*((Picture2->b)+d)+128) >> 1;
  751.                 }
  752.                 r=r+Matrix[x%8+(y%8)*8]; r=r/51;
  753.                 g=g+Matrix[x%8+(y%8)*8]; g=g/51;
  754.                 b=b+Matrix[x%8+(y%8)*8]; b=b/51;
  755.                 Array[x-xstart]=40+r+g*6+b*36;
  756.               }
  757.             }
  758.             WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  759.           }
  760.         }
  761.         if (y<=ymax-1)
  762.         {
  763.           for (x=xstart;(x<=xmax) && (x<MAX(Picture1->width,Picture2->width));x++)
  764.           {
  765.             Array[x-xstart]=0;
  766.           }
  767.           for (;y<=ymax;y++)
  768.           {
  769.             WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  770.           }
  771.         }
  772.         Point1=Points.First;
  773.         i=0;
  774.         while (Point1)
  775.         {
  776.           i++;
  777.           SetAPen(DWin->RPort,5);
  778.           x1=4*Point1->P.x1-xstart;
  779.           y1=4*Point1->P.y1-ystart;
  780.           WritePixel(DWin->RPort,x1,y1);
  781.           WritePixel(DWin->RPort,x1+1,y1);
  782.           WritePixel(DWin->RPort,x1+2,y1);
  783.           WritePixel(DWin->RPort,x1+3,y1);
  784.           WritePixel(DWin->RPort,x1,y1+1);
  785.           WritePixel(DWin->RPort,x1+3,y1+1);
  786.           WritePixel(DWin->RPort,x1,y1+2);
  787.           WritePixel(DWin->RPort,x1+3,y1+2);
  788.           WritePixel(DWin->RPort,x1,y1+3);
  789.           WritePixel(DWin->RPort,x1+1,y1+3);
  790.           WritePixel(DWin->RPort,x1+2,y1+3);
  791.           WritePixel(DWin->RPort,x1+3,y1+3);
  792.           x2=4*Point1->P.x2-xstart;
  793.           y2=4*Point1->P.y2-ystart;
  794.           WritePixel(DWin->RPort,x2,y2);
  795.           WritePixel(DWin->RPort,x2+1,y2);
  796.           WritePixel(DWin->RPort,x2+2,y2);
  797.           WritePixel(DWin->RPort,x2+3,y2);
  798.           WritePixel(DWin->RPort,x2,y2+1);
  799.           WritePixel(DWin->RPort,x2+3,y2+1);
  800.           WritePixel(DWin->RPort,x2,y2+2);
  801.           WritePixel(DWin->RPort,x2+3,y2+2);
  802.           WritePixel(DWin->RPort,x2,y2+3);
  803.           WritePixel(DWin->RPort,x2+1,y2+3);
  804.           WritePixel(DWin->RPort,x2+2,y2+3);
  805.           WritePixel(DWin->RPort,x2+3,y2+3);
  806.           Move(DWin->RPort,x1,y1);
  807.           Draw(DWin->RPort,x2,y2);
  808.           x=4*Point1->P.xs-xstart;
  809.           y=4*Point1->P.ys-ystart;
  810.           if (i==PointsBp.LongInt)
  811.           {
  812.             SetAPen(DWin->RPort,4);
  813.             WritePixel(DWin->RPort,x+1,y-2);
  814.             WritePixel(DWin->RPort,x+2,y-2);
  815.             WritePixel(DWin->RPort,x+1,y-1);
  816.             WritePixel(DWin->RPort,x+2,y-1);
  817.             WritePixel(DWin->RPort,x+1,y);
  818.             WritePixel(DWin->RPort,x+2,y);
  819.             WritePixel(DWin->RPort,x-2,y+1);
  820.             WritePixel(DWin->RPort,x-1,y+1);
  821.             WritePixel(DWin->RPort,x,y+1);
  822.             WritePixel(DWin->RPort,x+3,y+1);
  823.             WritePixel(DWin->RPort,x+4,y+1);
  824.             WritePixel(DWin->RPort,x+5,y+1);
  825.             WritePixel(DWin->RPort,x-2,y+2);
  826.             WritePixel(DWin->RPort,x-1,y+2);
  827.             WritePixel(DWin->RPort,x,y+2);
  828.             WritePixel(DWin->RPort,x+3,y+2);
  829.             WritePixel(DWin->RPort,x+4,y+2);
  830.             WritePixel(DWin->RPort,x+5,y+2);
  831.             WritePixel(DWin->RPort,x+1,y+3);
  832.             WritePixel(DWin->RPort,x+2,y+3);
  833.             WritePixel(DWin->RPort,x+1,y+4);
  834.             WritePixel(DWin->RPort,x+2,y+4);
  835.             WritePixel(DWin->RPort,x+1,y+5);
  836.             WritePixel(DWin->RPort,x+2,y+5);
  837.           }
  838.           else
  839.           {
  840.             WritePixel(DWin->RPort,x,y);
  841.             WritePixel(DWin->RPort,x+1,y);
  842.             WritePixel(DWin->RPort,x+2,y);
  843.             WritePixel(DWin->RPort,x+3,y);
  844.             WritePixel(DWin->RPort,x,y+1);
  845.             WritePixel(DWin->RPort,x+3,y+1);
  846.             WritePixel(DWin->RPort,x,y+2);
  847.             WritePixel(DWin->RPort,x+3,y+2);
  848.             WritePixel(DWin->RPort,x,y+3);
  849.             WritePixel(DWin->RPort,x+1,y+3);
  850.             WritePixel(DWin->RPort,x+2,y+3);
  851.             WritePixel(DWin->RPort,x+3,y+3);
  852.           }
  853.           Point1=Point1->Next;
  854.           Move(DWin->RPort,x1,y1);
  855.           Draw(DWin->RPort,(21*x1+14*x-3*x2) >> 5,(21*y1+14*y-3*y2) >> 5);
  856.           Draw(DWin->RPort,(3*x1+6*x-x2) >> 3,(3*y1+6*y-y2) >> 3);
  857.           Draw(DWin->RPort,(5*x1+30*x-3*x2) >> 5,(5*y1+30*y-3*y2) >> 5);
  858.           Draw(DWin->RPort,x,y);
  859.           Draw(DWin->RPort,(5*x2+30*x-3*x1) >> 5,(5*y2+30*y-3*y1) >> 5);
  860.           Draw(DWin->RPort,(3*x2+6*x-x1) >> 3,(3*y2+6*y-y1) >> 3);
  861.           Draw(DWin->RPort,(21*x2+14*x-3*x1) >> 5,(21*y2+14*y-3*y1) >> 5);
  862.           Draw(DWin->RPort,x2,y2);
  863.         }
  864.       }
  865.       else
  866.       {
  867.         if (DWin->GZZWidth<=MAX(Picture1->width,Picture2->width))
  868.         {
  869.           xstart=((MAX(Picture1->width,Picture2->width)-DWin->GZZWidth)*EditWindowBar1p.HorizPot)/65535;
  870.         }
  871.         else
  872.         {
  873.           xstart=0;
  874.         }
  875.         if (DWin->GZZHeight<=MAX(Picture1->height,Picture2->height))
  876.         {
  877.           ystart=((MAX(Picture1->height,Picture2->height)-DWin->GZZHeight)*EditWindowBar2p.VertPot)/65535;
  878.         }
  879.         else
  880.         {
  881.           ystart=0;
  882.         }
  883.         for (y=ystart;(y<MAX(Picture1->height,Picture2->height)) && (y<=ymax);y++)
  884.         {
  885.           for (x=xstart;(x<MAX(Picture1->width,Picture2->width)) && (x<=xmax);x++)
  886.           {
  887.             c=x+y*(Picture1->width);
  888.             d=x+y*(Picture2->width);
  889.             if ((x<Picture1->width) && (y<Picture1->height))
  890.             {
  891.               if ((x<Picture2->width) && (y<Picture2->height))
  892.               {
  893.                 r=(*((Picture1->r)+c)+*((Picture2->r)+d)) >> 1;
  894.                 g=(*((Picture1->g)+c)+*((Picture2->g)+d)) >> 1;
  895.                 b=(*((Picture1->b)+c)+*((Picture2->b)+d)) >> 1;
  896.               }
  897.               else
  898.               {
  899.                 r=(*((Picture1->r)+c)+128) >> 1;
  900.                 g=(*((Picture1->g)+c)+128) >> 1;
  901.                 b=(*((Picture1->b)+c)+128) >> 1;
  902.               }
  903.             }
  904.             else
  905.             {
  906.               r=(*((Picture2->r)+d)+128) >> 1;
  907.               g=(*((Picture2->g)+d)+128) >> 1;
  908.               b=(*((Picture2->b)+d)+128) >> 1;
  909.             }
  910.             r=r+Matrix[x%8+(y%8)*8]; r=r/51;
  911.             g=g+Matrix[x%8+(y%8)*8]; g=g/51;
  912.             b=b+Matrix[x%8+(y%8)*8]; b=b/51;
  913.             Array[x-xstart]=40+r+g*6+b*36;
  914.           }
  915.           WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  916.         }
  917.         if (y<=ymax-1)
  918.         {
  919.           for (x=xstart;(x<=xmax) && (x<MAX(Picture1->width,Picture2->width));x++)
  920.           {
  921.             Array[x-xstart]=0;
  922.           }
  923.           for (;y<=ymax;y++)
  924.           {
  925.             WritePixelLine8(DWin->RPort,0,y-ystart,xmax+1-xstart,&Array,&temprp);
  926.           }
  927.         }
  928.         Point1=Points.First;
  929.         i=0;
  930.         while (Point1)
  931.         {
  932.           i++;
  933.           SetAPen(DWin->RPort,5);
  934.           x1=Point1->P.x1-xstart;
  935.           y1=Point1->P.y1-ystart;
  936.           WritePixel(DWin->RPort,x1-1,y1-1);
  937.           WritePixel(DWin->RPort,x1,y1-1);
  938.           WritePixel(DWin->RPort,x1+1,y1-1);
  939.           WritePixel(DWin->RPort,x1-1,y1);
  940.           WritePixel(DWin->RPort,x1+1,y1);
  941.           WritePixel(DWin->RPort,x1-1,y1+1);
  942.           WritePixel(DWin->RPort,x1,y1+1);
  943.           WritePixel(DWin->RPort,x1+1,y1+1);
  944.           x2=Point1->P.x2-xstart;
  945.           y2=Point1->P.y2-ystart;
  946.           WritePixel(DWin->RPort,x2-1,y2-1);
  947.           WritePixel(DWin->RPort,x2,y2-1);
  948.           WritePixel(DWin->RPort,x2+1,y2-1);
  949.           WritePixel(DWin->RPort,x2-1,y2);
  950.           WritePixel(DWin->RPort,x2+1,y2);
  951.           WritePixel(DWin->RPort,x2-1,y2+1);
  952.           WritePixel(DWin->RPort,x2,y2+1);
  953.           WritePixel(DWin->RPort,x2+1,y2+1);
  954.           Move(DWin->RPort,x1,y1);
  955.           Draw(DWin->RPort,x2,y2);
  956.           x=Point1->P.xs-xstart;
  957.           y=Point1->P.ys-ystart;
  958.           if (i==PointsBp.LongInt)
  959.           {
  960.             SetAPen(DWin->RPort,4);
  961.             WritePixel(DWin->RPort,x,y-2);
  962.             WritePixel(DWin->RPort,x,y-1);
  963.             WritePixel(DWin->RPort,x-2,y);
  964.             WritePixel(DWin->RPort,x-1,y);
  965.             WritePixel(DWin->RPort,x+1,y);
  966.             WritePixel(DWin->RPort,x+2,y);
  967.             WritePixel(DWin->RPort,x,y+1);
  968.             WritePixel(DWin->RPort,x,y+2);
  969.           }
  970.           else
  971.           {
  972.             WritePixel(DWin->RPort,x-1,y-1);
  973.             WritePixel(DWin->RPort,x,y-1);
  974.             WritePixel(DWin->RPort,x+1,y-1);
  975.             WritePixel(DWin->RPort,x-1,y);
  976.             WritePixel(DWin->RPort,x+1,y);
  977.             WritePixel(DWin->RPort,x-1,y+1);
  978.             WritePixel(DWin->RPort,x,y+1);
  979.             WritePixel(DWin->RPort,x+1,y+1);
  980.           }
  981.           Point1=Point1->Next;
  982.           Move(DWin->RPort,x1,y1);
  983.           Draw(DWin->RPort,(21*x1+14*x-3*x2) >> 5,(21*y1+14*y-3*y2) >> 5);
  984.           Draw(DWin->RPort,(3*x1+6*x-x2) >> 3,(3*y1+6*y-y2) >> 3);
  985.           Draw(DWin->RPort,(5*x1+30*x-3*x2) >> 5,(5*y1+30*y-3*y2) >> 5);
  986.           Draw(DWin->RPort,x,y);
  987.           Draw(DWin->RPort,(5*x2+30*x-3*x1) >> 5,(5*y2+30*y-3*y1) >> 5);
  988.           Draw(DWin->RPort,(3*x2+6*x-x1) >> 3,(3*y2+6*y-y1) >> 3);
  989.           Draw(DWin->RPort,(21*x2+14*x-3*x1) >> 5,(21*y2+14*y-3*y1) >> 5);
  990.           Draw(DWin->RPort,x2,y2);
  991.         }
  992.       }
  993.       FreeBitMap(temprp.BitMap);
  994.     }
  995.     else
  996.     {
  997.       ShowError(&MemoryError);
  998.     }
  999.   }
  1000.   return((struct Pic *)-1);
  1001. }
  1002.  
  1003. /*----------------------------------------------------------------------------*/
  1004.  
  1005. /* End of Text */
  1006.