Embed a surface as a PNG in a patcher file


    Sep 02 2010 | 7:36 pm
    I am trying to figure out how to embed a surface as a PNG in a patcher file...
    I was able to find a code snippet that might be relevant for what I am trying to accomplish.
    long size = 0;
    void *data = NULL;
    
    jgraphics_write_image_surface_to_filedata(x->j_surface, JGRAPHICS_FILEFORMAT_PNG, &data, &size);
    if (size) {
    	x->j_format = gensym("png");
    	binarydata_appendtodictionary(data, size, gensym("data"), x->j_format, d);
    	x->j_imagedata = data;
    	x->j_imagedatasize = size;
    }
    However, the good stuff is probably inside the function binarydata_appendtodictionary() which is not available to me.
    Binbufs? Dictionaries?
    What's the right strategy to accomplish this in Max 5?
    Can someone post a more complete/detailed example?
    Thank you for any help.
    - Luigi