Exception 'ImageElement' is not a subtype of type 'CanvasElement'

If the source of the BitmapData is of type ImageElement, we have the exception "type 'ImageElement' is not a subtype of type 'CanvasElement' of 'canvas'" when we use it in a GraphicsPattern.