[Python.NET] How to use BitmapSource from System.Windows.Media.Imaging ?

Daniel Krause m.daniel.krause at googlemail.com
Sun Jan 20 20:40:49 CET 2013


I want to use BitmapSource from System.Windows.Media.Imaging
(Documentation here:
http://msdn.microsoft.com/de-de/library/system.windows.media.imaging.bitmapsource(v=vs.100).aspx)

It would be great if someone could help me with this, as I do not have yet
much experience with python for .NET, and none at all with .NET itself.

My test script:

import clr
clr.AddReference("System.Windows")
import System.Windows
bitmap = System.Windows.Media.Imaging.BitmapSource()

The interpreter info is:
Traceback (most recent call last):
  File "C:\Users\mdk\workspace\testbitmap.py", line 4, in <module>
    bitmapsrc = System.Windows.Media.Imaging.BitmapSource()
AttributeError: Media

I tried also:

import clr
clr.AddReference("System.Windows.Media")
import System.Windows
bitmapsrc = System.Windows.Media.Imaging.BitmapSource()


Traceback (most recent call last):
  File "C:\Users\mdk\workspace\testbitmap.py",
line 2, in <module>
    clr.AddReference("System.Windows.Media")
System.IO.FileNotFoundException: Unable to find assembly
'System.Windows.Media'.
   bei Python.Runtime.CLRModule.AddReference(String name)

And I also tried:

import clr
clr.AddReference("System.Windows")
from System.Windows import Media
bitmapsrc = Media.Imaging.BitmapSource()

Traceback (most recent call last):
  File
"C:\Users\mdk\workspace\lr_control\src\lr_control\camera\testbitmap.py",
line 3, in <module>
    from System.Windows import Media
ImportError: cannot import name Media
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20130120/c7066461/attachment.html>


More information about the PythonDotNet mailing list