testsuite: added first five tests
authorMatthias Kramm <kramm@quiss.org>
Thu, 13 Aug 2009 18:59:12 +0000 (20:59 +0200)
committerMatthias Kramm <kramm@quiss.org>
Thu, 13 Aug 2009 18:59:12 +0000 (20:59 +0200)
17 files changed:
lib/pdf/pdf.cc
spec/circularfill.pdf [new file with mode: 0644]
spec/circularfill.spec.rb [new file with mode: 0644]
spec/edit_spec.py [changed mode: 0644->0755]
spec/gradients.pdf [new file with mode: 0644]
spec/gradients.py [new file with mode: 0644]
spec/gradients.spec.rb [new file with mode: 0644]
spec/layers.pdf [new file with mode: 0644]
spec/layers.py [new file with mode: 0644]
spec/layers.spec.rb [new file with mode: 0644]
spec/pattern.pdf [new file with mode: 0644]
spec/pattern.py [new file with mode: 0644]
spec/pattern.spec.rb [new file with mode: 0644]
spec/simpletext.pdf [new file with mode: 0644]
spec/simpletext.spec.rb [new file with mode: 0644]
src/swfbytes.1 [new file with mode: 0644]
src/swfrender.c

index a0d9c6a..3e6a594 100644 (file)
@@ -1,3 +1,5 @@
+#include <stdio.h>
+#include <string.h>
 #include "../gfxdevice.h"
 #include "../gfxsource.h"
 #include "../devices/rescale.h"
@@ -447,7 +449,7 @@ static gfxdocument_t*pdf_open(gfxsource_t*src, const char*filename)
     i->filename = strdup(filename);
 
     char*x = 0;
