All pastes #1526823 Raw Edit

Untitled

public text v1 · immutable
#1526823 ·published 2009-08-12 17:47 UTC
rendered paste body
diff --git a/class/System.Windows/Mono/GeneratedPInvokes.cs b/class/System.Windows/Mono/GeneratedPInvokes.cs
index d5ce3c2..b2dd506 100644
--- a/class/System.Windows/Mono/GeneratedPInvokes.cs
+++ b/class/System.Windows/Mono/GeneratedPInvokes.cs
@@ -252,6 +252,10 @@ namespace Mono {
 		public extern static IntPtr bitmap_source_new ();
 
 		[DllImport ("moon")]
+		// gpointer bitmap_source_get_bitmap_data (BitmapSource *instance);
+		public extern static IntPtr bitmap_source_get_bitmap_data (IntPtr instance);
+
+		[DllImport ("moon")]
 		// void bitmap_source_invalidate (BitmapSource *instance);
 		public extern static void bitmap_source_invalidate (IntPtr instance);
 
diff --git a/class/System.Windows/System.Windows.Media.Imaging/WriteableBitmap.cs b/class/System.Windows/System.Windows.Media.Imaging/WriteableBitmap.cs
index 3506049..166557e 100644
--- a/class/System.Windows/System.Windows.Media.Imaging/WriteableBitmap.cs
+++ b/class/System.Windows/System.Windows.Media.Imaging/WriteableBitmap.cs
@@ -39,46 +39,46 @@ namespace System.Windows.Media.Imaging
 	{
 		IntPtr buffer;
 		bool rendered;
+		int[] pixels;
+		GCHandle pixels_handle;
 
 		public WriteableBitmap (BitmapSource source) : base (NativeMethods.writeable_bitmap_new (), true)
 		{
 			rendered = true;
 			if (source != null)
 				NativeMethods.writeable_bitmap_initialize_from_bitmap_source (native, source.native);
+
+			pixels = new int[source.PixelWidth * source.PixelHeight];
+			Marshal.Copy (NativeMethods.bitmap_source_get_bitmap_data (source.native),
+				      pixels, 0, pixels.Length);
 		}
 
-		public WriteableBitmap (int width, int height, PixelFormat format) : base (NativeMethods.writeable_bitmap_new (), true)
+		public WriteableBitmap (int width, int height) : base (NativeMethods.writeable_bitmap_new (), true)
 		{
 			PixelWidth = width;
 			PixelHeight = height;
-			PixelFormat = format;
 			rendered = false;
 
-			checked {
-				buffer = Marshal.AllocHGlobal (width * height * 4);
-				NativeMethods.bitmap_source_set_bitmap_data (native, buffer);
-			}
-		}
+			pixels = new int[PixelWidth * PixelHeight];
 
-		public int this[int index] {
-			get {
-				if (rendered)
-					throw new NullReferenceException ();
+			pixels_handle = GCHandle.Alloc(pixels, GCHandleType.Pinned); // pin it so it doesn't move
 
-				return Marshal.ReadInt32 (buffer, index*4);
-			}
-			set {
-				if (index > PixelWidth*PixelHeight || index < 0)
-					throw new ArgumentOutOfRangeException ("index must lie withing the boundaries of the bitmap");
-				checked {
-					Marshal.WriteInt32 (buffer, index*4, value);
-				}
+			NativeMethods.bitmap_source_set_bitmap_data (native, pixels_handle.AddrOfPinnedObject());
+		}
+
+		~WriteableBitmap ()
+		{
+			if (pixels_handle.IsAllocated) {
+				pixels_handle.Free ();
 			}
 		}
-		
-		public void Render (UIElement element, Transform transform) {
-			Lock ();
 
+		public int[] Pixels {
+			get { return pixels; }
+		}
+
+		public void Render (UIElement element, Transform transform)
+		{
 			if (element == null)
 				throw new NullReferenceException ("element cannot be null");
 			if (transform == null)
@@ -86,21 +86,12 @@ namespace System.Windows.Media.Imaging
 
 			rendered = true;
 			NativeMethods.writeable_bitmap_render (native, element.native, transform.native);
-
-			Unlock ();
 		}
 
-		public void Invalidate () {
+		public void Invalidate ()
+		{
 			NativeMethods.bitmap_source_invalidate (native);
 		}
-
-		public void Lock () {
-			NativeMethods.writeable_bitmap_lock (native);
-		}
-
-		public void Unlock () {
-			NativeMethods.writeable_bitmap_unlock (native);
-		}
 	}
 
 }
diff --git a/class/tuning/SecurityAttributes/automatic/System.Windows.auto.ssc b/class/tuning/SecurityAttributes/automatic/System.Windows.auto.ssc
index 521c48d..1eb4777 100644
--- a/class/tuning/SecurityAttributes/automatic/System.Windows.auto.ssc
+++ b/class/tuning/SecurityAttributes/automatic/System.Windows.auto.ssc
@@ -1,5 +1,5 @@
 # [SecuritySafeCritical] needed inside System.Windows to call all [SecurityCritical] methods
-# 472 methods
+# 469 methods
 
 +SSC-M: System.Void Microsoft.Internal.TextBoxView::.ctor()
 +SSC-M: Mono.Xaml.ManagedXamlLoader Mono.ApplicationLauncher::CreateXamlLoader(System.IntPtr,System.IntPtr,System.IntPtr,System.String,System.String,System.String)
@@ -328,13 +328,10 @@
 +SSC-M: System.Int32 System.Windows.Media.Imaging.DownloadProgressEventArgs::get_Progress()
 +SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::.ctor()
 +SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::.ctor(System.Windows.Media.Imaging.BitmapSource)
-+SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::.ctor(System.Int32,System.Int32,System.Windows.Media.PixelFormat)
-+SSC-M: System.Int32 System.Windows.Media.Imaging.WriteableBitmap::get_Item(System.Int32)
-+SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::set_Item(System.Int32,System.Int32)
++SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::.ctor(System.Int32,System.Int32)
++SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::Finalize()
 +SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::Render(System.Windows.UIElement,System.Windows.Media.Transform)
 +SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::Invalidate()
-+SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::Lock()
-+SSC-M: System.Void System.Windows.Media.Imaging.WriteableBitmap::Unlock()
 +SSC-M: System.Void System.Windows.Media.LinearGradientBrush::.ctor()
 +SSC-M: System.Void System.Windows.Media.LineGeometry::.ctor()
 +SSC-M: System.Void System.Windows.Media.LineSegment::.ctor()
diff --git a/src/bitmapsource.cpp b/src/bitmapsource.cpp
index fa22fed..57954a1 100644
--- a/src/bitmapsource.cpp
+++ b/src/bitmapsource.cpp
@@ -66,6 +66,8 @@ BitmapSource::Invalidate ()
 		cairo_surface_destroy (image_surface);
 
 	image_surface = cairo_image_surface_create_for_data ((unsigned char *) GetBitmapData (), GetPixelFormat () == PixelFormatBgr32 ? CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_ARGB32, GetPixelWidth (), GetPixelHeight (), GetPixelWidth ()*4);
+
+	Emit (BitmapSource::PixelDataChangedEvent);
 }
 
 cairo_surface_t *
diff --git a/src/bitmapsource.h b/src/bitmapsource.h
index aa3b65a..8f161db 100644
--- a/src/bitmapsource.h
+++ b/src/bitmapsource.h
@@ -38,12 +38,15 @@ class BitmapSource : public ImageSource {
 	const static int PixelHeightProperty;
  	/* @PropertyType=PixelFormat,DefaultValue=PixelFormatPbgra32,ManagedAccess=Internal,GenerateAccessors */
 	const static int PixelFormatProperty;
-	
+
+	const static int PixelDataChangedEvent;
+
 	virtual gint32 GetPixelWidth ();
 	virtual void SetPixelWidth (gint32 width);
 	virtual gint32 GetPixelHeight ();
 	virtual void SetPixelHeight (gint32 height);
 
+	/* @GenerateCBinding,GeneratePInvoke */
 	gpointer GetBitmapData ();
 	/* @GenerateCBinding,GeneratePInvoke */
 	void SetBitmapData (gpointer data);
diff --git a/src/brush.cpp b/src/brush.cpp
index b13769b..9341a12 100644
--- a/src/brush.cpp
+++ b/src/brush.cpp
@@ -522,6 +522,7 @@ ImageBrush::Dispose ()
 		source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
 		source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
 		source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+		source->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
 	}
 
 	TileBrush::Dispose ();
@@ -552,6 +553,14 @@ ImageBrush::image_failed (EventObject *sender, EventArgs *calldata, gpointer clo
 }
 
 void
+ImageBrush::source_pixel_data_changed (EventObject *sender, EventArgs *calldata, gpointer closure)
+{
+	ImageBrush *media = (ImageBrush *) closure;
+
+	media->SourcePixelDataChanged ();
+}
+
+void
 ImageBrush::DownloadProgress ()
 {
 	BitmapImage *source = (BitmapImage *) GetImageSource ();
@@ -563,7 +572,7 @@ ImageBrush::DownloadProgress ()
 void
 ImageBrush::ImageOpened ()
 {
-	BitmapImage *source = (BitmapImage *) GetImageSource ();
+	BitmapImage *source = (BitmapImage*)GetImageSource ();
 
 	source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
 	source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
@@ -573,7 +582,7 @@ ImageBrush::ImageOpened ()
 void
 ImageBrush::ImageFailed ()
 {
-	BitmapImage *source = (BitmapImage *) GetImageSource ();
+	BitmapImage *source = (BitmapImage*)GetImageSource ();
 
 	source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
 	source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
@@ -583,6 +592,12 @@ ImageBrush::ImageFailed ()
 }
 
 void
+ImageBrush::SourcePixelDataChanged ()
+{
+	NotifyListenersOfPropertyChange (Brush::ChangedProperty, NULL);
+}
+
+void
 ImageBrush::SetSource (Downloader *downloader, const char *PartName)
 {
 	BitmapImage *source = (BitmapImage *) GetImageSource ();
@@ -609,15 +624,22 @@ ImageBrush::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
 		ImageSource *source = args->GetNewValue () ? args->GetNewValue ()->AsImageSource () : NULL;
 		ImageSource *old = args->GetOldValue () ? args->GetOldValue ()->AsImageSource () : NULL;
 
+		if (old && old->Is(Type::BITMAPSOURCE)) {
+			old->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
+		}
+		if (source && source->Is(Type::BITMAPSOURCE)) {
+			source->AddHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
+		}
+
 		if (old && old->Is(Type::BITMAPIMAGE)) {
-			((BitmapImage *)old)->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
-			((BitmapImage *)old)->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
-			((BitmapImage *)old)->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+			old->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
+			old->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
+			old->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
                 }
 		if (source && source->Is(Type::BITMAPIMAGE)) {
-			((BitmapImage *)source)->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
-			((BitmapImage *)source)->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
-			((BitmapImage *)source)->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+			source->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
+			source->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
+			source->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this);
 		}
         }
 
diff --git a/src/brush.h b/src/brush.h
index 47d84c2..4aa92fc 100644
--- a/src/brush.h
+++ b/src/brush.h
@@ -309,10 +309,12 @@ private:
 	void DownloadProgress ();
 	void ImageOpened ();
 	void ImageFailed ();
+	void SourcePixelDataChanged ();
 
 	static void download_progress (EventObject *sender, EventArgs *calldata, gpointer closure);
 	static void image_opened (EventObject *sender, EventArgs *calldata, gpointer closure);
 	static void image_failed (EventObject *sender, EventArgs *calldata, gpointer closure);
+	static void source_pixel_data_changed (EventObject *sender, EventArgs *calldata, gpointer closure);
 
  protected:
 	virtual ~ImageBrush ();
diff --git a/src/cbinding.cpp b/src/cbinding.cpp
index 3ca37af..f53dc8b 100644
--- a/src/cbinding.cpp
+++ b/src/cbinding.cpp
@@ -535,6 +535,17 @@ bitmap_source_new (void)
 }
 
 
+gpointer
+bitmap_source_get_bitmap_data (BitmapSource *instance)
+{
+	if (instance == NULL)
+		// Need to find a proper way to get the default value for the specified type and return that if instance is NULL.
+		return (gpointer) 0;
+	
+	return instance->GetBitmapData ();
+}
+
+
 void
 bitmap_source_invalidate (BitmapSource *instance)
 {
diff --git a/src/cbinding.h b/src/cbinding.h
index a6344ff..c645984 100644
--- a/src/cbinding.h
+++ b/src/cbinding.h
@@ -941,6 +941,9 @@ void bitmap_image_pixmap_complete (BitmapImage *instance);
 BitmapSource *bitmap_source_new (void);
 
 /* @GeneratePInvoke */
+gpointer bitmap_source_get_bitmap_data (BitmapSource *instance);
+
+/* @GeneratePInvoke */
 void bitmap_source_invalidate (BitmapSource *instance);
 
 /* @GeneratePInvoke */
diff --git a/src/media.cpp b/src/media.cpp
index 0e253f2..58f7718 100644
--- a/src/media.cpp
+++ b/src/media.cpp
@@ -244,6 +244,10 @@ Image::Image ()
 
 Image::~Image ()
 {
+	BitmapSource *source = (BitmapSource*)GetSource ();
+
+	if (source)
+		source->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
 }
 
 void
@@ -271,6 +275,14 @@ Image::image_failed (EventObject *sender, EventArgs *calldata, gpointer closure)
 }
 
 void
+Image::source_pixel_data_changed (EventObject *sender, EventArgs *calldata, gpointer closure)
+{
+	Image *media = (Image *) closure;
+
+	media->SourcePixelDataChanged ();
+}
+
+void
 Image::DownloadProgress ()
 {
 	BitmapImage *source = (BitmapImage *) GetSource ();
@@ -282,11 +294,13 @@ Image::DownloadProgress ()
 void
 Image::ImageOpened ()
 {
-	BitmapImage *source = (BitmapImage *) GetSource ();
+	BitmapSource *source = (BitmapSource*)GetSource ();
 
-	source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
-	source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
-	source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+	if (source->Is (Type::BITMAPIMAGE)) {
+		source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
+		source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
+		source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+	}
 
 	InvalidateArrange ();
 	InvalidateMeasure ();
@@ -297,11 +311,14 @@ Image::ImageOpened ()
 void
 Image::ImageFailed ()
 {
-	BitmapImage *source = (BitmapImage *) GetSource ();
+	BitmapSource *source = (BitmapSource*) GetSource ();
 
-	source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
-	source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
-	source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+	if (source->Is (Type::BITMAPIMAGE)) {
+		source->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
+		source->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
+		source->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+	}
+	source->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
 
 	InvalidateArrange ();
 	InvalidateMeasure ();
@@ -312,6 +329,12 @@ Image::ImageFailed ()
 }
 
 void
+Image::SourcePixelDataChanged ()
+{
+	Invalidate();
+}
+
+void
 Image::SetSourceInternal (Downloader *downloader, char *PartName)
 {
 	BitmapImage *source = (BitmapImage *) GetSource ();
@@ -533,15 +556,22 @@ Image::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
 		ImageSource *source = args->GetNewValue () ? args->GetNewValue ()->AsImageSource () : NULL; 
 		ImageSource *old = args->GetOldValue () ? args->GetOldValue ()->AsImageSource () : NULL;
 
+		if (old && old->Is(Type::BITMAPSOURCE)) {
+			old->RemoveHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
+		}
+		if (source && source->Is(Type::BITMAPSOURCE)) {
+			source->AddHandler (BitmapSource::PixelDataChangedEvent, source_pixel_data_changed, this);
+		}
+
 		if (old && old->Is(Type::BITMAPIMAGE)) {
-			((BitmapImage *)old)->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
-			((BitmapImage *)old)->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
-			((BitmapImage *)old)->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+			old->RemoveHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
+			old->RemoveHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
+			old->RemoveHandler (BitmapImage::ImageFailedEvent, image_failed, this);
 		}
 		if (source && source->Is(Type::BITMAPIMAGE)) {
-			((BitmapImage *)source)->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
-			((BitmapImage *)source)->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
-			((BitmapImage *)source)->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this);
+			source->AddHandler (BitmapImage::DownloadProgressEvent, download_progress, this);
+			source->AddHandler (BitmapImage::ImageOpenedEvent, image_opened, this);
+			source->AddHandler (BitmapImage::ImageFailedEvent, image_failed, this);
 
 			if (((BitmapImage *)source)->GetPixelWidth () > 0 && ((BitmapImage *)source)->GetPixelHeight () > 0) {
 				ImageOpened ();
diff --git a/src/media.h b/src/media.h
index f9565aa..17dfad0 100644
--- a/src/media.h
+++ b/src/media.h
@@ -176,10 +176,12 @@ class Image : public MediaBase {
 	void DownloadProgress ();
 	void ImageOpened ();
 	void ImageFailed ();
+	void SourcePixelDataChanged ();
 
 	static void download_progress (EventObject *sender, EventArgs *calldata, gpointer closure);
 	static void image_opened (EventObject *sender, EventArgs *calldata, gpointer closure);
 	static void image_failed (EventObject *sender, EventArgs *calldata, gpointer closure);
+	static void source_pixel_data_changed (EventObject *sender, EventArgs *calldata, gpointer closure);
 
  protected:
 	virtual ~Image ();
diff --git a/src/type-generated.cpp b/src/type-generated.cpp
index fd94e81..b25589c 100644
--- a/src/type-generated.cpp
+++ b/src/type-generated.cpp
@@ -75,9 +75,10 @@
 #include "yuv-converter.h"
 
 const int Accessibility::PerformActionEvent = 1;
-const int BitmapImage::DownloadProgressEvent = 1;
-const int BitmapImage::ImageFailedEvent = 2;
-const int BitmapImage::ImageOpenedEvent = 3;
+const int BitmapImage::DownloadProgressEvent = 2;
+const int BitmapImage::ImageFailedEvent = 3;
+const int BitmapImage::ImageOpenedEvent = 4;
+const int BitmapSource::PixelDataChangedEvent = 1;
 const int Clock::CompletedEvent = 1;
 const int Clock::CurrentStateInvalidatedEvent = 2;
 const int Clock::CurrentTimeInvalidatedEvent = 3;
@@ -172,6 +173,7 @@ const int UIElement::UnloadedEvent = 17;
 
 const char *ACCESSIBILITY_Events [] = { "PerformAction", NULL };
 const char *BITMAPIMAGE_Events [] = { "DownloadProgress", "ImageFailed", "ImageOpened", NULL };
+const char *BITMAPSOURCE_Events [] = { "PixelDataChanged", NULL };
 const Type::Kind BOOL_Interfaces[] = { Type::ICOMPARABLE, Type::ICOMPARABLE_BOOL, Type::ICONVERTIBLE, Type::IEQUATABLE_BOOL };
 const Type::Kind CHAR_Interfaces[] = { Type::ICOMPARABLE, Type::ICOMPARABLE_CHAR, Type::ICONVERTIBLE, Type::IEQUATABLE_CHAR };
 const char *CLOCK_Events [] = { "Completed", "CurrentStateInvalidated", "CurrentTimeInvalidated", NULL };
@@ -232,8 +234,8 @@ Types::RegisterNativeTypes ()
 	types [(int) Type::BACKEASE] = new Type (Type::BACKEASE, Type::EASINGFUNCTIONBASE, false, false, "BackEase", 0, 1, NULL, 0, NULL, true, (create_inst_func *) back_ease_new, NULL);
 	types [(int) Type::BEGINSTORYBOARD] = new Type (Type::BEGINSTORYBOARD, Type::TRIGGERACTION, false, false, "BeginStoryboard", 0, 1, NULL, 0, NULL, true, (create_inst_func *) begin_storyboard_new, "Storyboard");
 	types [(int) Type::BEZIERSEGMENT] = new Type (Type::BEZIERSEGMENT, Type::PATHSEGMENT, false, false, "BezierSegment", 0, 1, NULL, 0, NULL, true, (create_inst_func *) bezier_segment_new, NULL);
-	types [(int) Type::BITMAPIMAGE] = new Type (Type::BITMAPIMAGE, Type::BITMAPSOURCE, false, false, "BitmapImage", 3, 4, BITMAPIMAGE_Events, 0, NULL, true, (create_inst_func *) bitmap_image_new, NULL);
-	types [(int) Type::BITMAPSOURCE] = new Type (Type::BITMAPSOURCE, Type::IMAGESOURCE, false, false, "BitmapSource", 0, 1, NULL, 0, NULL, true, (create_inst_func *) bitmap_source_new, NULL);
+	types [(int) Type::BITMAPIMAGE] = new Type (Type::BITMAPIMAGE, Type::BITMAPSOURCE, false, false, "BitmapImage", 3, 5, BITMAPIMAGE_Events, 0, NULL, true, (create_inst_func *) bitmap_image_new, NULL);
+	types [(int) Type::BITMAPSOURCE] = new Type (Type::BITMAPSOURCE, Type::IMAGESOURCE, false, false, "BitmapSource", 1, 2, BITMAPSOURCE_Events, 0, NULL, true, (create_inst_func *) bitmap_source_new, NULL);
 	types [(int) Type::BOOL] = new Type (Type::BOOL, Type::OBJECT, true, false, "bool", 0, 0, NULL, 4, BOOL_Interfaces, true, NULL, NULL);
 	types [(int) Type::BORDER] = new Type (Type::BORDER, Type::FRAMEWORKELEMENT, false, false, "Border", 0, 20, NULL, 0, NULL, true, (create_inst_func *) border_new, "Child");
 	types [(int) Type::BOUNCEEASE] = new Type (Type::BOUNCEEASE, Type::EASINGFUNCTIONBASE, false, false, "BounceEase", 0, 1, NULL, 0, NULL, true, (create_inst_func *) bounce_ease_new, NULL);
@@ -522,7 +524,7 @@ Types::RegisterNativeTypes ()
 	types [(int) Type::VIDEOBRUSH] = new Type (Type::VIDEOBRUSH, Type::TILEBRUSH, false, false, "VideoBrush", 0, 1, NULL, 0, NULL, true, (create_inst_func *) video_brush_new, NULL);
 	types [(int) Type::VIDEOSTREAM] = new Type (Type::VIDEOSTREAM, Type::IMEDIASTREAM, false, false, "VideoStream", 0, 2, NULL, 0, NULL, false, NULL, NULL);
 	types [(int) Type::VISUALBRUSH] = new Type (Type::VISUALBRUSH, Type::TILEBRUSH, false, false, "VisualBrush", 0, 1, NULL, 0, NULL, true, (create_inst_func *) visual_brush_new, NULL);
-	types [(int) Type::WRITEABLEBITMAP] = new Type (Type::WRITEABLEBITMAP, Type::BITMAPSOURCE, false, false, "WriteableBitmap", 0, 1, NULL, 0, NULL, true, (create_inst_func *) writeable_bitmap_new, NULL);
+	types [(int) Type::WRITEABLEBITMAP] = new Type (Type::WRITEABLEBITMAP, Type::BITMAPSOURCE, false, false, "WriteableBitmap", 0, 2, NULL, 0, NULL, true, (create_inst_func *) writeable_bitmap_new, NULL);
 	types [(int) Type::XMLLANGUAGE] = new Type (Type::XMLLANGUAGE, Type::OBJECT, false, false, "System.Windows.Markup.XmlLanguage", 0, 0, NULL, 0, NULL, false, NULL, NULL);
 	types [(int) Type::YUVCONVERTER] = new Type (Type::YUVCONVERTER, Type::IIMAGECONVERTER, false, false, "YUVConverter", 0, 1, NULL, 0, NULL, false, NULL, NULL);
 	types [(int) Type::LASTTYPE] = new Type (Type::LASTTYPE, Type::INVALID, false, false, NULL, 0, 0, NULL, 0, NULL, false, NULL, NULL);