Example #1
0
def StretchDIBits(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 81
    cmd.args =   emf.records[num].xDest,emf.records[num].yDest,emf.records[num].cxSrc,emf.records[num].cySrc, emf.records[num].nSize-58,\
                        emf.records[num].cbBmiSrc+14,emf.records[num].cxDest,emf.records[num].cyDest,emf.records[num].dwRop,\
                        emf.records[num].data[72:]
    page.cmds.append(cmd)
Example #2
0
def SetPolyfillMode(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 262
    if emf.records[num].iMode == 2:
        cmd.args =  0
    else:
        cmd.args =  1
    page.cmds.append(cmd)
Example #3
0
def SetPolyfillMode(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 19
    if emf.records[num].iMode == 2:
        cmd.args = 0
    else:
        cmd.args = 1
    page.cmds.append(cmd)
Example #4
0
def TextOut(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 1313
    count = emf.records[num].values[0]
    text = emf.records[num].data[2:2 + count]
    [y] = struct.unpack('>h', emf.records[num].data[2 + count:4 + count])
    [x] = struct.unpack('>h', emf.records[num].data[4 + count:6 + count])
    cmd.args = x, y, text, ''
    page.cmds.append(cmd)
Example #5
0
def TextOut(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 1313
    count = emf.records[num].values[0]
    text = emf.records[num].data[2:2+count]
    [y] = struct.unpack('>h',emf.records[num].data[2+count:4+count])
    [x] = struct.unpack('>h',emf.records[num].data[4+count:6+count])
    cmd.args = x,y,text,''
    page.cmds.append(cmd)
Example #6
0
def PolyPolygone(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 1336
    nPolys = emf.records[num].nPolys
    erd = emf.records[num].data[2:]
    aptl = {}
    for i in range(nPolys):
        [aptl[i]] = struct.unpack('<h',erd[i*2:i*2+2])
    cmd.args = nPolys,aptl,erd[nPolys*2:]
    page.cmds.append(cmd)
Example #7
0
def SetBKColor(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 25
    bkColor = emf.records[num].crColor
    f = (bkColor >> 24) & 0xFF
    b = (bkColor >> 16) & 0xFF
    g = (bkColor >> 8) & 0xFF
    r = bkColor & 0xFF
    cmd.args = r, g, b, f
    page.cmds.append(cmd)
Example #8
0
def SetBKColor(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 513
    bkColor = emf.records[num].bkColor
    f =  (bkColor>>24)&0xFF
    b = (bkColor>>16)&0xFF
    g = (bkColor>>8)&0xFF
    r = bkColor&0xFF
    cmd.args = r,g,b,f
    page.cmds.append(cmd)
Example #9
0
def SetTextColor(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 521
    crColor = emf.records[num].crColor
    f =  (crColor>>24)&0xFF
    b = (crColor>>16)&0xFF
    g = (crColor>>8)&0xFF
    r = crColor&0xFF
    cmd.args = r,g,b,f
    page.cmds.append(cmd)
Example #10
0
def PolyPolygone(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 1336
    nPolys = emf.records[num].nPolys
    erd = emf.records[num].data[2:]
    aptl = {}
    for i in range(nPolys):
        [aptl[i]] = struct.unpack('<h', erd[i * 2:i * 2 + 2])
    cmd.args = nPolys, aptl, erd[nPolys * 2:]
    page.cmds.append(cmd)
Example #11
0
def ExtTextOutW(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 84
    er = emf.records[num]
    text = er.string
    x = er.values[0]
    y = er.values[1]
    xscl = er.values[5]
    yscl = er.values[6]
    text = unicode(text, 'utf-16').encode('utf-8')
    ##    start,dx = er.unserializeList("i",er.nChars,er.data,er.unserializeOffset(er.offDx))
    cmd.args = x, y, text, '', xscl, yscl
    page.cmds.append(cmd)
Example #12
0
def CreatePatternBrush(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 505
    i = 0
    while i < page.maxobj:
        try:
            data = page.mfobjs[i]
            i += 1
        except:
            cmd.args = emf.records[num].data
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #13
0
def CreatePalette(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 247
    i = 0
    while i<page.maxobj:
        try:
            data = page.mfobjs[i]
            i+=1
        except:
            cmd.args = i,emf.records[num].lpltNumofclr, emf.records[num].data[4:]
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #14
0
def CreatePatternBrush(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 505
    i = 0
    while i<page.maxobj:
        try:
            data = page.mfobjs[i]
            i+=1
        except:
            cmd.args = emf.records[num].data
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #15
0
def CreatePen(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 38
    handle = emf.records[num].handle
    lbColor = emf.records[num].lopn_color
    width = emf.records[num].lopn_width
    style = emf.records[num].lopn_style
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    cmd.args = handle, r, g, b, f, width * 1., style
    page.cmds.append(cmd)
Example #16
0
def CreateBrushIndirect(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 39
    handle = emf.records[num].handle
    lbStyle = emf.records[num].lbStyle
    lbColor = emf.records[num].lbColor
    lbHatch = emf.records[num].lbHatch
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    cmd.args = handle, r, g, b, f, lbStyle, lbHatch
    page.cmds.append(cmd)
Example #17
0
def CreatePalette(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 247
    i = 0
    while i < page.maxobj:
        try:
            data = page.mfobjs[i]
            i += 1
        except:
            cmd.args = i, emf.records[num].lpltNumofclr, emf.records[num].data[
                4:]
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #18
0
def ExtTextOut(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 2610
    y = emf.records[num].values[0]
    x = emf.records[num].values[1]
    count = emf.records[num].values[2]
    flag = emf.records[num].values[3]
    shift = 8
    if flag & 4:
        shift = 16
    text = emf.records[num].data[shift:shift + count]
    dx = emf.records[num].data[shift + count:]
    cmd.args = x, y, text, dx
    page.cmds.append(cmd)
Example #19
0
def CreateFontIndirect(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 763
    i = 0
    while i < page.maxobj:
        try:
            data = page.mfobjs[i]
            i += 1
        except:
            er = emf.records[num]
            cmd.args = i, er.values, er.data[18:]
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #20
0
def StretchDIBits(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 3907
    er = emf.records[num]
    bd = er.bmpDepth
    bshift = palsize[bd] + 54
    cmd.args = er.topDest,er.leftDest,\
                     er.rightSrc-er.leftSrc,\
                     er.topSrc-er.bottomSrc,\
                     er.nSize-14,bshift,\
                     er.cxDest,\
                     er.cyDest,\
                     er.dwRop,er.data[22:]
    page.cmds.append(cmd)
Example #21
0
def StretchDIBits(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 3907
    er = emf.records[num]
    bd = er.bmpDepth
    bshift = palsize[bd]+54 
    cmd.args = er.topDest,er.leftDest,\
                     er.rightSrc-er.leftSrc,\
                     er.topSrc-er.bottomSrc,\
                     er.nSize-14,bshift,\
                     er.cxDest,\
                     er.cyDest,\
                     er.dwRop,er.data[22:]
    page.cmds.append(cmd)
Example #22
0
def ExtTextOut(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 2610
    y = emf.records[num].values[0]
    x = emf.records[num].values[1]
    count = emf.records[num].values[2]
    flag = emf.records[num].values[3]
    shift = 8
    if flag&4:
        shift = 16 
    text = emf.records[num].data[shift:shift+count]
    dx = emf.records[num].data[shift+count:]
    cmd.args = x,y,text,dx
    page.cmds.append(cmd)
Example #23
0
def CreateFontIndirect(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 763
    i = 0
    while i<page.maxobj:
        try:
            data = page.mfobjs[i]
            i+=1
        except:
            er = emf.records[num]
            cmd.args = i,er.values,er.data[18:]
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #24
0
def DibCreatePatternBrush(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 322
    i = 0
    while i<page.maxobj:
        try:
            data = page.mfobjs[i]
            i+=1
        except:
            ern = emf.records[num]
            bd = ern.biDepth
            bshift = palsize[bd]+54
            cmd.args = i,ern.biWidth,ern.biHeight,ern.nSize+4,bshift,ern.data[4:]
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #25
0
def DibCreatePatternBrush(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 322
    i = 0
    while i < page.maxobj:
        try:
            data = page.mfobjs[i]
            i += 1
        except:
            ern = emf.records[num]
            bd = ern.biDepth
            bshift = palsize[bd] + 54
            cmd.args = i, ern.biWidth, ern.biHeight, ern.nSize + 4, bshift, ern.data[
                4:]
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #26
0
def parse(page):
    counter = 0
    wmf = page.file
    for i in range(len(wmf.records)):
        id = wmf.records[i].mr_id
        if mr_ids.has_key(id):
            if mr_cmds.has_key(id):
                print i,mr_ids[id]
                mr_cmds[id](wmf,i,page)
            else:
                cmd = mfpage.cmd()
                cmd.type = id
                page.cmds.append(cmd)
                counter+=1
                print i,'UNSUPPORTED COMMAND!', mr_ids[id]
        else:
            print 'Unknown key: ',id
    print 'Unknown commands: ',counter
Example #27
0
def parse(page):
    counter = 0
    wmf = page.file
    for i in range(len(wmf.records)):
        id = wmf.records[i].mr_id
        if mr_ids.has_key(id):
            if mr_cmds.has_key(id):
                print i, mr_ids[id]
                mr_cmds[id](wmf, i, page)
            else:
                cmd = mfpage.cmd()
                cmd.type = id
                page.cmds.append(cmd)
                counter += 1
                print i, 'UNSUPPORTED COMMAND!', mr_ids[id]
        else:
            print 'Unknown key: ', id
    print 'Unknown commands: ', counter
Example #28
0
def CreateBrushIndirect(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 764
    
    lbStyle = emf.records[num].lbStyle
    lbColor = emf.records[num].lbColor
    lbHatch = emf.records[num].lbHatch
    f =  (lbColor>>24)&0xFF
    b = (lbColor>>16)&0xFF
    g = (lbColor>>8)&0xFF
    r = lbColor&0xFF
    i = 0
    while i<page.maxobj:
        try:
            data = page.mfobjs[i]
            i+=1
        except:
            cmd.args = i,r,g,b,f,lbStyle,lbHatch
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #29
0
def CreatePenIndirect(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 762

    lbColor = emf.records[num].lopnColor
    width = emf.records[num].lopnWidth
    style = emf.records[num].lopnStyle
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    i = 0
    while i < page.maxobj:
        try:
            data = page.mfobjs[i]
            i += 1
        except:
            cmd.args = i, r, g, b, f, width * 1., style
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #30
0
def CreatePenIndirect(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 762
    
    lbColor = emf.records[num].lopnColor
    width = emf.records[num].lopnWidth
    style = emf.records[num].lopnStyle
    f =  (lbColor>>24)&0xFF    
    b = (lbColor>>16)&0xFF
    g = (lbColor>>8)&0xFF
    r = lbColor&0xFF
    i = 0
    while i<page.maxobj:
        try:
            data = page.mfobjs[i]
            i+=1
        except:
            cmd.args = i,r,g,b,f,width*1.,style
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #31
0
def CreateBrushIndirect(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 764

    lbStyle = emf.records[num].lbStyle
    lbColor = emf.records[num].lbColor
    lbHatch = emf.records[num].lbHatch
    f = (lbColor >> 24) & 0xFF
    b = (lbColor >> 16) & 0xFF
    g = (lbColor >> 8) & 0xFF
    r = lbColor & 0xFF
    i = 0
    while i < page.maxobj:
        try:
            data = page.mfobjs[i]
            i += 1
        except:
            cmd.args = i, r, g, b, f, lbStyle, lbHatch
            page.mfobjs[i] = 0
            page.cmds.append(cmd)
            break
Example #32
0
def parse(page):
    emf = page.file
    page.width = emf.records[0].values[2]  ##*emf.records[0].values[6]
    page.height = emf.records[0].values[3]  ##*emf.records[0].values[7]
    page.scale = emf.records[0].values[18] * 1. / emf.records[0].values[20]
    counter = 0
    for i in range(len(emf.records)):
        id = emf.records[i].emr_id
        if emr_ids.has_key(id):
            if cmds.has_key(id):
                cmds[id](emf, i, page)
            else:
                cmd = mfpage.cmd()
                cmd.type = id
                page.cmds.append(cmd)
                counter += 1
                print 'UNSUPPORTED COMMAND! ', emr_ids[id]
        else:
            print 'Unknown key: ', id

    print 'Unknown commands: ', counter
    return page
Example #33
0
def SelectClipPath(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 67
    page.cmds.append(cmd)
Example #34
0
def SetTextAlign(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 302
    cmd.args =  emf.records[num].iMode
    page.cmds.append(cmd)
Example #35
0
def SetStretchBltMode(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 263
    cmd.args =  emf.records[num].iMode
    page.cmds.append(cmd)
Example #36
0
def SetRop2(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 20
    cmd.args = emf.records[num].iMode
    page.cmds.append(cmd)
Example #37
0
def SelectObject(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 301
    cmd.args = emf.records[num].handle
    page.cmds.append(cmd)
Example #38
0
def SetTextAlign(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 22
    cmd.args = emf.records[num].iMode
    page.cmds.append(cmd)
Example #39
0
def IntersectClipRect(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 1046
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #40
0
def Polyline(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 805
    cmd.args = emf.records[num].aptl
    page.cmds.append(cmd)
Example #41
0
def SetICMMode(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 98
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #42
0
def SaveDC(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 30
    page.cmds.append(cmd)
Example #43
0
def DeleteObject(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 496
    cmd.args = emf.records[num].handle
    del page.mfobjs[emf.records[num].handle]
    page.cmds.append(cmd)
Example #44
0
def Aldus_Header(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 1
    cmd.args =  emf.records[num].values
    page.cmds.append(cmd)
Example #45
0
def ExtCreateFontIndirectW(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 82
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #46
0
def SelectPalette(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 564
    cmd.args =  emf.records[num].values
    page.cmds.append(cmd)
Example #47
0
def SetStretchBltMode(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 21
    cmd.args = emf.records[num].iMode
    page.cmds.append(cmd)
Example #48
0
def SetBKMode(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 258
    cmd.args =  emf.records[num].values
    page.cmds.append(cmd)
Example #49
0
def RestoreDC(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 295
    page.cmds.append(cmd)
Example #50
0
def SetROP2(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 260
    cmd.args =  emf.records[num].iMode
    page.cmds.append(cmd)
Example #51
0
def PolylineTo(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 6
    cmd.args = emf.records[num].aptl
    page.cmds.append(cmd)
Example #52
0
def Polygone(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 3
    ##    x,y = emf.records[num].values[0],emf.records[num].values[3]
    cmd.args = emf.records[num].aptl
    page.cmds.append(cmd)
Example #53
0
def SelectPalette(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 48
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #54
0
def LineTo(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 531
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #55
0
def IntersectClipRect(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 30
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #56
0
def Arc(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 2071
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #57
0
def PolybezierTo(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 5
    cmd.args = emf.records[num].aptl
    page.cmds.append(cmd)
Example #58
0
def Ellipse(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 1048
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)
Example #59
0
def PolyPolyline(emf, num, page):
    cmd = mfpage.cmd()
    cmd.type = 7
    x, y = emf.records[num].values[0], emf.records[num].values[3]
    cmd.args = emf.records[num].aPolyCounts, emf.records[num].aptl, (x, y)
    page.cmds.append(cmd)
Example #60
0
def SetViewportOrgEx(emf,num,page):
    cmd = mfpage.cmd()
    cmd.type = 525
    cmd.args = emf.records[num].values
    page.cmds.append(cmd)