I am using PIL to create thumbnails.
In order to use these thumbails in DrawMsg(), they must be Bitmaps and not a buffer memory.
PIL returns the converted image in memory.
So, the question is how to convert this memory to a Bitmap?
At this moment I store the thumbnail in a file and load that file back in the BaseBitmap.
bmp = c4d.bitmaps.BaseBitmap()
image = Image.open(...)
MAX_SIZE = (100, 100)
image.thumbnail(MAX_SIZE)
# Saving files
save = os.path.join(...) #save result in file
image.save(save)
bmp.InitWith(save) # load file into bitmap
# draw bitmap
self.DrawBitmap(bmp, x1, y1, 100, 100, 0, 0, 100, 100, c4d.BMP_NORMAL)
I also tried to use mfs, but no success
bmp = c4d.bitmaps.BaseBitmap()
hf = storage.HyperFile()
mfs = storage.MemoryFileStruct()
image = Image.open(img)
MAX_SIZE = (100, 100)
image.thumbnail(MAX_SIZE)
mfs.SetMemoryReadMode(image.fp.read(), len(image.fp.read()))
if hf.Open(0, mfs, c4d.FILEOPEN_READ, c4d.FILEDIALOG_NONE):
bmp = hf.ReadImage()
bmp.InitWith(save)bmp.Init(100, 100, depth=16, flags=c4d.INITBITMAPFLAGS_0)
self.DrawBitmap(bmp, x1, y1, 100, 100, 0, 0, 100, 100, c4d.BMP_NORMAL)