# Path: resources/lib/pdfminer/pdftypes.py
# LITERALS_DCT_DECODE = (LIT('DCTDecode'), LIT('DCT'))
# 
# Path: resources/lib/pdfminer/pdfcolor.py
# LITERAL_DEVICE_GRAY = LIT('DeviceGray')
# 
# Path: resources/lib/pdfminer/pdfcolor.py
# LITERAL_DEVICE_RGB = LIT('DeviceRGB')
# 
# Path: resources/lib/pdfminer/pdfcolor.py
# LITERAL_DEVICE_CMYK = LIT('DeviceCMYK')


import struct
import os
import os.path
from io import BytesIO
from .pdftypes import LITERALS_DCT_DECODE
from .pdfcolor import LITERAL_DEVICE_GRAY
from .pdfcolor import LITERAL_DEVICE_RGB
from .pdfcolor import LITERAL_DEVICE_CMYK
                from PIL import Image
                from PIL import ImageChops
#!/usr/bin/env python


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

# Path: resources/lib/pdfminer/pdftypes.py
# LITERALS_DCT_DECODE = (LIT('DCTDecode'), LIT('DCT'))
# 
# Path: resources/lib/pdfminer/pdfcolor.py
# LITERAL_DEVICE_GRAY = LIT('DeviceGray')
# 
# Path: resources/lib/pdfminer/pdfcolor.py
# LITERAL_DEVICE_RGB = LIT('DeviceRGB')
# 
# Path: resources/lib/pdfminer/pdfcolor.py
# LITERAL_DEVICE_CMYK = LIT('DeviceCMYK')


# Path: resources/lib/pdfminer/image.py
import struct
import os
import os.path
from io import BytesIO
from .pdftypes import LITERALS_DCT_DECODE
from .pdfcolor import LITERAL_DEVICE_GRAY
from .pdfcolor import LITERAL_DEVICE_RGB
from .pdfcolor import LITERAL_DEVICE_CMYK
                from PIL import Image
                from PIL import ImageChops

#!/usr/bin/env python


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