Ejemplo n.º 1
0
 def render(self):
     # Using temporary png file because GdkPixbuf.Pixbuf.new_from_data() appears to be broken
     h, self.imgtmp = tempfile.mkstemp(suffix = ".png")
     print_to_console("\nTemporary .png file: \"%s\"" % self.imgtmp)
     imgtmp = open(self.imgtmp, "wb")
     imgtmp.write(ghostscript.load_image(
         self.pdftmp, # PDF Filename
         [0, 0, 0, 0], # Don't supply a bounding box
         72 * self.quality, # X Resolution * quality factor
         72 * self.quality, # Y Resolution * quality factor
         0, # 0 = Render entire page
         0, # 0 = Render entire page
         "pnggray").tostring())
     imgtmp.close()
     os.close(h)
     return Image.open(self.imgtmp)
Ejemplo n.º 2
0
bbox[2] += (right_margin/25.4*72.0)
bbox[3] += (bottom_margin/25.4*72.0)

xres = 2540   # dpi, i.e 10um per pixel
yres = 600

bbox_width = bbox[2] - bbox[0]
bbox_height = bbox[3] - bbox[1]

width_px = 11000 # Render 110 mm strip
height_px = int(math.ceil((yres*bbox_height)/72))

bytes_per_line = int(math.ceil(width_px / 8))

print "Loading image (%dx%d pixels):" % (width_px, height_px)
img = ghostscript.load_image(args.fname, bbox, xres, yres, width_px, height_px)

print "Setting up device"
pcb = PCBWriter()

pcb.set_n_scans(n_scans)
pcb.set_autostep(True)

print "%d bytes/line" % bytes_per_line

print "Transferring image: "

for line in range(0, height_px):
    print "Transferring line %d/%d" % (line, height_px)
    
    # line_data = array.array("B", [255]*2000)
Ejemplo n.º 3
0
bbox[2] += (right_margin / 25.4 * 72.0)
bbox[3] += (bottom_margin / 25.4 * 72.0)

xres = 2540  # dpi, i.e 10um per pixel
yres = 600

bbox_width = bbox[2] - bbox[0]
bbox_height = bbox[3] - bbox[1]

width_px = 11000  # Render 110 mm strip
height_px = int(math.ceil((yres * bbox_height) / 72))

bytes_per_line = int(math.ceil(width_px / 8))

print "Loading image (%dx%d pixels):" % (width_px, height_px)
img = ghostscript.load_image(args.fname, bbox, xres, yres, width_px, height_px)

print "Setting up device"
pcb = PCBWriter()

pcb.set_n_scans(n_scans)
pcb.set_autostep(True)

print "%d bytes/line" % bytes_per_line

print "Transferring image: "

for line in range(0, height_px):
    print "Transferring line %d/%d" % (line, height_px)

    # line_data = array.array("B", [255]*2000)