Beispiel #1
0
def CreateFontIndirect(mf, num, page, state):
    i = 0
    while i < state.maxobj:
        try:
            data = state.mfobjs[i]
            i += 1
        except:
            er = mf.records[num]
            eo = wmf.mfobj()
            eo.type = 3
            size = er.values[0]
            if size < 0:
                size = -size
            if size == 0:
                size = 12
            eo.size = size
            eo.weight = er.values[4]
            eo.escape = er.values[2]
            if eo.escape != er.values[3]:
                eo.orient = er.values[3]
            eo.italic = er.values[5]
            eo.under = er.values[6]
            eo.strike = er.values[7]
            eo.charset = er.values[8]
            font = er.data[18:]
            pos = font.find("\x00")
            font = font[0:pos]
            eo.font = font
            state.mfobjs[i] = eo
            break
Beispiel #2
0
def CreatePenIndirect(mf, num, page, state):
    lbColor = mf.records[num].lopnColor
    width = mf.records[num].lopnWidth
    style = mf.records[num].lopnStyle
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    if f == 1:
        clr = state.palette[r]  ## FIXME1 It has to be 2 bytes index made of R and G.
        r, g, b = clr.r, clr.g, clr.b
    i = 0
    while i < state.maxobj:
        try:
            data = state.mfobjs[i]
            i += 1
        except:
            mfo = wmf.mfobj()
            mfo.type = 1
            mfo.clr.r = r
            mfo.clr.g = g
            mfo.clr.b = b
            mfo.style = style
            mfo.width = width
            state.mfobjs[i] = mfo
            break
Beispiel #3
0
def CreateFontIndirect(mf, num, page, state):
    i = 0
    while i < state.maxobj:
        try:
            data = state.mfobjs[i]
            i += 1
        except:
            er = mf.records[num]
            eo = wmf.mfobj()
            eo.type = 3
            size = er.values[0]
            if size < 0:
                size = -size
            if size == 0:
                size = 12
            eo.size = size
            eo.weight = er.values[4]
            eo.escape = er.values[2]
            if eo.escape != er.values[3]:
                eo.orient = er.values[3]
            eo.italic = er.values[5]
            eo.under = er.values[6]
            eo.strike = er.values[7]
            eo.charset = er.values[8]
            font = er.data[18:]
            pos = font.find('\x00')
            font = font[0:pos]
            eo.font = font
            state.mfobjs[i] = eo
            break
Beispiel #4
0
def CreatePenIndirect(mf, num, page, state):
    lbColor = mf.records[num].lopnColor
    width = mf.records[num].lopnWidth
    style = mf.records[num].lopnStyle
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    if f == 1:
        clr = state.palette[
            r]  ## FIXME1 It has to be 2 bytes index made of R and G.
        r, g, b = clr.r, clr.g, clr.b
    i = 0
    while i < state.maxobj:
        try:
            data = state.mfobjs[i]
            i += 1
        except:
            mfo = wmf.mfobj()
            mfo.type = 1
            mfo.clr.r = r
            mfo.clr.g = g
            mfo.clr.b = b
            mfo.style = style
            mfo.width = width
            state.mfobjs[i] = mfo
            break
Beispiel #5
0
def CreatePalette(mf, num, page, state):
    data = mf.records[num].data[4:]
    h = mf.records[num].handle
    eo = wmf.mfobj()
    eo.type = 4
    for j in range(mf.records[num].lpltNumofclr):
        clr = wmf.Color()
        clr.r, clr.g, clr.b = ord(data[j * 4]), ord(data[j * 4 + 1]), ord(
            data[j * 4 + 2])
        state.palette[j] = clr
        state.mfobjs[h] = eo
Beispiel #6
0
def DibCreatePatternBrush(mf, num, page, state):
    palsize = {1: 8, 2: 16, 4: 64, 8: 1024, 16: 0, 24: 0, 32: 0}
    h = mf.records[num].handle
    ern = mf.records[num]
    bd = ern.biDepth
    bshift = palsize[bd] + 54
    eo = wmf.mfobj()
    eo.type = 2
    eo.style = 3  ## pattern brush
    eo.data = ern.biWidth, ern.biHeight, ern.nSize + 4, bshift, ern.data[
        4:]  ## temporary assume 1 bpp image
    state.mfobjs[h] = eo
