home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Converter / DC-PGS21.DMS / in.adf / Extras / DevDocs.LHA / DeveloperDocs / examples / efx / negative.c < prev   
Encoding:
C/C++ Source or Header  |  1996-06-03  |  2.0 KB  |  100 lines

  1. /* Simple test effect - Inverts an image. 
  2.  
  3.     Copyright © 1995-1996 Almathera Systems Ltd. All Rights Reserved
  4.  
  5. */
  6.  
  7.     #include <exec/types.h>
  8.     #include <exec/memory.h>
  9.     #include <clib/exec_protos.h>
  10.     #include <clib/dos_protos.h>
  11.     #include <dos/dos.h>    
  12.     #include <clib/alib_protos.h>
  13.     #include <pragmas/exec_pragmas.h>
  14.     #include <pragmas/dos_pragmas.h>
  15.  
  16.     #include <photogenics/pgs_protos.h>
  17.     #include <photogenics/pgsrexx_protos.h>
  18.     #include <photogenics/parse.h>
  19.  
  20.     #include <pragmas/pgsrexx_pragmas.h>
  21.     #include <pragmas/pgs_pragmas.h>
  22.  
  23.     #include <photogenics/gio.h>
  24.     #include <photogenics/efx.h>
  25.  
  26.     #include <stdio.h>
  27.     #include <stdlib.h>
  28.     #include <string.h>
  29.  
  30. #define DOSBase giodata->DOSBase
  31. #define PgsBase giodata->PgsBase
  32.  
  33. __asm ULONG EfxInfo(void)
  34. {
  35.     return(EFX_24BIT|EFX_NOOPTIONS|EFX_8GREY);
  36. }
  37.  
  38. __asm ULONG EfxPreRender(register __a0 struct GIOData *giodata)
  39. {
  40.     return(0);
  41. }
  42.  
  43. __asm ULONG EfxRender(register __a0 struct GIOData *giodata)
  44. {
  45. UBYTE r,g,b;
  46. int x,y;
  47.     
  48.     SetProgress("Inverting image...",0);
  49.  
  50.     switch(giodata->Depth)
  51.     {
  52.         case 24:
  53.             for(y=giodata->WindY;y<giodata->WindY+giodata->WindHeight;y++)
  54.             {
  55.                 if(!(y%64))
  56.                 {
  57.                     if(SetProgress(0,(y-giodata->WindY)*100/giodata->WindHeight)!=1) 
  58.                     {
  59.                         giodata->Error = GIO_ABORTED;
  60.                         goto err;
  61.                     }
  62.                 }
  63.                 for(x=giodata->WindX;x<giodata->WindX+giodata->WindWidth;x++)
  64.                 {
  65.                     GetSrcPixel(giodata,x,y,&r,&g,&b);
  66.                     PutDestPixel(giodata,x,y,255-r,255-g,255-b);
  67.                 }
  68.             }
  69.         break;
  70.  
  71.         case 8:
  72.             for(y=giodata->WindY;y<giodata->WindY+giodata->WindHeight;y++)
  73.             {
  74.                 if(!(y%64))
  75.                 {
  76.                     if(SetProgress(0,(y-giodata->WindY)*100/giodata->WindHeight)!=1) 
  77.                     {
  78.                         giodata->Error = GIO_ABORTED;
  79.                         goto err;
  80.                     }
  81.                 }
  82.                 for(x=giodata->WindX;x<giodata->WindX+giodata->WindWidth;x++)
  83.                 {
  84.                     r=GetSrcPixel8(giodata,x,y);
  85.                     PutDestPixel8(giodata,x,y,255-r);
  86.                 }
  87.             }
  88.         break;
  89.     }
  90.     giodata->Error = GIO_OK;
  91. err:
  92.     return(giodata->Error);
  93. }
  94.  
  95. __asm ULONG EfxPrefs(register __a0 struct GIOData *giodata)
  96. {
  97.     return(0);
  98. }
  99.  
  100.