I usually use Python’s pickle
module for serialization. But it doesn’t work with Processing objects from PImage
, or PVector
.
There is this other Java strategy that has the same problem.
from java import io
def saveObject(x,fname="jython.bin"):
outs=io.ObjectOutputStream(io.FileOutputStream(fname))
outs.writeObject(x)
outs.close()
def loadObject(fname="jython.bin"):
ins=io.ObjectInputStream(io.FileInputStream(fname))
x=ins.readObject()
ins.close()
return x
# p = createImage(RGB, 100, 100)
# image(p, 0, 0)
x={1:1,'two':"2",'three':[1,2,3]}
saveObject(x)
p=loadObject()
print p
Is it possible to “mark” PImage as serializable?
http://www.javapractices.com/topic/TopicAction.do?Id=45