Beispiel #7
0
def CreatePalette(mf, num, page, state):
    i = 0
    while i < state.maxobj:
        try:
            data = state.mfobjs[i]
            i += 1
        except:
            data = mf.records[num].data[4:]
            eo = wmf.mfobj()
            eo.type = 4
            for j in range(mf.records[num].lpltNumofclr):
                clr = wmf.Color()
                clr.r, clr.g, clr.b = ord(data[j * 4]), ord(data[j * 4 + 1]), ord(data[j * 4 + 2])
                state.palette[j] = clr
            state.mfobjs[i] = eo
            break
Beispiel #8
0
def DibCreatePatternBrush(mf, num, page, state):
    palsize = {1: 8, 2: 16, 4: 64, 8: 1024, 16: 0, 24: 0, 32: 0}
    i = 0
    while i < state.maxobj:
        try:
            data = state.mfobjs[i]
            i += 1
        except:
            ern = mf.records[num]
            bd = ern.biDepth
            bshift = palsize[bd] + 54
            eo = wmf.mfobj()
            eo.type = 2
            eo.style = 3  ## pattern brush
            eo.data = ern.biWidth, ern.biHeight, ern.nSize + 4, bshift, ern.data[4:]  ## temporary assume 1 bpp image
            state.mfobjs[i] = eo
            break
Beispiel #9
0
def CreatePalette(mf, num, page, state):
    i = 0
    while i < state.maxobj:
        try:
            data = state.mfobjs[i]
            i += 1
        except:
            data = mf.records[num].data[4:]
            eo = wmf.mfobj()
            eo.type = 4
            for j in range(mf.records[num].lpltNumofclr):
                clr = wmf.Color()
                clr.r, clr.g, clr.b = ord(data[j * 4]), ord(
                    data[j * 4 + 1]), ord(data[j * 4 + 2])
                state.palette[j] = clr
            state.mfobjs[i] = eo
            break
Beispiel #10
0
def CreatePenIndirect(mf, num, page, state):
    h = mf.records[num].handle
    lbColor = mf.records[num].lopn_color
    width = mf.records[num].lopn_width
    style = mf.records[num].lopn_style
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    if f == 1:
        clr = state.palette[
            r]  ## FIXME1 It has to be 2 bytes index made of R and G.
        r, g, b = clr.r, clr.g, clr.b
    mfo = wmf.mfobj()
    mfo.type = 1
    mfo.clr.r = r
    mfo.clr.g = g
    mfo.clr.b = b
    mfo.style = style
    mfo.width = width
    state.mfobjs[h] = mfo
    print 'Pen:', h, 'Color:', r, g, b, 'Style:', style, width, f
Beispiel #11
0
def ExtCreatePen(mf, num, page, state):
    h = mf.records[num].handle
    width = mf.records[num].lopnWidth
    style = mf.records[num].lopnStyle
    brstyle = mf.records[num].lbStyle
    lbColor = mf.records[num].lbColor
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    if f == 1:
        clr = state.palette[
            r]  ## FIXME1 It has to be 2 bytes index made of R and G.
        r, g, b = clr.r, clr.g, clr.b
    mfo = wmf.mfobj()
    mfo.type = 1
    mfo.clr.r = r
    mfo.clr.g = g
    mfo.clr.b = b
    mfo.style = style
    mfo.width = width
    state.mfobjs[h] = mfo
Beispiel #12
0
def CreateBrushIndirect(mf, num, page, state):
    h = mf.records[num].handle
    lbStyle = mf.records[num].lbStyle
    lbColor = mf.records[num].lbColor
    lbHatch = mf.records[num].lbHatch
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    if f == 1:
        clr = state.palette[
            r]  ## FIXME1 It has to be 2 bytes index made of R and G.
        r, g, b = clr.r, clr.g, clr.b
    mfo = wmf.mfobj()
    mfo.type = 2
    mfo.clr.r = r
    mfo.clr.g = g
    mfo.clr.b = b
    mfo.style = lbStyle
    mfo.hatch = lbHatch
    state.mfobjs[h] = mfo
    print 'Brush:', h, 'Color:', r, g, b, 'Style:', lbStyle, lbHatch
Beispiel #13
0
def CreateFontIndirect(mf, num, page, state):
    er = mf.records[num]
    eo = wmf.mfobj()
    eo.type = 3
    size = er.values[1]
    if size < 0:
        size = -size
    if size == 0:
        size = 12
    eo.size = size
    eo.weight = er.values[5]
    eo.escape = er.values[3]
    eo.orient = er.values[4]
    eo.italic = er.values[6]
    eo.under = er.values[7]
    eo.strike = er.values[8]
    eo.charset = er.values[9]
    font = er.data[18:]
    pos = font.find('\x00')
    font = font[0:pos]
    eo.font = font
    h = er.values[0]
    state.mfobjs[h] = eo