-    if((x = strchr(filename, '|'))) {
+    if((x = strchr((char*)filename, '|'))) {
        *x = 0;
        userPassword = x+1;
     }
diff --git a/spec/circularfill.pdf b/spec/circularfill.pdf
new file mode 100644 (file)
index 0000000..63172e2
--- /dev/null
@@ -0,0 +1,265 @@
+%PDF-1.6
+%äãÏÒ
+1 0 obj
+[/PDF/ImageB/ImageC/ImageI/Text]
+endobj
+4 0 obj
+<</Length 5 0 R
+>>
+stream
+BT
+/F0 18 Tf
+18 TL
+0 0 Td
+(\(0/0\))Tj
+50 0 Td
+(\(50/0\))Tj
+50 0 Td
+(\(100/0\))Tj
+50 0 Td
+(\(150/0\))Tj
+50 0 Td
+(\(200/0\))Tj
+50 0 Td
+(\(250/0\))Tj
+50 0 Td
+(\(300/0\))Tj
+50 0 Td
+(\(350/0\))Tj
+50 0 Td
+(\(400/0\))Tj
+50 0 Td
+(\(450/0\))Tj
+50 0 Td
+(\(500/0\))Tj
+50 0 Td
+(\(550/0\))Tj
+50 0 Td
+(\(600/0\))Tj
+50 0 Td
+(\(650/0\))Tj
+50 0 Td
+(\(700/0\))Tj
+50 0 Td
+(\(750/0\))Tj
+50 0 Td
+(\(800/0\))Tj
+50 0 Td
+(\(850/0\))Tj
+50 0 Td
+(\(900/0\))Tj
+50 0 Td
+(\(950/0\))Tj
+-950 50 Td
+(\(0/50\))Tj
+0 50 Td
+(\(0/100\))Tj
+0 50 Td
+(\(0/150\))Tj
+0 50 Td
+(\(0/200\))Tj
+0 50 Td
+(\(0/250\))Tj
+0 50 Td
+(\(0/300\))Tj
+0 50 Td
+(\(0/350\))Tj
+0 50 Td
+(\(0/400\))Tj
+0 50 Td
+(\(0/450\))Tj
+0 50 Td
+(\(0/500\))Tj
+0 50 Td
+(\(0/550\))Tj
+0 50 Td
+(\(0/600\))Tj
+0 50 Td
+(\(0/650\))Tj
+0 50 Td
+(\(0/700\))Tj
+0 50 Td
+(\(0/750\))Tj
+1 0 0 rg
+0 0 0 RG
+ET
+100 150 m
+500 150 l
+500 550 l
+100 550 l
+100 150 l
+300 350 m
+700 350 l
+700 750 l
+300 750 l
+300 350 l
+200 250 m
+200 450 l
+600 450 l
+600 250 l
+200 250 l
+250 300 m
+250 500 l
+650 500 l
+650 300 l
+250 300 l
+f
+100 150 m
+500 150 l
+500 550 l
+100 550 l
+100 150 l
+300 350 m
+700 350 l
+700 750 l
+300 750 l
+300 350 l
+200 250 m
+200 450 l
+600 450 l
+600 250 l
+200 250 l
+250 300 m
+250 500 l
+650 500 l
+650 300 l
+250 300 l
+S
+
+endstream
+endobj
+5 0 obj
+1212
+endobj
+7 0 obj
+<</ProcSet 1 0 R
+/Font<</F0 6 0 R
+>>
+>>
+endobj
+8 0 obj
+<</Title (Hello world \(Python\))
+/Creator (pdflib_py)
+/Author (Matthias Kramm)
+/CreationDate (D:20090430213900+02'00')
+/Producer (PDFlib Lite 7.0.2 \(Python 2.5.1/Linux\))
+>>
+endobj
+6 0 obj
+<</Type/Font
+/Subtype/Type1
+/BaseFont/Helvetica-Bold
+/FontDescriptor 9 0 R
+/FirstChar 0
+/LastChar 255
+/Widths[278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 333 474 556 556 889 722 238 333 333 389 584 278 333 278 278
+556 556 556 556 556 556 556 556 556 556 333 333 584 584 584 611
+975 722 722 722 722 667 611 778 722 278 556 722 611 833 722 778
+667 778 722 667 611 722 667 944 667 667 611 333 278 333 584 556
+333 556 611 556 611 556 333 611 611 278 278 556 278 889 611 611
+611 611 389 556 333 611 556 778 556 556 500 389 280 389 584 278
+278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 333 556 556 556 556 280 556 333 737 370 556 584 333 737 552
+400 549 333 333 333 576 556 278 333 333 365 556 834 834 834 611
+722 722 722 722 722 722 1000 722 667 667 667 667 278 278 278 278
+722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611
+556 556 556 556 556 556 889 556 556 556 556 556 278 278 278 278
+611 611 611 611 611 611 611 549 611 611 611 611 611 556 611 556]
+/Encoding 10 0 R
+>>
+endobj
+10 0 obj
+<</Type/Encoding
+/BaseEncoding/WinAnsiEncoding
+/Differences[0/.notdef
+/.notdef
+/.notdef
+128/.notdef
+130/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+142/.notdef
+145/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+158/.notdef
+/.notdef
+/space
+173/hyphen
+]
+>>
+endobj
+9 0 obj
+<</Type/FontDescriptor
+/Flags 262176
+/Ascent 718
+/CapHeight 718
+/Descent -207
+/FontBBox[-628 -376 2000 1010]
+/FontName/Helvetica-Bold
+/ItalicAngle 0
+/StemV 166
+/XHeight 532
+>>
+endobj
+3 0 obj
+<</Type/Page
+/Parent 2 0 R
+/Contents 4 0 R
+/Resources 7 0 R
+/MediaBox[0 0 1024 800]
+>>
+endobj
+2 0 obj
+<</Type/Pages
+/Count 1
+/Kids[ 3 0 R]>>
+endobj
+11 0 obj
+<</Type/Catalog
+/Pages 2 0 R
+>>
+endobj
+xref
+0 12
+0000000000 65535 f 
+0000000015 00000 n 
+0000003442 00000 n 
+0000003340 00000 n 
+0000000063 00000 n 
+0000001327 00000 n 
+0000001593 00000 n 
+0000001347 00000 n 
+0000001402 00000 n 
+0000003149 00000 n 
+0000002764 00000 n 
+0000003496 00000 n 
+trailer
+<</Size 12
+/Root 11 0 R
+/Info 8 0 R
+/ID[<A80D8D952F38BE573BFE3BC2018E21E1><A80D8D952F38BE573BFE3BC2018E21E1>]
+>>
+startxref
+3544
+%%EOF
diff --git a/spec/circularfill.spec.rb b/spec/circularfill.spec.rb
new file mode 100644 (file)
index 0000000..5d15d2d
--- /dev/null
@@ -0,0 +1,29 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "pdf conversion" do
+    convert_file "circularfill.pdf" do
+        pixel_at(194,224).should_be_of_color 0xffffff
+        pixel_at(169,225).should_be_of_color 0xff0000
+        pixel_at(138,225).should_be_of_color 0xffffff
+        pixel_at(72,162).should_be_of_color 0xff0000
+        pixel_at(195,132).should_be_of_color 0xff0000
+        pixel_at(69,132).should_be_of_color 0xffffff
+        pixel_at(310,289).should_be_of_color 0xff0000
+        pixel_at(287,200).should_be_of_color 0xff0000
+        pixel_at(309,161).should_be_of_color 0xff0000
+        pixel_at(287,161).should_be_of_color 0xff0000
+        pixel_at(109,336).should_be_of_color 0xff0000
+        pixel_at(310,306).should_be_of_color 0xff0000
+        pixel_at(282,340).should_be_of_color 0xff0000
+        pixel_at(409,252).should_be_of_color 0xff0000
+        pixel_at(139,310).should_be_of_color 0xffffff
+        pixel_at(312,343).should_be_of_color 0xffffff
+        pixel_at(311,248).should_be_of_color 0xff0000
+        pixel_at(102,228).should_be_of_color 0xff0000
+        pixel_at(374,281).should_be_of_color 0xff0000
+        pixel_at(167,281).should_be_of_color 0xff0000
+        pixel_at(409,285).should_be_of_color 0xffffff
+        pixel_at(166,190).should_be_of_color 0xffffff
+        pixel_at(138,191).should_be_of_color 0xff0000
+    end
+end
old mode 100644 (file)
new mode 100755 (executable)
index dec96ef..ba6448d
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 import wx
 import wx.lib.scrolledpanel as scrolled
 import os
@@ -16,6 +17,8 @@ class Check:
         return "pixel at (%d,%d)" % (self.x,self.y)
     def right(self):
         return ""
+    def verifies(self, model):
+        return True
 
 class PixelColorCheck(Check):
     def __init__(self, x,y, color):
@@ -23,6 +26,10 @@ class PixelColorCheck(Check):
         self.color = color
     def right(self):
         return "is of color 0x%06x" % self.color
+    def verifies(self, model):
+        p = model.getPixel(self.x,self.y)
+        val = p[0]<<16 | p[1]<<8 | p[2]
+        return val == self.color
 
 class TwoPixelCheck(Check): 
     def __init__(self, x,y, x2,y2):
@@ -55,6 +62,8 @@ class AreaNotPlain(AreaCheck):
 
 checktypes = [PixelColorCheck,PixelBrighterThan,PixelDarkerThan,PixelEqualTo,AreaPlain,AreaNotPlain]
 
+global TESTMODE
+
 def convert_to_ppm(pdf):
     print pdf
     f = os.popen("pdfinfo "+pdf, "rb")
@@ -62,13 +71,21 @@ def convert_to_ppm(pdf):
     f.close()
     width,heigth = re.compile(r"Page size:\s*([0-9]+) x ([0-9]+) pts").findall(info)[0]
     dpi = int(72.0 * 612 / int(width))
-    os.system("pdftoppm -r "+str(dpi)+" -f 1 -l 1 "+pdf+" test")
+    if TESTMODE:
+        os.system("pdf2swf -s zoom="+str(dpi)+" -p1 "+pdf+" -o test.swf")
+        os.system("swfrender --legacy test.swf -o test.png")
+        os.unlink("test.swf")
+        return "test.png"
+    else:
+        os.system("pdftoppm -r "+str(dpi)+" -f 1 -l 1 "+pdf+" test")
     return "test-000001.ppm"
 
+
 class Model:
-    def __init__(self, filename, checks):
-        self.filename = filename
-        self.imgfilename = convert_to_ppm(filename)
+    def __init__(self, specfile, docfile, checks):
+        self.specfile = specfile
+        self.docfile = docfile
+        self.imgfilename = convert_to_ppm(self.docfile)
         self.bitmap = wx.Bitmap(self.imgfilename)
         self.image = wx.ImageFromBitmap(self.bitmap)
         self.width = self.bitmap.GetWidth()
@@ -78,6 +95,13 @@ class Model:
         self.appendListeners = []
         self.drawModeListeners = []
         self.drawmode = PixelColorCheck
+
+    def close(self):
+        try: os.unlink(self.imgfilename)
+        except: pass
+
+    def getPixel(self,x,y):
+        return (self.image.GetRed(x,y), self.image.GetGreen(x,y), self.image.GetBlue(x,y))
         
     def setdrawmode(self, mode):
         self.drawmode = mode
@@ -102,7 +126,18 @@ class Model:
 
     @staticmethod
     def load(filename):
-        path = os.path.splitext(filename)[0]+".rb"
+        # convenience, allow to do "edit_spec.py file.pdf"
+        p,ext = os.path.splitext(filename)
+        if ext!=".rb":
+            path = p+".rb"
+            if not os.path.isfile(path):
+                path = p+".spec.rb"
+                if not os.path.isfile(path):
+                    print "No file %s found, creating new..." % path
+                    return Model(path, filename, [])
+        else:
+            path = filename
+
         fi = open(path, "rb")
         r_file = re.compile(r"^convert_file \"([^\"]*)\"")
         r_pixelcolor = re.compile(r"^pixel_at\(([0-9]+),([0-9]+)\).should_be_of_color (0x[0-9a-fA-F]+)")
@@ -127,7 +162,7 @@ class Model:
                 if filename:
                     raise Exception("can't load multi-file specs (in line %d)" % (nr+1))
                 filename = m.group(1);
-                model = Model(filename, [])
+                model = Model(path, filename, [])
                 continue
             m = r_pixelcolor.match(line)
             if m: model.append(PixelColorCheck(int(m.group(1)),int(m.group(2)),int(m.group(3),16)));continue
@@ -152,10 +187,10 @@ class Model:
         return model
 
     def save(self):
-        path = os.path.splitext(self.filename)[0]+".rb"
+        path = self.specfile
         fi = open(path, "wb")
         fi.write("require File.dirname(__FILE__) + '/spec_helper'\n\ndescribe \"pdf conversion\" do\n")
-        fi.write("    convert_file \"%s\" do\n" % self.filename)
+        fi.write("    convert_file \"%s\" do\n" % self.docfile)
         for check in self.checks:
             c = check.__class__
             if c == PixelColorCheck:
@@ -201,7 +236,7 @@ class ZoomWindow(wx.Window):
             for xx in range(15):
                 x = self.x+xx-8
                 if 0<=x<self.model.width and 0<=y<self.model.height:
-                    color = (self.model.image.GetRed(x,y), self.model.image.GetGreen(x,y), self.model.image.GetBlue(x,y))
+                    color = self.model.getPixel(x,y)
                 else:
                     color = (0,0,0)
                 dc.SetPen(wx.Pen(color))
@@ -248,7 +283,8 @@ class ImageWindow(wx.Window):
             if check:
                 self.model.delete(check)
             else:
-                color = self.model.image.GetRed(x,y)<<16 | self.model.image.GetGreen(x,y)<<8 | self.model.image.GetBlue(x,y)
+                p = slef.model.GetPixel(x,y)
+                color = p[0]<<16|p[1]<<8|p[2]
                 self.model.append(PixelColorCheck(x,y,color))
         else:
             if not self.firstclick:
@@ -282,6 +318,8 @@ class ImageWindow(wx.Window):
         dc.SetBackground(wx.Brush((0,0,0)))
         dc.DrawBitmap(self.model.bitmap, 0, 0, False)
 
+        red = wx.Pen((192,0,0),2)
+
         if self.firstclick:
             x,y = self.firstclick
             if AreaCheck in self.model.drawmode.__bases__:
@@ -293,6 +331,10 @@ class ImageWindow(wx.Window):
                 dc.DrawLine(x,y,self.x,self.y)
 
         for check in self.model.checks:
+            if TESTMODE and not check.verifies(model):
+                dc.SetPen(red)
+            else:
+                dc.SetPen(wx.BLACK_PEN)
             if AreaCheck in check.__class__.__bases__:
                 dc.SetBrush(wx.TRANSPARENT_BRUSH)
                 dc.DrawRectangle(check.x,check.y,check.x2-check.x,check.y2-check.y)
@@ -308,6 +350,7 @@ class ImageWindow(wx.Window):
                 dc.DrawLine(x,y,x+1,y)
                 if TwoPixelCheck in check.__class__.__bases__:
                     dc.DrawLine(x,y,check.x2,check.y2)
+            dc.SetPen(wx.BLACK_PEN)
 
 class EntryPanel(scrolled.ScrolledPanel):
     def __init__(self, parent, model):
@@ -331,23 +374,37 @@ class EntryPanel(scrolled.ScrolledPanel):
             self.id2check[button.Id] = check
             self.Bind(wx.EVT_BUTTON, self.delete, button)
 
+            def setdefault(lb,nr):
+                lb.Select(nr);self.Bind(wx.EVT_CHOICE, lambda lb:lb.EventObject.Select(nr), lb)
+
             desc = wx.StaticText(self, -1, check.left())
+
             hbox.Add(desc, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
             if isinstance(check,AreaCheck):
                 choices = ["is plain","is not plain"]
                 lb = wx.Choice(self, -1, (100, 50), choices = choices)
+                if isinstance(check,AreaPlain):
+                    setdefault(lb,0)
+                else:
+                    setdefault(lb,1)
                 hbox.Add(lb, 0, wx.ALIGN_LEFT|wx.ALL, 5)
             elif isinstance(check,TwoPixelCheck):
                 choices = ["is the same as","is brighter than","is darker than"]
                 lb = wx.Choice(self, -1, (100, 50), choices = choices)
                 hbox.Add(lb, 0, wx.ALIGN_LEFT|wx.ALL, 5)
+                if isinstance(check, PixelEqualTo):
+                    setdefault(lb,0)
+                elif isinstance(check, PixelBrighterThan):
+                    setdefault(lb,1)
+                elif isinstance(check, PixelDarkerThan):
+                    setdefault(lb,2)
             elif isinstance(check,PixelColorCheck):
                 # TODO: color control
                 pass
             
-            desc = wx.StaticText(self, -1, check.right())
-            hbox.Add(desc, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
-
+            desc2 = wx.StaticText(self, -1, check.right())
+            hbox.Add(desc2, 0, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
+            
             self.vbox.Add(hbox)
             self.vbox.Add(wx.StaticLine(self, -1, size=(500,-1)), 0, wx.ALL, 5)
         self.end = wx.Window(self, -1, size=(1,1))
@@ -418,20 +475,21 @@ class MainFrame(wx.Frame):
         self.toolbar.Realize()
 
 
-#class ScrollFrame(wx.Frame):
+if __name__ == "__main__":
+    from optparse import OptionParser
+    global TESTMODE
+    parser = OptionParser()
+    parser.add_option("-t", "--test", dest="test", help="Test checks against swf", action="store_true")
+    (options, args) = parser.parse_args()
 
-def getpixels(filename, p):
-    model = Model(filename, p)
-    app = wx.PySimpleApp()
-    main = MainFrame(app, model)
-    main.Show()
-    app.MainLoop()
-    return model.pixels
+    if options.test:
+        TESTMODE = True
 
-if __name__ == "__main__":
     app = wx.PySimpleApp()
-    model = Model.load(sys.argv[1])
+    model = Model.load(args[0])
+
     main = MainFrame(app, model)
     main.Show()
     app.MainLoop()
     model.save()
+    model.close()
diff --git a/spec/gradients.pdf b/spec/gradients.pdf
new file mode 100644 (file)
index 0000000..eef9e29
--- /dev/null
@@ -0,0 +1,361 @@
+%PDF-1.6
+%äãÏÒ
+1 0 obj
+[/PDF/ImageB/ImageC/ImageI/Text]
+endobj
+4 0 obj
+<</Length 5 0 R
+>>
+stream
+0 0 0 rg
+
+endstream
+endobj
+5 0 obj
+9
+endobj
+6 0 obj
+<</ShadingType 3
+/ColorSpace/DeviceRGB
+/Coords[160 160 0 160 160 320]
+/Function<</FunctionType 2
+/Domain[0 1]
+/N 1
+/Range[0 1 0 1 0 1]
+/C0[0 0 0]
+/C1[1 1 1]>>>>
+endobj
+7 0 obj
+<</Length 8 0 R
+>>
+stream
+
+endstream
+endobj
+8 0 obj
+0
+endobj
+9 0 obj
+<</PatternType 2
+/Shading 6 0 R
+>>
+endobj
+10 0 obj
+<</Length 11 0 R
+>>
+stream
+/Pattern cs/P0 scn
+0 0 m
+80 80 80 240 0 320 c
+80 240 240 240 320 320 c
+240 240 240 80 320 0 c
+240 80 80 80 0 0 c
+f
+0 0 m
+80 80 80 240 0 320 c
+80 240 240 240 320 320 c
+240 240 240 80 320 0 c
+240 80 80 80 0 0 c
+S
+0 0 0.4 rg
+
+endstream
+endobj
+11 0 obj
+222
+endobj
+12 0 obj
+<</ShadingType 2
+/ColorSpace/DeviceRGB
+/Coords[200 0 520 320]
+/Function<</FunctionType 2
+/Domain[0 1]
+/N 1
+/Range[0 1 0 1 0 1]
+/C0[0 0 0.4]
+/C1[1 1 1]>>>>
+endobj
+13 0 obj
+<</Length 14 0 R
+>>
+stream
+
+endstream
+endobj
+14 0 obj
+0
+endobj
+15 0 obj
+<</PatternType 2
+/Shading 12 0 R
+>>
+endobj
+16 0 obj
+<</Length 17 0 R
+>>
+stream
+/Pattern cs/P1 scn
+200 0 m
+280 80 280 240 200 320 c
+280 240 440 240 520 320 c
+440 240 440 80 520 0 c
+440 80 280 80 200 0 c
+f
+200 0 m
+280 80 280 240 200 320 c
+280 240 440 240 520 320 c
+440 240 440 80 520 0 c
+440 80 280 80 200 0 c
+S
+0 0 0.4 rg
+
+endstream
+endobj
+17 0 obj
+242
+endobj
+18 0 obj
+<</ShadingType 3
+/ColorSpace/DeviceRGB
+/Coords[620 340 0 620 340 220]
+/Function<</FunctionType 2
+/Domain[0 1]
+/N 1
+/Range[0 1 0 1 0 1]
+/C0[0 0 0.4]
+/C1[1 1 1]>>>>
+endobj
+19 0 obj
+<</Length 20 0 R
+>>
+stream
+
+endstream
+endobj
+20 0 obj
+0
+endobj
+21 0 obj
+<</PatternType 2
+/Shading 18 0 R
+>>
+endobj
+22 0 obj
+<</Length 23 0 R
+>>
+stream
+/Pattern cs/P2 scn
+580 80 m
+580 640 l
+660 640 l
+660 80 l
+580 80 l
+f
+580 80 m
+580 640 l
+660 640 l
+660 80 l
+580 80 l
+S
+0 0 0.4 rg
+
+endstream
+endobj
+23 0 obj
+128
+endobj
+24 0 obj
+<</ShadingType 2
+/ColorSpace/DeviceRGB
+/Coords[680 80 680 640]
+/Function<</FunctionType 2
+/Domain[0 1]
+/N 1
+/Range[0 1 0 1 0 1]
+/C0[0 0 0.4]
+/C1[1 1 1]>>>>
+endobj
+25 0 obj
+<</Length 26 0 R
+>>
+stream
+
+endstream
+endobj
+26 0 obj
+0
+endobj
+27 0 obj
+<</PatternType 2
+/Shading 24 0 R
+>>
+endobj
+28 0 obj
+<</Length 29 0 R
+>>
+stream
+/Pattern cs/P3 scn
+680 80 m
+680 640 l
+760 640 l
+760 80 l
+680 80 l
+f
+680 80 m
+680 640 l
+760 640 l
+760 80 l
+680 80 l
+S
+0 0 0.4 rg
+
+endstream
+endobj
+29 0 obj
+128
+endobj
+30 0 obj
+<</ShadingType 2
+/ColorSpace/DeviceRGB
+/Coords[130 380 450 380]
+/Function<</FunctionType 2
+/Domain[0 1]
+/N 1
+/Range[0 1 0 1 0 1]
+/C0[0 0 0.4]
+/C1[1 1 1]>>>>
+endobj
+31 0 obj
+<</Length 32 0 R
+>>
+stream
+
+endstream
+endobj
+32 0 obj
+0
+endobj
+33 0 obj
+<</PatternType 2
+/Shading 30 0 R
+>>
+endobj
+34 0 obj
+<</Length 35 0 R
+>>
+stream
+/Pattern cs/P4 scn
+130 380 m
+130 460 l
+450 460 l
+450 380 l
+130 380 l
+f
+130 380 m
+130 460 l
+450 460 l
+450 380 l
+130 380 l
+S
+
+endstream
+endobj
+35 0 obj
+123
+endobj
+36 0 obj
+[ 4 0 R 7 0 R 10 0 R 13 0 R 16 0 R 19 0 R 22 0 R 25 0 R 28 0 R 31 0 R 34 0 R]
+endobj
+37 0 obj
+<</ProcSet 1 0 R
+/Pattern<</P0 9 0 R
+/P1 15 0 R
+/P2 21 0 R
+/P3 27 0 R
+/P4 33 0 R
+>>
+/Shading<</Sh0 6 0 R
+/Sh1 12 0 R
+/Sh2 18 0 R
+/Sh3 24 0 R
+/Sh4 30 0 R
+>>
+>>
+endobj
+38 0 obj
+<</Title (gradients)
+/Creator (pdflib_py)
+/Author (pdflib)
+/CreationDate (D:20090813183507+02'00')
+/Producer (PDFlib Lite 7.0.2p8 \(Python 2.5.4/Linux\))
+>>
+endobj
+3 0 obj
+<</Type/Page
+/Parent 2 0 R
+/Contents 36 0 R
+/Resources 37 0 R
+/MediaBox[0 0 1024 800]
+>>
+endobj
+2 0 obj
+<</Type/Pages
+/Count 1
+/Kids[ 3 0 R]>>
+endobj
+39 0 obj
+<</Type/Catalog
+/Pages 2 0 R
+>>
+endobj
+xref
+0 40
+0000000000 65535 f 
+0000000015 00000 n 
+0000003386 00000 n 
+0000003282 00000 n 
+0000000063 00000 n 
+0000000124 00000 n 
+0000000141 00000 n 
+0000000317 00000 n 
+0000000369 00000 n 
+0000000386 00000 n 
+0000000436 00000 n 
+0000000712 00000 n 
+0000000732 00000 n 
+0000000903 00000 n 
+0000000957 00000 n 
+0000000975 00000 n 
+0000001027 00000 n 
+0000001323 00000 n 
+0000001343 00000 n 
+0000001522 00000 n 
+0000001576 00000 n 
+0000001594 00000 n 
+0000001646 00000 n 
+0000001828 00000 n 
+0000001848 00000 n 
+0000002020 00000 n 
+0000002074 00000 n 
+0000002092 00000 n 
+0000002144 00000 n 
+0000002326 00000 n 
+0000002346 00000 n 
+0000002519 00000 n 
+0000002573 00000 n 
+0000002591 00000 n 
+0000002643 00000 n 
+0000002820 00000 n 
+0000002840 00000 n 
+0000002934 00000 n 
+0000003109 00000 n 
+0000003440 00000 n 
+trailer
+<</Size 40
+/Root 39 0 R
+/Info 38 0 R
+/ID[<A0E82BF89312F184E84C0D3E46EE0F2B><A0E82BF89312F184E84C0D3E46EE0F2B>]
+>>
+startxref
+3488
+%%EOF
diff --git a/spec/gradients.py b/spec/gradients.py
new file mode 100644 (file)
index 0000000..2e439e7
--- /dev/null
@@ -0,0 +1,114 @@
+from sys import * 
+from pdflib_py import * 
+p = PDF_new() 
+PDF_open_file(p, "gradients.pdf")
+
+PDF_set_parameter(p, "usercoordinates", "true")
+PDF_set_value(p, "compress", 0)
+
+PDF_set_info(p, "Author", "pdflib")
+PDF_set_info(p, "Creator", "pdflib_py")
+PDF_set_info(p, "Title", "gradients")
+
+width = 1024
+height = 800
+PDF_begin_page(p, width, height)
+
+type,x,params = "radial",0,"r0=0 r1=320"
+y = 0
+PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.0, 1.0)
+shading = PDF_shading(p, type, 160+x,160+y, 160+x, 160+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial
+pattern = PDF_shading_pattern(p,shading,"")
+PDF_setcolor(p, "fill", "pattern", pattern,0,0,0)
+PDF_moveto(p, x,y)
+PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320)
+PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320)
+PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y)
+PDF_curveto(p, x+240, y+80, x+80, y+80, x, y)
+PDF_fill(p)
+PDF_moveto(p, x,y)
+PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320)
+PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320)
+PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y)
+PDF_curveto(p, x+240, y+80, x+80, y+80, x, y)
+PDF_stroke(p)
+
+type,x,params = "axial",200,""
+y = 0
+PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0)
+shading = PDF_shading(p, type, 0+x,0+y, 320+x,320+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial
+pattern = PDF_shading_pattern(p,shading,"")
+PDF_setcolor(p, "fill", "pattern", pattern,0,0,0)
+PDF_moveto(p, x,y)
+PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320)
+PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320)
+PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y)
+PDF_curveto(p, x+240, y+80, x+80, y+80, x, y)
+PDF_fill(p)
+PDF_moveto(p, x,y)
+PDF_curveto(p, x+80, y+80, x+80, y+240, x, y+320)
+PDF_curveto(p, x+80, y+240, x+240, y+240, x+320, y+320)
+PDF_curveto(p, x+240, y+240, x+240, y+80, x+320, y)
+PDF_curveto(p, x+240, y+80, x+80, y+80, x, y)
+PDF_stroke(p)
+
+type,x,params = "radial",500,"r0=0 r1=220"
+y = 0
+PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0)
+shading = PDF_shading(p, type, 120+x, 340+y, 120+x, 340+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial
+pattern = PDF_shading_pattern(p,shading,"")
+PDF_setcolor(p, "fill", "pattern", pattern,0,0,0)
+PDF_moveto(p, x+80, y+80)
+PDF_lineto(p, x+80, y+640)
+PDF_lineto(p, x+160, y+640)
+PDF_lineto(p, x+160, y+80)
+PDF_lineto(p, x+80, y+80)
+PDF_fill(p)
+PDF_moveto(p, x+80, y+80)
+PDF_lineto(p, x+80, y+640)
+PDF_lineto(p, x+160, y+640)
+PDF_lineto(p, x+160, y+80)
+PDF_lineto(p, x+80, y+80)
+PDF_stroke(p)
+
+type,x,params = "axial",600,""
+y = 0
+PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0)
+shading = PDF_shading(p, type, 80+x, 80+y, 80+x, 640+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial
+pattern = PDF_shading_pattern(p,shading,"")
+PDF_setcolor(p, "fill", "pattern", pattern,0,0,0)
+PDF_moveto(p, x+80, y+80)
+PDF_lineto(p, x+80, y+640)
+PDF_lineto(p, x+160, y+640)
+PDF_lineto(p, x+160, y+80)
+PDF_lineto(p, x+80, y+80)
+PDF_fill(p)
+PDF_moveto(p, x+80, y+80)
+PDF_lineto(p, x+80, y+640)
+PDF_lineto(p, x+160, y+640)
+PDF_lineto(p, x+160, y+80)
+PDF_lineto(p, x+80, y+80)
+PDF_stroke(p)
+
+type,x,params = "axial",50,""
+y = 300
+PDF_setcolor(p, "fill", "rgb", 0.0, 0.0, 0.4, 1.0)
+shading = PDF_shading(p, type, 80+x, 80+y, 400+x, 80+y, 1.0, 1.0, 1.0, 1.0, params) #axial|radial
+pattern = PDF_shading_pattern(p,shading,"")
+PDF_setcolor(p, "fill", "pattern", pattern,0,0,0)
+PDF_moveto(p, x+80, y+80)
+PDF_lineto(p, x+80, y+160)
+PDF_lineto(p, x+400, y+160)
+PDF_lineto(p, x+400, y+80)
+PDF_lineto(p, x+80, y+80)
+PDF_fill(p)
+PDF_moveto(p, x+80, y+80)
+PDF_lineto(p, x+80, y+160)
+PDF_lineto(p, x+400, y+160)
+PDF_lineto(p, x+400, y+80)
+PDF_lineto(p, x+80, y+80)
+PDF_stroke(p)
+
+PDF_end_page(p)
+PDF_close(p)
+PDF_delete(p);
diff --git a/spec/gradients.spec.rb b/spec/gradients.spec.rb
new file mode 100644 (file)
index 0000000..62aebbb
--- /dev/null
@@ -0,0 +1,34 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "pdf conversion" do
+    convert_file "gradients.pdf" do
+        pixel_at(269,324).should_be_brighter_than pixel_at(155,438)
+        pixel_at(261,388).should_be_brighter_than pixel_at(209,434)
+        pixel_at(195,329).should_be_brighter_than pixel_at(164,367)
+        pixel_at(33,318).should_be_brighter_than pixel_at(92,381)
+        pixel_at(168,310).should_be_brighter_than pixel_at(108,381)
+        pixel_at(166,455).should_be_brighter_than pixel_at(109,401)
+        pixel_at(25,454).should_be_brighter_than pixel_at(89,396)
+        pixel_at(258,210).should_be_brighter_than pixel_at(90,215)
+        pixel_at(259,225).should_be_brighter_than pixel_at(95,227)
+        pixel_at(257,240).should_be_brighter_than pixel_at(102,240)
+        pixel_at(359,121).should_be_brighter_than pixel_at(360,270)
+        pixel_at(383,119).should_be_brighter_than pixel_at(385,181)
+        pixel_at(373,167).should_be_brighter_than pixel_at(373,239)
+        pixel_at(355,409).should_be_brighter_than pixel_at(356,349)
+        pixel_at(370,377).should_be_brighter_than pixel_at(369,316)
+        pixel_at(382,333).should_be_brighter_than pixel_at(383,286)
+        pixel_at(422,115).should_be_brighter_than pixel_at(422,411)
+        pixel_at(437,190).should_be_brighter_than pixel_at(436,318)
+        pixel_at(447,276).should_be_brighter_than pixel_at(446,413)
+        pixel_at(413,101).should_be_the_same_as pixel_at(448,101)
+        pixel_at(412,166).should_be_the_same_as pixel_at(449,166)
+        pixel_at(412,246).should_be_the_same_as pixel_at(450,246)
+        pixel_at(413,332).should_be_the_same_as pixel_at(450,332)
+        pixel_at(414,400).should_be_the_same_as pixel_at(451,400)
+        pixel_at(87,245).should_be_the_same_as pixel_at(87,212)
+        pixel_at(143,245).should_be_the_same_as pixel_at(143,209)
+        pixel_at(189,246).should_be_the_same_as pixel_at(189,210)
+        pixel_at(236,244).should_be_the_same_as pixel_at(236,208)
+    end
+end
diff --git a/spec/layers.pdf b/spec/layers.pdf
new file mode 100644 (file)
index 0000000..877a1f3
--- /dev/null
@@ -0,0 +1,147 @@
+%PDF-1.6
+%äãÏÒ
+1 0 obj
+[/PDF/ImageB/ImageC/ImageI/Text]
+endobj
+4 0 obj
+<</Length 5 0 R
+/Filter/FlateDecode
+>>
+stream
+x\9cU\8eÍ
+Â0\10\84ïó\14\93kmü96E½xÒ}\ 4­ -\85\12ÐÇw'QA\ 2É·3Ìf¢aqPÙªX\aÞ'¨,ý½b\16Ç\94ÆAìöJs{P÷s>Âí'öæ\82Ê\80 \f¨ô¸ PѾ
+cÓ\1d« R\ 5÷ê]\86\86\aÙêÀ¯\94¹h¨}[U*5¥ÈúSðoj9y­7\85Õ+×
+endstream
+endobj
+5 0 obj
+136
+endobj
+7 0 obj
+<</ProcSet 1 0 R
+/Font<</F0 6 0 R
+>>
+>>
+endobj
+8 0 obj
+<</CreationDate (D:20090813192742+02'00')
+/Producer (PDFlib Lite 7.0.2p8 \(Python 2.5.4/Linux\))
+>>
+endobj
+6 0 obj
+<</Type/Font
+/Subtype/Type1
+/BaseFont/Helvetica-Bold
+/FontDescriptor 9 0 R
+/FirstChar 0
+/LastChar 255
+/Widths[278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 333 474 556 556 889 722 238 333 333 389 584 278 333 278 278
+556 556 556 556 556 556 556 556 556 556 333 333 584 584 584 611
+975 722 722 722 722 667 611 778 722 278 556 722 611 833 722 778
+667 778 722 667 611 722 667 944 667 667 611 333 278 333 584 556
+333 556 611 556 611 556 333 611 611 278 278 556 278 889 611 611
+611 611 389 556 333 611 556 778 556 556 500 389 280 389 584 278
+278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 278 278 278 278 278 278 278 278 278 278 278 278 278 278 278
+278 333 556 556 556 556 280 556 333 737 370 556 584 333 737 552
+400 549 333 333 333 576 556 278 333 333 365 556 834 834 834 611
+722 722 722 722 722 722 1000 722 667 667 667 667 278 278 278 278
+722 722 778 778 778 778 778 584 778 722 722 722 722 667 667 611
+556 556 556 556 556 556 889 556 556 556 556 556 278 278 278 278
+611 611 611 611 611 611 611 549 611 611 611 611 611 556 611 556]
+/Encoding 10 0 R
+>>
+endobj
+10 0 obj
+<</Type/Encoding
+/BaseEncoding/WinAnsiEncoding
+/Differences[0/.notdef
+/.notdef
+/.notdef
+128/.notdef
+130/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+142/.notdef
+145/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+/.notdef
+158/.notdef
+/.notdef
+/space
+173/hyphen
+]
+>>
+endobj
+9 0 obj
+<</Type/FontDescriptor
+/Flags 262176
+/Ascent 718
+/CapHeight 718
+/Descent -207
+/FontBBox[-628 -376 2000 1010]
+/FontName/Helvetica-Bold
+/ItalicAngle 0
+/StemV 166
+/XHeight 532
+>>
+endobj
+3 0 obj
+<</Type/Page
+/Parent 2 0 R
+/Contents 4 0 R
+/Resources 7 0 R
+/MediaBox[0 0 500 200]
+>>
+endobj
+2 0 obj
+<</Type/Pages
+/Count 1
+/Kids[ 3 0 R]>>
+endobj
+11 0 obj
+<</Type/Catalog
+/Pages 2 0 R
+>>
+endobj
+xref
+0 12
+0000000000 65535 f 
+0000000015 00000 n 
+0000002308 00000 n 
+0000002207 00000 n 
+0000000063 00000 n 
+0000000271 00000 n 
+0000000460 00000 n 
+0000000290 00000 n 
+0000000345 00000 n 
+0000002016 00000 n 
+0000001631 00000 n 
+0000002362 00000 n 
+trailer
+<</Size 12
+/Root 11 0 R
+/Info 8 0 R
+/ID[<B6CA5265ECA0298B084A1DBB5789E6F8><B6CA5265ECA0298B084A1DBB5789E6F8>]
+>>
+startxref
+2410
+%%EOF
diff --git a/spec/layers.py b/spec/layers.py
new file mode 100644 (file)
index 0000000..30ba5bf
--- /dev/null
@@ -0,0 +1,41 @@
+from sys import * 
+from pdflib_py import * 
+
+p = PDF_new() 
+PDF_open_file(p, "layers.pdf")
+
+PDF_set_parameter(p, "usercoordinates", "true")
+PDF_begin_page(p, 500, 200)
+
+font = PDF_load_font(p, "Helvetica-Bold", "host", "")
+PDF_setfont(p, font, 80.0)
+PDF_set_text_pos(p, 0, 10)
+PDF_show(p, "Bottom Text")
+
+PDF_setrgbcolor_stroke(p, 0, 1.0, 1.0)
+PDF_setlinewidth(p, 10)
+PDF_moveto(p, 0, 0)
+PDF_lineto(p, 500, 100)
+PDF_stroke(p)
+PDF_moveto(p, 0, 100)
+PDF_lineto(p, 500, 0)
+PDF_stroke(p)
+
+PDF_setrgbcolor_fill(p, 0, 0, 1.0)
+PDF_moveto(p, 350, 25)
+PDF_lineto(p, 490, 25)
+PDF_lineto(p, 490, 75)
+PDF_lineto(p, 350, 75)
+PDF_lineto(p, 350, 25)
+PDF_fill(p)
+
+PDF_setrgbcolor_fill(p, 1, 1, 0)
+PDF_set_text_pos(p, 400, 20);PDF_show(p, "A")
+PDF_set_text_pos(p, 400, 80);PDF_show(p, "B")
+PDF_set_text_pos(p, 400, 140);PDF_show(p, "C")
+
+
+PDF_end_page(p)
+
+PDF_close(p)
+PDF_delete(p);
diff --git a/spec/layers.spec.rb b/spec/layers.spec.rb
new file mode 100644 (file)
index 0000000..2594835
--- /dev/null
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "pdf conversion" do
+    convert_file "layers.pdf" do
+        pixel_at(67,134).should_be_of_color 0x00ffff
+        pixel_at(299,182).should_be_of_color 0x00ffff
+        pixel_at(144,215).should_be_of_color 0x00ffff
+        pixel_at(206,203).should_be_of_color 0x00ffff
+        pixel_at(243,196).should_be_of_color 0x00ffff
+        pixel_at(270,190).should_be_of_color 0x00ffff
+        pixel_at(114,220).should_be_of_color 0x00ffff
+        pixel_at(406,161).should_be_of_color 0x00ffff
+        pixel_at(398,201).should_be_of_color 0x00ffff
+        pixel_at(438,211).should_be_of_color 0x0000ff
+        pixel_at(499,216).should_be_of_color 0xffff00
+        pixel_at(498,223).should_be_of_color 0x00ffff
+        pixel_at(515,175).should_be_of_color 0xffff00
+        pixel_at(458,185).should_be_of_color 0x0000ff
+        pixel_at(541,138).should_be_of_color 0xffff00
+        pixel_at(433,158).should_be_of_color 0x0000ff
+        area_at(431,155,485,212).should_be_plain_colored
+        pixel_at(103,184).should_be_of_color 0x000000
+        pixel_at(505,84).should_be_of_color 0xffff00
+        pixel_at(314,149).should_be_of_color 0xffffff
+    end
+end
diff --git a/spec/pattern.pdf b/spec/pattern.pdf
new file mode 100644 (file)
index 0000000..ddd9b9d
Binary files /dev/null and b/spec/pattern.pdf differ
diff --git a/spec/pattern.py b/spec/pattern.py
new file mode 100644 (file)
index 0000000..5e4871a
--- /dev/null
@@ -0,0 +1,41 @@
+from sys import * 
+from pdflib_py import * 
+p = PDF_new() 
+PDF_open_file(p, "pattern.pdf")
+
+PDF_set_parameter(p, "usercoordinates", "true")
+PDF_set_info(p, "Creator", "pattern.py")
+
+width=595
+height=842
+
+PDF_begin_page(p, width, height)
+
+PDF_setrgbcolor_stroke(p, 0, 0, 0.9)
+PDF_setrgbcolor_fill(p, 0.7, 0.7, 0.0)
+pattern = PDF_begin_pattern(p, 4, 4, 4, 4, 2)
+PDF_moveto(p, 0, 0)
+PDF_lineto(p, 4, 4)
+PDF_moveto(p, 4, 0)
+PDF_lineto(p, 0, 4)
+PDF_stroke(p)
+PDF_moveto(p, 0, 2)
+PDF_lineto(p, 0, 4)
+PDF_lineto(p, 4, 4)
+PDF_lineto(p, 4, 2)
+PDF_lineto(p, 0, 2)
+PDF_fill(p)
+PDF_end_pattern(p)
+
+PDF_setcolor(p, "fill", "pattern", pattern, 0.0, 0.9, 0.0)
+PDF_moveto(p, 0, 0)
+PDF_lineto(p, width-100, 0)
+PDF_lineto(p, width-100, height)
+PDF_lineto(p, 0, height)
+PDF_lineto(p, 0, 0)
+PDF_fill(p)
+
+PDF_end_page(p)
+
+PDF_close(p)
+PDF_delete(p);
diff --git a/spec/pattern.spec.rb b/spec/pattern.spec.rb
new file mode 100644 (file)
index 0000000..fb8636b
--- /dev/null
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "pdf conversion" do
+    convert_file "pattern.pdf" do
+        area_at(425,190,500,224).should_not_be_plain_colored
+        area_at(517,192,583,225).should_be_plain_colored
+    end
+end
diff --git a/spec/simpletext.pdf b/spec/simpletext.pdf
new file mode 100644 (file)
index 0000000..8dd26d7
Binary files /dev/null and b/spec/simpletext.pdf differ
diff --git a/spec/simpletext.spec.rb b/spec/simpletext.spec.rb
new file mode 100644 (file)
index 0000000..d5911ad
--- /dev/null
@@ -0,0 +1,12 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "pdf conversion" do
+    convert_file "simpletext.pdf" do
+        pixel_at(109,133).should_be_of_color 0x000000
+        pixel_at(154,139).should_be_brighter_than pixel_at(151,139)
+        pixel_at(53,136).should_be_darker_than pixel_at(58,166)
+        pixel_at(97,164).should_be_the_same_as pixel_at(208,256)
+        area_at(215,80,333,156).should_be_plain_colored
+        area_at(46,126,180,158).should_not_be_plain_colored
+    end
+end
diff --git a/src/swfbytes.1 b/src/swfbytes.1
new file mode 100644 (file)
index 0000000..ae14406
--- /dev/null
@@ -0,0 +1,26 @@
+.TH swfbytes "1" "August 2009" "swfbytes" "swftools"
+.SH NAME
+swfbytes - Tool for simplifying the hex-editing of SWF files.
+
+.SH Synopsis
+.B swfbytes [-v] file.swf > file.hexdump
+.PP
+.B swfbytes file.hexdump
+
+.SH DESCRIPTION
+With this tool and a text editor, you can perform some basic
+editing operations on SWF files.
+
+.SH OPTIONS
+.TP
+\fB\-h\fR, \fB\-\-help\fR 
+    Print help and exit
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR 
+    Be more verbose
+.TP
+\fB\-V\fR, \fB\-\-version\fR 
+    Print program version and exit
+.SH AUTHOR
+
+Matthias Kramm <kramm@quiss.org>
index 8ac81d5..0dcee51 100644 (file)
@@ -128,7 +128,7 @@ int main(int argn, char*argv[])
        fi = open(filename, O_RDONLY|O_BINARY);
        if (fi<=0) { 
            fprintf(stderr,"Couldn't open %s\n", filename);
-           perror(argv[1]);
+           perror(filename);
            exit(1);
        }
        if(swf_ReadSWF(fi,&swf)<0) {