fixed z-order problems in poly2bitmap
[swftools.git] / swfs / simple_viewer.c
index 93d6b5f..af02ee5 100644 (file)
@@ -8,8 +8,19 @@
 
    Copyright (c) 2000, 2001 Matthias Kramm <kramm@quiss.org>
  
-   This file is distributed under the GPL, see file COPYING for details 
-*/
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #include <stdio.h>
 #include <fcntl.h>
@@ -32,12 +43,15 @@ RGBA button_colors[6]=
 int useDefineButton2 = 0; // set this to 1 to use DefineButton2 Tags
                           // instead of DefineButton1
 #define SUBTITLES 1
+//#define USE_WATERMARK 1   // set this flag to print-protect your swfs
+
+#define ID_WATERMARK 64
 
 int main (int argc,char ** argv)
 { SWF swf;
   RGBA rgb;
   SRECT r;
-  LPSHAPE s;
+  SHAPE* s;
   MATRIX m;
   ActionTAG*a1,*a2,*a3;
   S32 width=1024,height = 768;
@@ -82,6 +96,31 @@ int main (int argc,char ** argv)
   m.tx = 0; //move
   m.ty = 0;
   swf_ObjectPlace(tag, 23, 1,&m,0,"viewport");
+    
+#ifdef USE_WATERMARK
+
+  // Insert Alpha watermark to avoid printing
+
+  tag = swf_InsertTag(tag,ST_DEFINESHAPE3);
+  swf_ShapeNew(&s);
+  rgb.r = rgb.g = rgb.b = 0xff;
+  rgb.a = 0x08;
+  fs1 = swf_ShapeAddSolidFillStyle(s,&rgb);
+  swf_SetU16(tag,ID_WATERMARK);
+  r.xmin = r.ymin = 0;
+  r.xmax = 20*width;
+  r.ymax = 20*height;
+  swf_SetRect(tag,&r); // cover whole viewport
+  swf_SetShapeHeader(tag,s);
+  swf_ShapeSetAll(tag,s,0,0,0,fs1,0);
+  swf_ShapeSetLine(tag,s,20*width,0);
+  swf_ShapeSetLine(tag,s,0,20*height);
+  swf_ShapeSetLine(tag,s,-20*width,0);
+  swf_ShapeSetLine(tag,s,0,-20*height);
+  swf_ShapeSetEnd(tag);
+  swf_ShapeFree(s);  
+
+#endif // USE_WATERMARK
 
   for(count=0;count<6;count++)
   {
@@ -179,10 +218,19 @@ int main (int argc,char ** argv)
   m.tx = 0; //move
   m.ty = 0;
   tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
-  swf_ObjectPlace(tag, 30, 2,&m,0,0);
+  swf_ObjectPlace(tag, 30, 3,&m,0,0);
   m.tx = button_sizex*30;
   tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
-  swf_ObjectPlace(tag, 31, 3,&m,0,0);
+  swf_ObjectPlace(tag, 31, 4,&m,0,0);
+
+#ifdef USE_WATERMARK
+
+  // place watermark
+
+  tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
+  swf_ObjectPlace(tag, ID_WATERMARK, 2, &m, 0,0);
+
+#endif // USE_WATERMARK
   
   swf_ActionFree(a1);
   swf_ActionFree(a2);
@@ -216,14 +264,14 @@ int main (int argc,char ** argv)
       m.tx = m.ty = 0;
   }
   tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
-  swf_ObjectPlace(tag, 0x77, 4,&m,0,0);
+  swf_ObjectPlace(tag, 0x77, 5,&m,0,0);
 #endif
 
   tag = swf_InsertTag(tag,ST_SHOWFRAME);
   tag = swf_InsertTag(tag,ST_END);
   
 
-  f = open("simple_viewer.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
+  f = open("simple_viewer.swf",O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
   if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
   close(f);