I am trying to create a thumbnail image using IronPython utilising the Common Language Runtime.
Coming from a Visual Basic background I am struggling with the concept of passing a delegated function to the CLR from within IronPython.
Below is my coding:
import os
import clr
# contains Image definition
clr.AddReference('System.Drawing')
from System.Drawing import Image
# contains Action and Func for delegation
clr.AddReference('System.Core')
from System import Func
# open image filename
objImageA = Image.FromFile('a.jpg')
# delegated function
def ImageAbortDelegate():
return False
objThumbImageAbort = Func[objImageA.GetThumbnailAbort](ImageAbortDelegate)
# for this example reduce image by 10 percent
intHeight = objImageA.Height / 10
intWidth = objImageA.Width / 10
# why is this failing?
objThumbImageA = objImageA.GetThumbnailImage(intHeight, intWidth, objThumbAbort, 0)
# gives error message TypeError: expected GetThumbnailImageAbort, got Func[GetThumbnailImageAbort]