示例#1
0
def parse_embedded_image_data(image_string):
    """Returns a string describing the format, and a string with the
    raw image data."""
    encoding, data = strip_MIME(image_string)
    if encoding == "base64_jpg":
        return "jpeg", decode_base64(data)
    elif encoding == "base64_png":
        return "png", decode_base64(data)
    return None, ""
def parseImageNode( node, props ):
    result = parse_objects.parseImageNode( node )
    if result[0] == "faint:background":
        base64png = result[1]
        props.set_background_png_string( decode_base64(base64png )) # Fixme: Add to props
        return None
    return createObject( parse_objects.parseImageNode( node ), props )
            transformed = applyTransforms(transforms)
            applyCTF(pathId, props)
            if transformed:
                pop_transform()
            return pathId
        except ValueError, e:
            print "Failed parsing path: %s" % pathDef
            print "(%s)" % str(e)
            return None

    elif type == 'image':
        type, (x, y, w, h), settings, transforms, data = objInfo
        imageType, imageData = data
        if (imageType == "base64_jpg"):
            imageId = props.Raster((x, y, w, h), "jpeg",
                                   decode_base64(imageData), settings)
        elif (imageType == "base64_png"):
            imageId = props.Raster((x, y, w, h), "png",
                                   decode_base64(imageData), settings)
        else:
            assert (False)

        transformed = applyTransforms(transforms)
        applyCTF(imageId, props)
        if transformed:
            pop_transform()
        return imageId
    else:
        assert (False)
    return None
            type, pathDef, settings, transforms = objInfo
            pathId = props.Path( pathDef, settings ) # Fixme: Handle exception
            transformed = applyTransforms( transforms )
            applyCTF( pathId, props )
            if transformed:
                pop_transform()
            return pathId
        except ValueError, e:
            print "Failed parsing path: %s" % pathDef
            print "(%s)" % str(e)

    elif type == 'image':
        type, (x,y,w,h), settings, transforms, data = objInfo
        imageType, imageData = data
        if ( imageType == "base64_jpg" ):
            imageId = props.Raster((x,y,w,h),"jpeg",decode_base64(imageData), settings)
        elif ( imageType == "base64_png" ):
            imageId = props.Raster((x,y,w,h),"png",decode_base64(imageData), settings)
        else:
            assert( False )

        transformed = applyTransforms( transforms )
        applyCTF( imageId, props )
        if transformed:
            pop_transform()
        return imageId
    else:
        assert( False )
    return None

def parseCircleNode( node, props ):