im hoping someonw whos familiar with PIL [and older versions of PIL] can help me.
ive got a program[script] running in the 2.37a GameEngine which automatically prints to my printer when a variable equals something. i want it too print when my framerate falls below a certain point, to do this ive had to recode in 2.25 publisher due to something to do with logic and physics[not too clear on it myself].
as 2.25publisher uses python 2.0 ive had to get older versions of win32ui and PIL. everything works fine except something in PIL[version 1.1.1]
heres the code
if own.printer == 1: import win32print import win32ui from PIL import Image, ImageWin import Rasterizer file_name = "test_a%04d.jpg" % own.printer_count #####filename = "anim%04d.tga" % obj.frame Rasterizer.makeScreenshot(file_name) # # Constants for GetDeviceCaps # # # HORZRES / VERTRES = printable area # HORZRES = 8 VERTRES = 10 # # LOGPIXELS = dots per inch # LOGPIXELSX = 88 LOGPIXELSY = 90 # # PHYSICALWIDTH/HEIGHT = total area # PHYSICALWIDTH = 110 PHYSICALHEIGHT = 111 # # PHYSICALOFFSETX/Y = left / top margin # PHYSICALOFFSETX = 112 PHYSICALOFFSETY = 113 printer_name = win32print.GetDefaultPrinter () ####file_name = "test.jpg" # # You can only write a Device-independent bitmap # directly to a Windows device context; therefore # we need (for ease) to use the Python Imaging # Library to manipulate the image. # # Create a device context from a named printer # and assess the printable size of the paper. # hDC = win32ui.CreateDC () hDC.CreatePrinterDC (printer_name) printable_area = hDC.GetDeviceCaps (HORZRES), hDC.GetDeviceCaps (VERTRES) printer_size = hDC.GetDeviceCaps (PHYSICALWIDTH), hDC.GetDeviceCaps (PHYSICALHEIGHT) printer_margins = hDC.GetDeviceCaps (PHYSICALOFFSETX), hDC.GetDeviceCaps (PHYSICALOFFSETY) # # Open the image, rotate it if it's wider than # it is high, and work out how much to multiply # each pixel by to get it as big as possible on # the page without distorting. # bmp = Image.open (file_name) if bmp.size > bmp.size: bmp = bmp.rotate (90) ratios = [1.0 * printable_area / bmp.size, 1.0 * printable_area / bmp.size] scale = min (ratios) # # Start the print job, and draw the bitmap to # the printer device at the scaled size. # hDC.StartDoc (file_name) hDC.StartPage () dib = ImageWin.Dib (bmp) scaled_size = tuple ([scale * i for i in bmp.size]) x = (printer_size - scaled_size) / 2 y = (printer_size - scaled_size) / 2 dib.draw (hDC.GetHandleOutput (), (x, y) + scaled_size) hDC.EndPage () hDC.EndDoc () own.printer_count +=1 own.printer=0
this is part of my fullsc ript[ the printing bit] it runs fine in 2.37 with latest PIL and win32ui[pythonwin]. but using publisher and the Pil 1.1.1 i get an error relating to this line
dib = ImageWin.Dib (bmp)
PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File “Text.py”, line 152, in ?
TypeError: not enough arguments; expected 3, got 2
does anyone know what changed between PIL 1.1.1 and now [ a lot i guess] so that i can figure what i have to put in the above line to get my program running, thanks
or does anyone know where i can get a more recent version of PIL compiled for python 2.0