#!/usr/bin/env python2 import sys import struct import os, os.path from pdftypes import LITERALS_DCT_DECODE from pdfcolor import LITERAL_DEVICE_GRAY, LITERAL_DEVICE_RGB def align32(x): return ((x+3)/4)*4 ## BMPWriter ## class BMPWriter(object): def __init__(self, fp, bits, width, height): self.fp = fp self.bits = bits self.width = width self.height = height if bits == 1: ncols = 2 elif bits == 8: ncols = 256 elif bits == 24: ncols = 0 else: raise ValueError(bits) self.linesize = align32((self.width*self.bits+7)/8) self.datasize = self.linesize * self.height headersize = 14+40+ncols*4 info = struct.pack('