Beispiel #1
1
        // Code compiled into PresentationFramework.dll

        // Initialize known object types
        internal static object CreateKnownElement(KnownElements knownElement) 
        {
            object o = null; 
            switch (knownElement) 
            {
                case KnownElements.AccessText: o = new System.Windows.Controls.AccessText();   break; 
                case KnownElements.AdornedElementPlaceholder: o = new System.Windows.Controls.AdornedElementPlaceholder();   break;
                case KnownElements.AdornerDecorator: o = new System.Windows.Documents.AdornerDecorator();   break;
                case KnownElements.AmbientLight: o = new System.Windows.Media.Media3D.AmbientLight();   break;
                case KnownElements.Application: o = new System.Windows.Application();   break; 
                case KnownElements.ArcSegment: o = new System.Windows.Media.ArcSegment();   break;
                case KnownElements.ArrayExtension: o = new System.Windows.Markup.ArrayExtension();   break; 
                case KnownElements.AxisAngleRotation3D: o = new System.Windows.Media.Media3D.AxisAngleRotation3D();   break; 
                case KnownElements.BeginStoryboard: o = new System.Windows.Media.Animation.BeginStoryboard();   break;
                case KnownElements.BevelBitmapEffect: o = new System.Windows.Media.Effects.BevelBitmapEffect();   break; 
                case KnownElements.BezierSegment: o = new System.Windows.Media.BezierSegment();   break;
                case KnownElements.Binding: o = new System.Windows.Data.Binding();   break;
                case KnownElements.BitmapEffectCollection: o = new System.Windows.Media.Effects.BitmapEffectCollection();   break;
                case KnownElements.BitmapEffectGroup: o = new System.Windows.Media.Effects.BitmapEffectGroup();   break; 
                case KnownElements.BitmapEffectInput: o = new System.Windows.Media.Effects.BitmapEffectInput();   break;
                case KnownElements.BitmapImage: o = new System.Windows.Media.Imaging.BitmapImage();   break; 
                case KnownElements.BlockUIContainer: o = new System.Windows.Documents.BlockUIContainer();   break; 
                case KnownElements.BlurBitmapEffect: o = new System.Windows.Media.Effects.BlurBitmapEffect();   break;
                case KnownElements.BmpBitmapEncoder: o = new System.Windows.Media.Imaging.BmpBitmapEncoder();   break; 
                case KnownElements.Bold: o = new System.Windows.Documents.Bold();   break;
                case KnownElements.BoolIListConverter: o = new System.Windows.Media.Converters.BoolIListConverter();   break;
                case KnownElements.BooleanAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.BooleanAnimationUsingKeyFrames();   break;
                case KnownElements.BooleanConverter: o = new System.ComponentModel.BooleanConverter();   break; 
                case KnownElements.BooleanKeyFrameCollection: o = new System.Windows.Media.Animation.BooleanKeyFrameCollection();   break;
                case KnownElements.BooleanToVisibilityConverter: o = new System.Windows.Controls.BooleanToVisibilityConverter();   break; 
                case KnownElements.Border: o = new System.Windows.Controls.Border();   break; 
                case KnownElements.BorderGapMaskConverter: o = new System.Windows.Controls.BorderGapMaskConverter();   break;
                case KnownElements.BrushConverter: o = new System.Windows.Media.BrushConverter();   break; 
                case KnownElements.BulletDecorator: o = new System.Windows.Controls.Primitives.BulletDecorator();   break;
                case KnownElements.Button: o = new System.Windows.Controls.Button();   break;
                case KnownElements.ByteAnimation: o = new System.Windows.Media.Animation.ByteAnimation();   break;
                case KnownElements.ByteAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ByteAnimationUsingKeyFrames();   break; 
                case KnownElements.ByteConverter: o = new System.ComponentModel.ByteConverter();   break;
                case KnownElements.ByteKeyFrameCollection: o = new System.Windows.Media.Animation.ByteKeyFrameCollection();   break; 
                case KnownElements.Canvas: o = new System.Windows.Controls.Canvas();   break; 
                case KnownElements.CharAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.CharAnimationUsingKeyFrames();   break;
                case KnownElements.CharConverter: o = new System.ComponentModel.CharConverter();   break; 
                case KnownElements.CharIListConverter: o = new System.Windows.Media.Converters.CharIListConverter();   break;
                case KnownElements.CharKeyFrameCollection: o = new System.Windows.Media.Animation.CharKeyFrameCollection();   break;
                case KnownElements.CheckBox: o = new System.Windows.Controls.CheckBox();   break;
                case KnownElements.CollectionContainer: o = new System.Windows.Data.CollectionContainer();   break; 
                case KnownElements.CollectionViewSource: o = new System.Windows.Data.CollectionViewSource();   break;
                case KnownElements.Color: o = new System.Windows.Media.Color();   break; 
                case KnownElements.ColorAnimation: o = new System.Windows.Media.Animation.ColorAnimation();   break; 
                case KnownElements.ColorAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ColorAnimationUsingKeyFrames();   break;
                case KnownElements.ColorConvertedBitmap: o = new System.Windows.Media.Imaging.ColorConvertedBitmap();   break; 
                case KnownElements.ColorConvertedBitmapExtension: o = new System.Windows.ColorConvertedBitmapExtension();   break;
                case KnownElements.ColorConverter: o = new System.Windows.Media.ColorConverter();   break;
                case KnownElements.ColorKeyFrameCollection: o = new System.Windows.Media.Animation.ColorKeyFrameCollection();   break;
                case KnownElements.ColumnDefinition: o = new System.Windows.Controls.ColumnDefinition();   break; 
                case KnownElements.CombinedGeometry: o = new System.Windows.Media.CombinedGeometry();   break;
                case KnownElements.ComboBox: o = new System.Windows.Controls.ComboBox();   break; 
                case KnownElements.ComboBoxItem: o = new System.Windows.Controls.ComboBoxItem();   break; 
                case KnownElements.CommandConverter: o = new System.Windows.Input.CommandConverter();   break;
                case KnownElements.ComponentResourceKey: o = new System.Windows.ComponentResourceKey();   break; 
                case KnownElements.ComponentResourceKeyConverter: o = new System.Windows.Markup.ComponentResourceKeyConverter();   break;
                case KnownElements.Condition: o = new System.Windows.Condition();   break;
                case KnownElements.ContainerVisual: o = new System.Windows.Media.ContainerVisual();   break;
                case KnownElements.ContentControl: o = new System.Windows.Controls.ContentControl();   break; 
                case KnownElements.ContentElement: o = new System.Windows.ContentElement();   break;
                case KnownElements.ContentPresenter: o = new System.Windows.Controls.ContentPresenter();   break; 
                case KnownElements.ContextMenu: o = new System.Windows.Controls.ContextMenu();   break; 
                case KnownElements.Control: o = new System.Windows.Controls.Control();   break;
                case KnownElements.ControlTemplate: o = new System.Windows.Controls.ControlTemplate();   break; 
                case KnownElements.CornerRadius: o = new System.Windows.CornerRadius();   break;
                case KnownElements.CornerRadiusConverter: o = new System.Windows.CornerRadiusConverter();   break;
                case KnownElements.CroppedBitmap: o = new System.Windows.Media.Imaging.CroppedBitmap();   break;
                case KnownElements.CultureInfoConverter: o = new System.ComponentModel.CultureInfoConverter();   break; 
                case KnownElements.CultureInfoIetfLanguageTagConverter: o = new System.Windows.CultureInfoIetfLanguageTagConverter();   break;
                case KnownElements.CursorConverter: o = new System.Windows.Input.CursorConverter();   break; 
                case KnownElements.DashStyle: o = new System.Windows.Media.DashStyle();   break; 
                case KnownElements.DataTemplate: o = new System.Windows.DataTemplate();   break;
                case KnownElements.DataTemplateKey: o = new System.Windows.DataTemplateKey();   break; 
                case KnownElements.DataTrigger: o = new System.Windows.DataTrigger();   break;
                case KnownElements.DateTimeConverter: o = new System.ComponentModel.DateTimeConverter();   break;
                case KnownElements.DateTimeConverter2: o = new System.Windows.Markup.DateTimeConverter2();   break;
                case KnownElements.DecimalAnimation: o = new System.Windows.Media.Animation.DecimalAnimation();   break; 
                case KnownElements.DecimalAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.DecimalAnimationUsingKeyFrames();   break;
                case KnownElements.DecimalConverter: o = new System.ComponentModel.DecimalConverter();   break; 
                case KnownElements.DecimalKeyFrameCollection: o = new System.Windows.Media.Animation.DecimalKeyFrameCollection();   break; 
                case KnownElements.Decorator: o = new System.Windows.Controls.Decorator();   break;
                case KnownElements.DependencyObject: o = new System.Windows.DependencyObject();   break; 
                case KnownElements.DependencyPropertyConverter: o = new System.Windows.Markup.DependencyPropertyConverter();   break;
                case KnownElements.DialogResultConverter: o = new System.Windows.DialogResultConverter();   break;
                case KnownElements.DiffuseMaterial: o = new System.Windows.Media.Media3D.DiffuseMaterial();   break;
                case KnownElements.DirectionalLight: o = new System.Windows.Media.Media3D.DirectionalLight();   break; 
                case KnownElements.DiscreteBooleanKeyFrame: o = new System.Windows.Media.Animation.DiscreteBooleanKeyFrame();   break;
                case KnownElements.DiscreteByteKeyFrame: o = new System.Windows.Media.Animation.DiscreteByteKeyFrame();   break; 
                case KnownElements.DiscreteCharKeyFrame: o = new System.Windows.Media.Animation.DiscreteCharKeyFrame();   break; 
                case KnownElements.DiscreteColorKeyFrame: o = new System.Windows.Media.Animation.DiscreteColorKeyFrame();   break;
                case KnownElements.DiscreteDecimalKeyFrame: o = new System.Windows.Media.Animation.DiscreteDecimalKeyFrame();   break; 
                case KnownElements.DiscreteDoubleKeyFrame: o = new System.Windows.Media.Animation.DiscreteDoubleKeyFrame();   break;
                case KnownElements.DiscreteInt16KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt16KeyFrame();   break;
                case KnownElements.DiscreteInt32KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt32KeyFrame();   break;
                case KnownElements.DiscreteInt64KeyFrame: o = new System.Windows.Media.Animation.DiscreteInt64KeyFrame();   break; 
                case KnownElements.DiscreteMatrixKeyFrame: o = new System.Windows.Media.Animation.DiscreteMatrixKeyFrame();   break;
                case KnownElements.DiscreteObjectKeyFrame: o = new System.Windows.Media.Animation.DiscreteObjectKeyFrame();   break; 
                case KnownElements.DiscretePoint3DKeyFrame: o = new System.Windows.Media.Animation.DiscretePoint3DKeyFrame();   break; 
                case KnownElements.DiscretePointKeyFrame: o = new System.Windows.Media.Animation.DiscretePointKeyFrame();   break;
                case KnownElements.DiscreteQuaternionKeyFrame: o = new System.Windows.Media.Animation.DiscreteQuaternionKeyFrame();   break; 
                case KnownElements.DiscreteRectKeyFrame: o = new System.Windows.Media.Animation.DiscreteRectKeyFrame();   break;
                case KnownElements.DiscreteRotation3DKeyFrame: o = new System.Windows.Media.Animation.DiscreteRotation3DKeyFrame();   break;
                case KnownElements.DiscreteSingleKeyFrame: o = new System.Windows.Media.Animation.DiscreteSingleKeyFrame();   break;
                case KnownElements.DiscreteSizeKeyFrame: o = new System.Windows.Media.Animation.DiscreteSizeKeyFrame();   break; 
                case KnownElements.DiscreteStringKeyFrame: o = new System.Windows.Media.Animation.DiscreteStringKeyFrame();   break;
                case KnownElements.DiscreteThicknessKeyFrame: o = new System.Windows.Media.Animation.DiscreteThicknessKeyFrame();   break; 
                case KnownElements.DiscreteVector3DKeyFrame: o = new System.Windows.Media.Animation.DiscreteVector3DKeyFrame();   break; 
                case KnownElements.DiscreteVectorKeyFrame: o = new System.Windows.Media.Animation.DiscreteVectorKeyFrame();   break;
                case KnownElements.DockPanel: o = new System.Windows.Controls.DockPanel();   break; 
                case KnownElements.DocumentPageView: o = new System.Windows.Controls.Primitives.DocumentPageView();   break;
                case KnownElements.DocumentReference: o = new System.Windows.Documents.DocumentReference();   break;
                case KnownElements.DocumentViewer: o = new System.Windows.Controls.DocumentViewer();   break;
                case KnownElements.DoubleAnimation: o = new System.Windows.Media.Animation.DoubleAnimation();   break; 
                case KnownElements.DoubleAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames();   break;
                case KnownElements.DoubleAnimationUsingPath: o = new System.Windows.Media.Animation.DoubleAnimationUsingPath();   break; 
                case KnownElements.DoubleCollection: o = new System.Windows.Media.DoubleCollection();   break; 
                case KnownElements.DoubleCollectionConverter: o = new System.Windows.Media.DoubleCollectionConverter();   break;
                case KnownElements.DoubleConverter: o = new System.ComponentModel.DoubleConverter();   break; 
                case KnownElements.DoubleIListConverter: o = new System.Windows.Media.Converters.DoubleIListConverter();   break;
                case KnownElements.DoubleKeyFrameCollection: o = new System.Windows.Media.Animation.DoubleKeyFrameCollection();   break;
                case KnownElements.DrawingBrush: o = new System.Windows.Media.DrawingBrush();   break;
                case KnownElements.DrawingCollection: o = new System.Windows.Media.DrawingCollection();   break; 
                case KnownElements.DrawingGroup: o = new System.Windows.Media.DrawingGroup();   break;
                case KnownElements.DrawingImage: o = new System.Windows.Media.DrawingImage();   break; 
                case KnownElements.DrawingVisual: o = new System.Windows.Media.DrawingVisual();   break; 
                case KnownElements.DropShadowBitmapEffect: o = new System.Windows.Media.Effects.DropShadowBitmapEffect();   break;
                case KnownElements.Duration: o = new System.Windows.Duration();   break; 
                case KnownElements.DurationConverter: o = new System.Windows.DurationConverter();   break;
                case KnownElements.DynamicResourceExtension: o = new System.Windows.DynamicResourceExtension();   break;
                case KnownElements.DynamicResourceExtensionConverter: o = new System.Windows.DynamicResourceExtensionConverter();   break;
                case KnownElements.Ellipse: o = new System.Windows.Shapes.Ellipse();   break; 
                case KnownElements.EllipseGeometry: o = new System.Windows.Media.EllipseGeometry();   break;
                case KnownElements.EmbossBitmapEffect: o = new System.Windows.Media.Effects.EmbossBitmapEffect();   break; 
                case KnownElements.EmissiveMaterial: o = new System.Windows.Media.Media3D.EmissiveMaterial();   break; 
                case KnownElements.EventSetter: o = new System.Windows.EventSetter();   break;
                case KnownElements.EventTrigger: o = new System.Windows.EventTrigger();   break; 
                case KnownElements.Expander: o = new System.Windows.Controls.Expander();   break;
                case KnownElements.ExpressionConverter: o = new System.Windows.ExpressionConverter();   break;
                case KnownElements.Figure: o = new System.Windows.Documents.Figure();   break;
                case KnownElements.FigureLength: o = new System.Windows.FigureLength();   break; 
                case KnownElements.FigureLengthConverter: o = new System.Windows.FigureLengthConverter();   break;
                case KnownElements.FixedDocument: o = new System.Windows.Documents.FixedDocument();   break; 
                case KnownElements.FixedDocumentSequence: o = new System.Windows.Documents.FixedDocumentSequence();   break; 
                case KnownElements.FixedPage: o = new System.Windows.Documents.FixedPage();   break;
                case KnownElements.Floater: o = new System.Windows.Documents.Floater();   break; 
                case KnownElements.FlowDocument: o = new System.Windows.Documents.FlowDocument();   break;
                case KnownElements.FlowDocumentPageViewer: o = new System.Windows.Controls.FlowDocumentPageViewer();   break;
                case KnownElements.FlowDocumentReader: o = new System.Windows.Controls.FlowDocumentReader();   break;
                case KnownElements.FlowDocumentScrollViewer: o = new System.Windows.Controls.FlowDocumentScrollViewer();   break; 
                case KnownElements.FontFamily: o = new System.Windows.Media.FontFamily();   break;
                case KnownElements.FontFamilyConverter: o = new System.Windows.Media.FontFamilyConverter();   break; 
                case KnownElements.FontSizeConverter: o = new System.Windows.FontSizeConverter();   break; 
                case KnownElements.FontStretch: o = new System.Windows.FontStretch();   break;
                case KnownElements.FontStretchConverter: o = new System.Windows.FontStretchConverter();   break; 
                case KnownElements.FontStyle: o = new System.Windows.FontStyle();   break;
                case KnownElements.FontStyleConverter: o = new System.Windows.FontStyleConverter();   break;
                case KnownElements.FontWeight: o = new System.Windows.FontWeight();   break;
                case KnownElements.FontWeightConverter: o = new System.Windows.FontWeightConverter();   break; 
                case KnownElements.FormatConvertedBitmap: o = new System.Windows.Media.Imaging.FormatConvertedBitmap();   break;
                case KnownElements.Frame: o = new System.Windows.Controls.Frame();   break; 
                case KnownElements.FrameworkContentElement: o = new System.Windows.FrameworkContentElement();   break; 
                case KnownElements.FrameworkElement: o = new System.Windows.FrameworkElement();   break;
                case KnownElements.FrameworkElementFactory: o = new System.Windows.FrameworkElementFactory();   break; 
                case KnownElements.FrameworkPropertyMetadata: o = new System.Windows.FrameworkPropertyMetadata();   break;
                case KnownElements.GeneralTransformCollection: o = new System.Windows.Media.GeneralTransformCollection();   break;
                case KnownElements.GeneralTransformGroup: o = new System.Windows.Media.GeneralTransformGroup();   break;
                case KnownElements.GeometryCollection: o = new System.Windows.Media.GeometryCollection();   break; 
                case KnownElements.GeometryConverter: o = new System.Windows.Media.GeometryConverter();   break;
                case KnownElements.GeometryDrawing: o = new System.Windows.Media.GeometryDrawing();   break; 
                case KnownElements.GeometryGroup: o = new System.Windows.Media.GeometryGroup();   break; 
                case KnownElements.GeometryModel3D: o = new System.Windows.Media.Media3D.GeometryModel3D();   break;
                case KnownElements.GestureRecognizer: o = new System.Windows.Ink.GestureRecognizer();   break; 
                case KnownElements.GifBitmapEncoder: o = new System.Windows.Media.Imaging.GifBitmapEncoder();   break;
                case KnownElements.GlyphRun: o = new System.Windows.Media.GlyphRun();   break;
                case KnownElements.GlyphRunDrawing: o = new System.Windows.Media.GlyphRunDrawing();   break;
                case KnownElements.GlyphTypeface: o = new System.Windows.Media.GlyphTypeface();   break; 
                case KnownElements.Glyphs: o = new System.Windows.Documents.Glyphs();   break;
                case KnownElements.GradientStop: o = new System.Windows.Media.GradientStop();   break; 
                case KnownElements.GradientStopCollection: o = new System.Windows.Media.GradientStopCollection();   break; 
                case KnownElements.Grid: o = new System.Windows.Controls.Grid();   break;
                case KnownElements.GridLength: o = new System.Windows.GridLength();   break; 
                case KnownElements.GridLengthConverter: o = new System.Windows.GridLengthConverter();   break;
                case KnownElements.GridSplitter: o = new System.Windows.Controls.GridSplitter();   break;
                case KnownElements.GridView: o = new System.Windows.Controls.GridView();   break;
                case KnownElements.GridViewColumn: o = new System.Windows.Controls.GridViewColumn();   break; 
                case KnownElements.GridViewColumnHeader: o = new System.Windows.Controls.GridViewColumnHeader();   break;
                case KnownElements.GridViewHeaderRowPresenter: o = new System.Windows.Controls.GridViewHeaderRowPresenter();   break; 
                case KnownElements.GridViewRowPresenter: o = new System.Windows.Controls.GridViewRowPresenter();   break; 
                case KnownElements.GroupBox: o = new System.Windows.Controls.GroupBox();   break;
                case KnownElements.GroupItem: o = new System.Windows.Controls.GroupItem();   break; 
                case KnownElements.GuidConverter: o = new System.ComponentModel.GuidConverter();   break;
                case KnownElements.GuidelineSet: o = new System.Windows.Media.GuidelineSet();   break;
                case KnownElements.HeaderedContentControl: o = new System.Windows.Controls.HeaderedContentControl();   break;
                case KnownElements.HeaderedItemsControl: o = new System.Windows.Controls.HeaderedItemsControl();   break; 
                case KnownElements.HierarchicalDataTemplate: o = new System.Windows.HierarchicalDataTemplate();   break;
                case KnownElements.HostVisual: o = new System.Windows.Media.HostVisual();   break; 
                case KnownElements.Hyperlink: o = new System.Windows.Documents.Hyperlink();   break; 
                case KnownElements.Image: o = new System.Windows.Controls.Image();   break;
                case KnownElements.ImageBrush: o = new System.Windows.Media.ImageBrush();   break; 
                case KnownElements.ImageDrawing: o = new System.Windows.Media.ImageDrawing();   break;
                case KnownElements.ImageSourceConverter: o = new System.Windows.Media.ImageSourceConverter();   break;
                case KnownElements.InkCanvas: o = new System.Windows.Controls.InkCanvas();   break;
                case KnownElements.InkPresenter: o = new System.Windows.Controls.InkPresenter();   break; 
                case KnownElements.InlineUIContainer: o = new System.Windows.Documents.InlineUIContainer();   break;
                case KnownElements.InputScope: o = new System.Windows.Input.InputScope();   break; 
                case KnownElements.InputScopeConverter: o = new System.Windows.Input.InputScopeConverter();   break; 
                case KnownElements.InputScopeName: o = new System.Windows.Input.InputScopeName();   break;
                case KnownElements.InputScopeNameConverter: o = new System.Windows.Input.InputScopeNameConverter();   break; 
                case KnownElements.Int16Animation: o = new System.Windows.Media.Animation.Int16Animation();   break;
                case KnownElements.Int16AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int16AnimationUsingKeyFrames();   break;
                case KnownElements.Int16Converter: o = new System.ComponentModel.Int16Converter();   break;
                case KnownElements.Int16KeyFrameCollection: o = new System.Windows.Media.Animation.Int16KeyFrameCollection();   break; 
                case KnownElements.Int32Animation: o = new System.Windows.Media.Animation.Int32Animation();   break;
                case KnownElements.Int32AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int32AnimationUsingKeyFrames();   break; 
                case KnownElements.Int32Collection: o = new System.Windows.Media.Int32Collection();   break; 
                case KnownElements.Int32CollectionConverter: o = new System.Windows.Media.Int32CollectionConverter();   break;
                case KnownElements.Int32Converter: o = new System.ComponentModel.Int32Converter();   break; 
                case KnownElements.Int32KeyFrameCollection: o = new System.Windows.Media.Animation.Int32KeyFrameCollection();   break;
                case KnownElements.Int32Rect: o = new System.Windows.Int32Rect();   break;
                case KnownElements.Int32RectConverter: o = new System.Windows.Int32RectConverter();   break;
                case KnownElements.Int64Animation: o = new System.Windows.Media.Animation.Int64Animation();   break; 
                case KnownElements.Int64AnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Int64AnimationUsingKeyFrames();   break;
                case KnownElements.Int64Converter: o = new System.ComponentModel.Int64Converter();   break; 
                case KnownElements.Int64KeyFrameCollection: o = new System.Windows.Media.Animation.Int64KeyFrameCollection();   break; 
                case KnownElements.Italic: o = new System.Windows.Documents.Italic();   break;
                case KnownElements.ItemsControl: o = new System.Windows.Controls.ItemsControl();   break; 
                case KnownElements.ItemsPanelTemplate: o = new System.Windows.Controls.ItemsPanelTemplate();   break;
                case KnownElements.ItemsPresenter: o = new System.Windows.Controls.ItemsPresenter();   break;
                case KnownElements.JournalEntryListConverter: o = new System.Windows.Navigation.JournalEntryListConverter();   break;
                case KnownElements.JournalEntryUnifiedViewConverter: o = new System.Windows.Navigation.JournalEntryUnifiedViewConverter();   break; 
                case KnownElements.JpegBitmapEncoder: o = new System.Windows.Media.Imaging.JpegBitmapEncoder();   break;
                case KnownElements.KeyBinding: o = new System.Windows.Input.KeyBinding();   break; 
                case KnownElements.KeyConverter: o = new System.Windows.Input.KeyConverter();   break; 
                case KnownElements.KeyGestureConverter: o = new System.Windows.Input.KeyGestureConverter();   break;
                case KnownElements.KeySpline: o = new System.Windows.Media.Animation.KeySpline();   break; 
                case KnownElements.KeySplineConverter: o = new System.Windows.KeySplineConverter();   break;
                case KnownElements.KeyTime: o = new System.Windows.Media.Animation.KeyTime();   break;
                case KnownElements.KeyTimeConverter: o = new System.Windows.KeyTimeConverter();   break;
                case KnownElements.Label: o = new System.Windows.Controls.Label();   break; 
                case KnownElements.LengthConverter: o = new System.Windows.LengthConverter();   break;
                case KnownElements.Line: o = new System.Windows.Shapes.Line();   break; 
                case KnownElements.LineBreak: o = new System.Windows.Documents.LineBreak();   break; 
                case KnownElements.LineGeometry: o = new System.Windows.Media.LineGeometry();   break;
                case KnownElements.LineSegment: o = new System.Windows.Media.LineSegment();   break; 
                case KnownElements.LinearByteKeyFrame: o = new System.Windows.Media.Animation.LinearByteKeyFrame();   break;
                case KnownElements.LinearColorKeyFrame: o = new System.Windows.Media.Animation.LinearColorKeyFrame();   break;
                case KnownElements.LinearDecimalKeyFrame: o = new System.Windows.Media.Animation.LinearDecimalKeyFrame();   break;
                case KnownElements.LinearDoubleKeyFrame: o = new System.Windows.Media.Animation.LinearDoubleKeyFrame();   break; 
                case KnownElements.LinearGradientBrush: o = new System.Windows.Media.LinearGradientBrush();   break;
                case KnownElements.LinearInt16KeyFrame: o = new System.Windows.Media.Animation.LinearInt16KeyFrame();   break; 
                case KnownElements.LinearInt32KeyFrame: o = new System.Windows.Media.Animation.LinearInt32KeyFrame();   break; 
                case KnownElements.LinearInt64KeyFrame: o = new System.Windows.Media.Animation.LinearInt64KeyFrame();   break;
                case KnownElements.LinearPoint3DKeyFrame: o = new System.Windows.Media.Animation.LinearPoint3DKeyFrame();   break; 
                case KnownElements.LinearPointKeyFrame: o = new System.Windows.Media.Animation.LinearPointKeyFrame();   break;
                case KnownElements.LinearQuaternionKeyFrame: o = new System.Windows.Media.Animation.LinearQuaternionKeyFrame();   break;
                case KnownElements.LinearRectKeyFrame: o = new System.Windows.Media.Animation.LinearRectKeyFrame();   break;
                case KnownElements.LinearRotation3DKeyFrame: o = new System.Windows.Media.Animation.LinearRotation3DKeyFrame();   break; 
                case KnownElements.LinearSingleKeyFrame: o = new System.Windows.Media.Animation.LinearSingleKeyFrame();   break;
                case KnownElements.LinearSizeKeyFrame: o = new System.Windows.Media.Animation.LinearSizeKeyFrame();   break; 
                case KnownElements.LinearThicknessKeyFrame: o = new System.Windows.Media.Animation.LinearThicknessKeyFrame();   break; 
                case KnownElements.LinearVector3DKeyFrame: o = new System.Windows.Media.Animation.LinearVector3DKeyFrame();   break;
                case KnownElements.LinearVectorKeyFrame: o = new System.Windows.Media.Animation.LinearVectorKeyFrame();   break; 
                case KnownElements.List: o = new System.Windows.Documents.List();   break;
                case KnownElements.ListBox: o = new System.Windows.Controls.ListBox();   break;
                case KnownElements.ListBoxItem: o = new System.Windows.Controls.ListBoxItem();   break;
                case KnownElements.ListItem: o = new System.Windows.Documents.ListItem();   break; 
                case KnownElements.ListView: o = new System.Windows.Controls.ListView();   break;
                case KnownElements.ListViewItem: o = new System.Windows.Controls.ListViewItem();   break; 
                case KnownElements.MaterialCollection: o = new System.Windows.Media.Media3D.MaterialCollection();   break; 
                case KnownElements.MaterialGroup: o = new System.Windows.Media.Media3D.MaterialGroup();   break;
                case KnownElements.Matrix: o = new System.Windows.Media.Matrix();   break; 
                case KnownElements.Matrix3D: o = new System.Windows.Media.Media3D.Matrix3D();   break;
                case KnownElements.Matrix3DConverter: o = new System.Windows.Media.Media3D.Matrix3DConverter();   break;
                case KnownElements.MatrixAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.MatrixAnimationUsingKeyFrames();   break;
                case KnownElements.MatrixAnimationUsingPath: o = new System.Windows.Media.Animation.MatrixAnimationUsingPath();   break; 
                case KnownElements.MatrixCamera: o = new System.Windows.Media.Media3D.MatrixCamera();   break;
                case KnownElements.MatrixConverter: o = new System.Windows.Media.MatrixConverter();   break; 
                case KnownElements.MatrixKeyFrameCollection: o = new System.Windows.Media.Animation.MatrixKeyFrameCollection();   break; 
                case KnownElements.MatrixTransform: o = new System.Windows.Media.MatrixTransform();   break;
                case KnownElements.MatrixTransform3D: o = new System.Windows.Media.Media3D.MatrixTransform3D();   break; 
                case KnownElements.MediaElement: o = new System.Windows.Controls.MediaElement();   break;
                case KnownElements.MediaPlayer: o = new System.Windows.Media.MediaPlayer();   break;
                case KnownElements.MediaTimeline: o = new System.Windows.Media.MediaTimeline();   break;
                case KnownElements.Menu: o = new System.Windows.Controls.Menu();   break; 
                case KnownElements.MenuItem: o = new System.Windows.Controls.MenuItem();   break;
                case KnownElements.MenuScrollingVisibilityConverter: o = new System.Windows.Controls.MenuScrollingVisibilityConverter();   break; 
                case KnownElements.MeshGeometry3D: o = new System.Windows.Media.Media3D.MeshGeometry3D();   break; 
                case KnownElements.Model3DCollection: o = new System.Windows.Media.Media3D.Model3DCollection();   break;
                case KnownElements.Model3DGroup: o = new System.Windows.Media.Media3D.Model3DGroup();   break; 
                case KnownElements.ModelVisual3D: o = new System.Windows.Media.Media3D.ModelVisual3D();   break;
                case KnownElements.ModifierKeysConverter: o = new System.Windows.Input.ModifierKeysConverter();   break;
                case KnownElements.MouseActionConverter: o = new System.Windows.Input.MouseActionConverter();   break;
                case KnownElements.MouseBinding: o = new System.Windows.Input.MouseBinding();   break; 
                case KnownElements.MouseGesture: o = new System.Windows.Input.MouseGesture();   break;
                case KnownElements.MouseGestureConverter: o = new System.Windows.Input.MouseGestureConverter();   break; 
                case KnownElements.MultiBinding: o = new System.Windows.Data.MultiBinding();   break; 
                case KnownElements.MultiDataTrigger: o = new System.Windows.MultiDataTrigger();   break;
                case KnownElements.MultiTrigger: o = new System.Windows.MultiTrigger();   break; 
                case KnownElements.NameScope: o = new System.Windows.NameScope();   break;
                case KnownElements.NavigationWindow: o = new System.Windows.Navigation.NavigationWindow();   break;
                case KnownElements.NullExtension: o = new System.Windows.Markup.NullExtension();   break;
                case KnownElements.NullableBoolConverter: o = new System.Windows.NullableBoolConverter();   break; 
                case KnownElements.NumberSubstitution: o = new System.Windows.Media.NumberSubstitution();   break;
                case KnownElements.Object: o = new System.Object();   break; 
                case KnownElements.ObjectAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ObjectAnimationUsingKeyFrames();   break; 
                case KnownElements.ObjectDataProvider: o = new System.Windows.Data.ObjectDataProvider();   break;
                case KnownElements.ObjectKeyFrameCollection: o = new System.Windows.Media.Animation.ObjectKeyFrameCollection();   break; 
                case KnownElements.OrthographicCamera: o = new System.Windows.Media.Media3D.OrthographicCamera();   break;
                case KnownElements.OuterGlowBitmapEffect: o = new System.Windows.Media.Effects.OuterGlowBitmapEffect();   break;
                case KnownElements.Page: o = new System.Windows.Controls.Page();   break;
                case KnownElements.PageContent: o = new System.Windows.Documents.PageContent();   break; 
                case KnownElements.Paragraph: o = new System.Windows.Documents.Paragraph();   break;
                case KnownElements.ParallelTimeline: o = new System.Windows.Media.Animation.ParallelTimeline();   break; 
                case KnownElements.ParserContext: o = new System.Windows.Markup.ParserContext();   break; 
                case KnownElements.PasswordBox: o = new System.Windows.Controls.PasswordBox();   break;
                case KnownElements.Path: o = new System.Windows.Shapes.Path();   break; 
                case KnownElements.PathFigure: o = new System.Windows.Media.PathFigure();   break;
                case KnownElements.PathFigureCollection: o = new System.Windows.Media.PathFigureCollection();   break;
                case KnownElements.PathFigureCollectionConverter: o = new System.Windows.Media.PathFigureCollectionConverter();   break;
                case KnownElements.PathGeometry: o = new System.Windows.Media.PathGeometry();   break; 
                case KnownElements.PathSegmentCollection: o = new System.Windows.Media.PathSegmentCollection();   break;
                case KnownElements.PauseStoryboard: o = new System.Windows.Media.Animation.PauseStoryboard();   break; 
                case KnownElements.Pen: o = new System.Windows.Media.Pen();   break; 
                case KnownElements.PerspectiveCamera: o = new System.Windows.Media.Media3D.PerspectiveCamera();   break;
                case KnownElements.PixelFormat: o = new System.Windows.Media.PixelFormat();   break; 
                case KnownElements.PixelFormatConverter: o = new System.Windows.Media.PixelFormatConverter();   break;
                case KnownElements.PngBitmapEncoder: o = new System.Windows.Media.Imaging.PngBitmapEncoder();   break;
                case KnownElements.Point: o = new System.Windows.Point();   break;
                case KnownElements.Point3D: o = new System.Windows.Media.Media3D.Point3D();   break; 
                case KnownElements.Point3DAnimation: o = new System.Windows.Media.Animation.Point3DAnimation();   break;
                case KnownElements.Point3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Point3DAnimationUsingKeyFrames();   break; 
                case KnownElements.Point3DCollection: o = new System.Windows.Media.Media3D.Point3DCollection();   break; 
                case KnownElements.Point3DCollectionConverter: o = new System.Windows.Media.Media3D.Point3DCollectionConverter();   break;
                case KnownElements.Point3DConverter: o = new System.Windows.Media.Media3D.Point3DConverter();   break; 
                case KnownElements.Point3DKeyFrameCollection: o = new System.Windows.Media.Animation.Point3DKeyFrameCollection();   break;
                case KnownElements.Point4D: o = new System.Windows.Media.Media3D.Point4D();   break;
                case KnownElements.Point4DConverter: o = new System.Windows.Media.Media3D.Point4DConverter();   break;
                case KnownElements.PointAnimation: o = new System.Windows.Media.Animation.PointAnimation();   break; 
                case KnownElements.PointAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.PointAnimationUsingKeyFrames();   break;
                case KnownElements.PointAnimationUsingPath: o = new System.Windows.Media.Animation.PointAnimationUsingPath();   break; 
                case KnownElements.PointCollection: o = new System.Windows.Media.PointCollection();   break; 
                case KnownElements.PointCollectionConverter: o = new System.Windows.Media.PointCollectionConverter();   break;
                case KnownElements.PointConverter: o = new System.Windows.PointConverter();   break; 
                case KnownElements.PointIListConverter: o = new System.Windows.Media.Converters.PointIListConverter();   break;
                case KnownElements.PointKeyFrameCollection: o = new System.Windows.Media.Animation.PointKeyFrameCollection();   break;
                case KnownElements.PointLight: o = new System.Windows.Media.Media3D.PointLight();   break;
                case KnownElements.PolyBezierSegment: o = new System.Windows.Media.PolyBezierSegment();   break; 
                case KnownElements.PolyLineSegment: o = new System.Windows.Media.PolyLineSegment();   break;
                case KnownElements.PolyQuadraticBezierSegment: o = new System.Windows.Media.PolyQuadraticBezierSegment();   break; 
                case KnownElements.Polygon: o = new System.Windows.Shapes.Polygon();   break; 
                case KnownElements.Polyline: o = new System.Windows.Shapes.Polyline();   break;
                case KnownElements.Popup: o = new System.Windows.Controls.Primitives.Popup();   break; 
                case KnownElements.PriorityBinding: o = new System.Windows.Data.PriorityBinding();   break;
                case KnownElements.ProgressBar: o = new System.Windows.Controls.ProgressBar();   break;
                case KnownElements.PropertyPathConverter: o = new System.Windows.PropertyPathConverter();   break;
                case KnownElements.QuadraticBezierSegment: o = new System.Windows.Media.QuadraticBezierSegment();   break; 
                case KnownElements.Quaternion: o = new System.Windows.Media.Media3D.Quaternion();   break;
                case KnownElements.QuaternionAnimation: o = new System.Windows.Media.Animation.QuaternionAnimation();   break; 
                case KnownElements.QuaternionAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.QuaternionAnimationUsingKeyFrames();   break; 
                case KnownElements.QuaternionConverter: o = new System.Windows.Media.Media3D.QuaternionConverter();   break;
                case KnownElements.QuaternionKeyFrameCollection: o = new System.Windows.Media.Animation.QuaternionKeyFrameCollection();   break; 
                case KnownElements.QuaternionRotation3D: o = new System.Windows.Media.Media3D.QuaternionRotation3D();   break;
                case KnownElements.RadialGradientBrush: o = new System.Windows.Media.RadialGradientBrush();   break;
                case KnownElements.RadioButton: o = new System.Windows.Controls.RadioButton();   break;
                case KnownElements.Rect: o = new System.Windows.Rect();   break; 
                case KnownElements.Rect3D: o = new System.Windows.Media.Media3D.Rect3D();   break;
                case KnownElements.Rect3DConverter: o = new System.Windows.Media.Media3D.Rect3DConverter();   break; 
                case KnownElements.RectAnimation: o = new System.Windows.Media.Animation.RectAnimation();   break; 
                case KnownElements.RectAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.RectAnimationUsingKeyFrames();   break;
                case KnownElements.RectConverter: o = new System.Windows.RectConverter();   break; 
                case KnownElements.RectKeyFrameCollection: o = new System.Windows.Media.Animation.RectKeyFrameCollection();   break;
                case KnownElements.Rectangle: o = new System.Windows.Shapes.Rectangle();   break;
                case KnownElements.RectangleGeometry: o = new System.Windows.Media.RectangleGeometry();   break;
                case KnownElements.RelativeSource: o = new System.Windows.Data.RelativeSource();   break; 
                case KnownElements.RemoveStoryboard: o = new System.Windows.Media.Animation.RemoveStoryboard();   break;
                case KnownElements.RepeatBehavior: o = new System.Windows.Media.Animation.RepeatBehavior();   break; 
                case KnownElements.RepeatBehaviorConverter: o = new System.Windows.Media.Animation.RepeatBehaviorConverter();   break; 
                case KnownElements.RepeatButton: o = new System.Windows.Controls.Primitives.RepeatButton();   break;
                case KnownElements.ResizeGrip: o = new System.Windows.Controls.Primitives.ResizeGrip();   break; 
                case KnownElements.ResourceDictionary: o = new System.Windows.ResourceDictionary();   break;
                case KnownElements.ResumeStoryboard: o = new System.Windows.Media.Animation.ResumeStoryboard();   break;
                case KnownElements.RichTextBox: o = new System.Windows.Controls.RichTextBox();   break;
                case KnownElements.RotateTransform: o = new System.Windows.Media.RotateTransform();   break; 
                case KnownElements.RotateTransform3D: o = new System.Windows.Media.Media3D.RotateTransform3D();   break;
                case KnownElements.Rotation3DAnimation: o = new System.Windows.Media.Animation.Rotation3DAnimation();   break; 
                case KnownElements.Rotation3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Rotation3DAnimationUsingKeyFrames();   break; 
                case KnownElements.Rotation3DKeyFrameCollection: o = new System.Windows.Media.Animation.Rotation3DKeyFrameCollection();   break;
                case KnownElements.RoutedCommand: o = new System.Windows.Input.RoutedCommand();   break; 
                case KnownElements.RoutedEventConverter: o = new System.Windows.Markup.RoutedEventConverter();   break;
                case KnownElements.RoutedUICommand: o = new System.Windows.Input.RoutedUICommand();   break;
                case KnownElements.RowDefinition: o = new System.Windows.Controls.RowDefinition();   break;
                case KnownElements.Run: o = new System.Windows.Documents.Run();   break; 
                case KnownElements.SByteConverter: o = new System.ComponentModel.SByteConverter();   break;
                case KnownElements.ScaleTransform: o = new System.Windows.Media.ScaleTransform();   break; 
                case KnownElements.ScaleTransform3D: o = new System.Windows.Media.Media3D.ScaleTransform3D();   break; 
                case KnownElements.ScrollBar: o = new System.Windows.Controls.Primitives.ScrollBar();   break;
                case KnownElements.ScrollContentPresenter: o = new System.Windows.Controls.ScrollContentPresenter();   break; 
                case KnownElements.ScrollViewer: o = new System.Windows.Controls.ScrollViewer();   break;
                case KnownElements.Section: o = new System.Windows.Documents.Section();   break;
                case KnownElements.SeekStoryboard: o = new System.Windows.Media.Animation.SeekStoryboard();   break;
                case KnownElements.Separator: o = new System.Windows.Controls.Separator();   break; 
                case KnownElements.SetStoryboardSpeedRatio: o = new System.Windows.Media.Animation.SetStoryboardSpeedRatio();   break;
                case KnownElements.Setter: o = new System.Windows.Setter();   break; 
                case KnownElements.SingleAnimation: o = new System.Windows.Media.Animation.SingleAnimation();   break; 
                case KnownElements.SingleAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.SingleAnimationUsingKeyFrames();   break;
                case KnownElements.SingleConverter: o = new System.ComponentModel.SingleConverter();   break; 
                case KnownElements.SingleKeyFrameCollection: o = new System.Windows.Media.Animation.SingleKeyFrameCollection();   break;
                case KnownElements.Size: o = new System.Windows.Size();   break;
                case KnownElements.Size3D: o = new System.Windows.Media.Media3D.Size3D();   break;
                case KnownElements.Size3DConverter: o = new System.Windows.Media.Media3D.Size3DConverter();   break; 
                case KnownElements.SizeAnimation: o = new System.Windows.Media.Animation.SizeAnimation();   break;
                case KnownElements.SizeAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.SizeAnimationUsingKeyFrames();   break; 
                case KnownElements.SizeConverter: o = new System.Windows.SizeConverter();   break; 
                case KnownElements.SizeKeyFrameCollection: o = new System.Windows.Media.Animation.SizeKeyFrameCollection();   break;
                case KnownElements.SkewTransform: o = new System.Windows.Media.SkewTransform();   break; 
                case KnownElements.SkipStoryboardToFill: o = new System.Windows.Media.Animation.SkipStoryboardToFill();   break;
                case KnownElements.Slider: o = new System.Windows.Controls.Slider();   break;
                case KnownElements.SolidColorBrush: o = new System.Windows.Media.SolidColorBrush();   break;
                case KnownElements.SoundPlayerAction: o = new System.Windows.Controls.SoundPlayerAction();   break; 
                case KnownElements.Span: o = new System.Windows.Documents.Span();   break;
                case KnownElements.SpecularMaterial: o = new System.Windows.Media.Media3D.SpecularMaterial();   break; 
                case KnownElements.SplineByteKeyFrame: o = new System.Windows.Media.Animation.SplineByteKeyFrame();   break; 
                case KnownElements.SplineColorKeyFrame: o = new System.Windows.Media.Animation.SplineColorKeyFrame();   break;
                case KnownElements.SplineDecimalKeyFrame: o = new System.Windows.Media.Animation.SplineDecimalKeyFrame();   break; 
                case KnownElements.SplineDoubleKeyFrame: o = new System.Windows.Media.Animation.SplineDoubleKeyFrame();   break;
                case KnownElements.SplineInt16KeyFrame: o = new System.Windows.Media.Animation.SplineInt16KeyFrame();   break;
                case KnownElements.SplineInt32KeyFrame: o = new System.Windows.Media.Animation.SplineInt32KeyFrame();   break;
                case KnownElements.SplineInt64KeyFrame: o = new System.Windows.Media.Animation.SplineInt64KeyFrame();   break; 
                case KnownElements.SplinePoint3DKeyFrame: o = new System.Windows.Media.Animation.SplinePoint3DKeyFrame();   break;
                case KnownElements.SplinePointKeyFrame: o = new System.Windows.Media.Animation.SplinePointKeyFrame();   break; 
                case KnownElements.SplineQuaternionKeyFrame: o = new System.Windows.Media.Animation.SplineQuaternionKeyFrame();   break; 
                case KnownElements.SplineRectKeyFrame: o = new System.Windows.Media.Animation.SplineRectKeyFrame();   break;
                case KnownElements.SplineRotation3DKeyFrame: o = new System.Windows.Media.Animation.SplineRotation3DKeyFrame();   break; 
                case KnownElements.SplineSingleKeyFrame: o = new System.Windows.Media.Animation.SplineSingleKeyFrame();   break;
                case KnownElements.SplineSizeKeyFrame: o = new System.Windows.Media.Animation.SplineSizeKeyFrame();   break;
                case KnownElements.SplineThicknessKeyFrame: o = new System.Windows.Media.Animation.SplineThicknessKeyFrame();   break;
                case KnownElements.SplineVector3DKeyFrame: o = new System.Windows.Media.Animation.SplineVector3DKeyFrame();   break; 
                case KnownElements.SplineVectorKeyFrame: o = new System.Windows.Media.Animation.SplineVectorKeyFrame();   break;
                case KnownElements.SpotLight: o = new System.Windows.Media.Media3D.SpotLight();   break; 
                case KnownElements.StackPanel: o = new System.Windows.Controls.StackPanel();   break; 
                case KnownElements.StaticExtension: o = new System.Windows.Markup.StaticExtension();   break;
                case KnownElements.StaticResourceExtension: o = new System.Windows.StaticResourceExtension();   break; 
                case KnownElements.StatusBar: o = new System.Windows.Controls.Primitives.StatusBar();   break;
                case KnownElements.StatusBarItem: o = new System.Windows.Controls.Primitives.StatusBarItem();   break;
                case KnownElements.StopStoryboard: o = new System.Windows.Media.Animation.StopStoryboard();   break;
                case KnownElements.Storyboard: o = new System.Windows.Media.Animation.Storyboard();   break; 
                case KnownElements.StreamGeometry: o = new System.Windows.Media.StreamGeometry();   break;
                case KnownElements.StreamResourceInfo: o = new System.Windows.Resources.StreamResourceInfo();   break; 
                case KnownElements.StringAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.StringAnimationUsingKeyFrames();   break; 
                case KnownElements.StringConverter: o = new System.ComponentModel.StringConverter();   break;
                case KnownElements.StringKeyFrameCollection: o = new System.Windows.Media.Animation.StringKeyFrameCollection();   break; 
                case KnownElements.StrokeCollection: o = new System.Windows.Ink.StrokeCollection();   break;
                case KnownElements.StrokeCollectionConverter: o = new System.Windows.StrokeCollectionConverter();   break;
                case KnownElements.Style: o = new System.Windows.Style();   break;
                case KnownElements.TabControl: o = new System.Windows.Controls.TabControl();   break; 
                case KnownElements.TabItem: o = new System.Windows.Controls.TabItem();   break;
                case KnownElements.TabPanel: o = new System.Windows.Controls.Primitives.TabPanel();   break; 
                case KnownElements.Table: o = new System.Windows.Documents.Table();   break; 
                case KnownElements.TableCell: o = new System.Windows.Documents.TableCell();   break;
                case KnownElements.TableColumn: o = new System.Windows.Documents.TableColumn();   break; 
                case KnownElements.TableRow: o = new System.Windows.Documents.TableRow();   break;
                case KnownElements.TableRowGroup: o = new System.Windows.Documents.TableRowGroup();   break;
                case KnownElements.TemplateBindingExpressionConverter: o = new System.Windows.TemplateBindingExpressionConverter();   break;
                case KnownElements.TemplateBindingExtension: o = new System.Windows.TemplateBindingExtension();   break; 
                case KnownElements.TemplateBindingExtensionConverter: o = new System.Windows.TemplateBindingExtensionConverter();   break;
                case KnownElements.TemplateKeyConverter: o = new System.Windows.Markup.TemplateKeyConverter();   break; 
                case KnownElements.TextBlock: o = new System.Windows.Controls.TextBlock();   break; 
                case KnownElements.TextBox: o = new System.Windows.Controls.TextBox();   break;
                case KnownElements.TextDecoration: o = new System.Windows.TextDecoration();   break; 
                case KnownElements.TextDecorationCollection: o = new System.Windows.TextDecorationCollection();   break;
                case KnownElements.TextDecorationCollectionConverter: o = new System.Windows.TextDecorationCollectionConverter();   break;
                case KnownElements.TextEffect: o = new System.Windows.Media.TextEffect();   break;
                case KnownElements.TextEffectCollection: o = new System.Windows.Media.TextEffectCollection();   break; 
                case KnownElements.ThemeDictionaryExtension: o = new System.Windows.ThemeDictionaryExtension();   break;
                case KnownElements.Thickness: o = new System.Windows.Thickness();   break; 
                case KnownElements.ThicknessAnimation: o = new System.Windows.Media.Animation.ThicknessAnimation();   break; 
                case KnownElements.ThicknessAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.ThicknessAnimationUsingKeyFrames();   break;
                case KnownElements.ThicknessConverter: o = new System.Windows.ThicknessConverter();   break; 
                case KnownElements.ThicknessKeyFrameCollection: o = new System.Windows.Media.Animation.ThicknessKeyFrameCollection();   break;
                case KnownElements.Thumb: o = new System.Windows.Controls.Primitives.Thumb();   break;
                case KnownElements.TickBar: o = new System.Windows.Controls.Primitives.TickBar();   break;
                case KnownElements.TiffBitmapEncoder: o = new System.Windows.Media.Imaging.TiffBitmapEncoder();   break; 
                case KnownElements.TimeSpanConverter: o = new System.ComponentModel.TimeSpanConverter();   break;
                case KnownElements.TimelineCollection: o = new System.Windows.Media.Animation.TimelineCollection();   break; 
                case KnownElements.ToggleButton: o = new System.Windows.Controls.Primitives.ToggleButton();   break; 
                case KnownElements.ToolBar: o = new System.Windows.Controls.ToolBar();   break;
                case KnownElements.ToolBarOverflowPanel: o = new System.Windows.Controls.Primitives.ToolBarOverflowPanel();   break; 
                case KnownElements.ToolBarPanel: o = new System.Windows.Controls.Primitives.ToolBarPanel();   break;
                case KnownElements.ToolBarTray: o = new System.Windows.Controls.ToolBarTray();   break;
                case KnownElements.ToolTip: o = new System.Windows.Controls.ToolTip();   break;
                case KnownElements.Track: o = new System.Windows.Controls.Primitives.Track();   break; 
                case KnownElements.Transform3DCollection: o = new System.Windows.Media.Media3D.Transform3DCollection();   break;
                case KnownElements.Transform3DGroup: o = new System.Windows.Media.Media3D.Transform3DGroup();   break; 
                case KnownElements.TransformCollection: o = new System.Windows.Media.TransformCollection();   break; 
                case KnownElements.TransformConverter: o = new System.Windows.Media.TransformConverter();   break;
                case KnownElements.TransformGroup: o = new System.Windows.Media.TransformGroup();   break; 
                case KnownElements.TransformedBitmap: o = new System.Windows.Media.Imaging.TransformedBitmap();   break;
                case KnownElements.TranslateTransform: o = new System.Windows.Media.TranslateTransform();   break;
                case KnownElements.TranslateTransform3D: o = new System.Windows.Media.Media3D.TranslateTransform3D();   break;
                case KnownElements.TreeView: o = new System.Windows.Controls.TreeView();   break; 
                case KnownElements.TreeViewItem: o = new System.Windows.Controls.TreeViewItem();   break;
                case KnownElements.Trigger: o = new System.Windows.Trigger();   break; 
                case KnownElements.TypeExtension: o = new System.Windows.Markup.TypeExtension();   break; 
                case KnownElements.TypeTypeConverter: o = new System.Windows.Markup.TypeTypeConverter();   break;
                case KnownElements.UIElement: o = new System.Windows.UIElement();   break; 
                case KnownElements.UInt16Converter: o = new System.ComponentModel.UInt16Converter();   break;
                case KnownElements.UInt32Converter: o = new System.ComponentModel.UInt32Converter();   break;
                case KnownElements.UInt64Converter: o = new System.ComponentModel.UInt64Converter();   break;
                case KnownElements.UShortIListConverter: o = new System.Windows.Media.Converters.UShortIListConverter();   break; 
                case KnownElements.Underline: o = new System.Windows.Documents.Underline();   break;
                case KnownElements.UniformGrid: o = new System.Windows.Controls.Primitives.UniformGrid();   break; 
                case KnownElements.UriTypeConverter: o = new System.UriTypeConverter();   break; 
                case KnownElements.UserControl: o = new System.Windows.Controls.UserControl();   break;
                case KnownElements.Vector: o = new System.Windows.Vector();   break; 
                case KnownElements.Vector3D: o = new System.Windows.Media.Media3D.Vector3D();   break;
                case KnownElements.Vector3DAnimation: o = new System.Windows.Media.Animation.Vector3DAnimation();   break;
                case KnownElements.Vector3DAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.Vector3DAnimationUsingKeyFrames();   break;
                case KnownElements.Vector3DCollection: o = new System.Windows.Media.Media3D.Vector3DCollection();   break; 
                case KnownElements.Vector3DCollectionConverter: o = new System.Windows.Media.Media3D.Vector3DCollectionConverter();   break;
                case KnownElements.Vector3DConverter: o = new System.Windows.Media.Media3D.Vector3DConverter();   break; 
                case KnownElements.Vector3DKeyFrameCollection: o = new System.Windows.Media.Animation.Vector3DKeyFrameCollection();   break; 
                case KnownElements.VectorAnimation: o = new System.Windows.Media.Animation.VectorAnimation();   break;
                case KnownElements.VectorAnimationUsingKeyFrames: o = new System.Windows.Media.Animation.VectorAnimationUsingKeyFrames();   break; 
                case KnownElements.VectorCollection: o = new System.Windows.Media.VectorCollection();   break;
                case KnownElements.VectorCollectionConverter: o = new System.Windows.Media.VectorCollectionConverter();   break;
                case KnownElements.VectorConverter: o = new System.Windows.VectorConverter();   break;
                case KnownElements.VectorKeyFrameCollection: o = new System.Windows.Media.Animation.VectorKeyFrameCollection();   break; 
                case KnownElements.VideoDrawing: o = new System.Windows.Media.VideoDrawing();   break;
                case KnownElements.Viewbox: o = new System.Windows.Controls.Viewbox();   break; 
                case KnownElements.Viewport3D: o = new System.Windows.Controls.Viewport3D();   break; 
                case KnownElements.Viewport3DVisual: o = new System.Windows.Media.Media3D.Viewport3DVisual();   break;
                case KnownElements.VirtualizingStackPanel: o = new System.Windows.Controls.VirtualizingStackPanel();   break; 
                case KnownElements.VisualBrush: o = new System.Windows.Media.VisualBrush();   break;
                case KnownElements.Window: o = new System.Windows.Window();   break;
                case KnownElements.WmpBitmapEncoder: o = new System.Windows.Media.Imaging.WmpBitmapEncoder();   break;
                case KnownElements.WrapPanel: o = new System.Windows.Controls.WrapPanel();   break; 
                case KnownElements.XamlBrushSerializer: o = new System.Windows.Markup.XamlBrushSerializer();   break;
                case KnownElements.XamlInt32CollectionSerializer: o = new System.Windows.Markup.XamlInt32CollectionSerializer();   break; 
                case KnownElements.XamlPathDataSerializer: o = new System.Windows.Markup.XamlPathDataSerializer();   break; 
                case KnownElements.XamlPoint3DCollectionSerializer: o = new System.Windows.Markup.XamlPoint3DCollectionSerializer();   break;
                case KnownElements.XamlPointCollectionSerializer: o = new System.Windows.Markup.XamlPointCollectionSerializer();   break; 
                case KnownElements.XamlStyleSerializer: o = new System.Windows.Markup.XamlStyleSerializer();   break;
                case KnownElements.XamlTemplateSerializer: o = new System.Windows.Markup.XamlTemplateSerializer();   break;
                case KnownElements.XamlVector3DCollectionSerializer: o = new System.Windows.Markup.XamlVector3DCollectionSerializer();   break;
                case KnownElements.XmlDataProvider: o = new System.Windows.Data.XmlDataProvider();   break; 
                case KnownElements.XmlLanguageConverter: o = new System.Windows.Markup.XmlLanguageConverter();   break;
                case KnownElements.XmlNamespaceMapping: o = new System.Windows.Data.XmlNamespaceMapping();   break; 
                case KnownElements.ZoomPercentageConverter: o = new System.Windows.Documents.ZoomPercentageConverter();   break; 
            }
            return o; 
        }
Beispiel #2
0
        private ImageSource GetItem(int index)
        {
            if (index < 0 || index >= Count)
            {
                throw new IndexOutOfRangeException();
            }

            if (m_Cache.ContainsKey(index))
            {
                return(m_Cache[index]);
            }

            int startPoint = IconWidth * index;
            var Frame      = new System.Windows.Int32Rect(startPoint, 0, IconWidth, IconHeight);

            byte[] bits = new byte[m_CompleteImage.PixelHeight * stride];
            m_CompleteImage.CopyPixels(Frame, bits, stride, 0);

            WriteableBitmap target = new WriteableBitmap(
                IconWidth,
                IconHeight,
                m_CompleteImage.DpiX, m_CompleteImage.DpiY,
                m_CompleteImage.Format, null);

            // Write the pixel data to the WriteableBitmap.
            target.WritePixels(
                new System.Windows.Int32Rect(0, 0, IconWidth, IconHeight),
                bits, stride, 0);

            target.Freeze();
            m_Cache.Add(index, target);

            return(target);
        }
        private static WriteableBitmap GetBGImgGray8(BitmapImage baseImage)
        {
            if (baseImage.Format != System.Windows.Media.PixelFormats.Gray8)
            {
                return(null);
            }
            int mapheight = baseImage.PixelHeight;
            int mapwidth  = baseImage.PixelWidth;

            WriteableBitmap re = new WriteableBitmap(mapwidth, mapheight, baseImage.DpiX, baseImage.DpiY, System.Windows.Media.PixelFormats.Rgb24, null);

            byte[] buffer = new byte[mapwidth * 3];
            //复制图像
            for (int h = 0; h < mapheight; h++)
            {
                System.Windows.Int32Rect rect = new System.Windows.Int32Rect(0, h, mapwidth, 1);
                baseImage.CopyPixels(rect, buffer, mapwidth, 0);
                for (int w = mapwidth - 1; w >= 0; w--)
                {
                    buffer[w * 3] = buffer[w * 3 + 1] = buffer[w * 3 + 2] = buffer[w];
                }
                re.WritePixels(rect, buffer, mapwidth * 3, 0);
            }

            return(re);
        }
        private static WriteableBitmap GetBGImgIndex8(BitmapImage baseImage)
        {
            if (baseImage.Format != System.Windows.Media.PixelFormats.Indexed8)
            {
                return(null);
            }
            int mapheight = baseImage.PixelHeight;
            int mapwidth  = baseImage.PixelWidth;

            WriteableBitmap re     = new WriteableBitmap(mapwidth, mapheight, baseImage.DpiX, baseImage.DpiY, System.Windows.Media.PixelFormats.Bgr24, null);
            var             colors = baseImage.Palette.Colors;

            byte[] buffer = new byte[mapwidth * 3];
            //复制图像
            for (int h = 0; h < mapheight; h++)
            {
                System.Windows.Int32Rect rect = new System.Windows.Int32Rect(0, h, mapwidth, 1);
                baseImage.CopyPixels(rect, buffer, mapwidth, 0);
                for (int w = mapwidth - 1; w >= 0; w--)
                {
                    byte index = buffer[w];
                    buffer[w * 3]     = colors[index].B;
                    buffer[w * 3 + 1] = colors[index].G;
                    buffer[w * 3 + 2] = colors[index].R;
                }
                re.WritePixels(rect, buffer, mapwidth * 3, 0);
            }

            return(re);
        }
Beispiel #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            CroppedBitmap bitmap = null;

            if (value is SpriteWrapper spriteWrapper)
            {
                var path = spriteWrapper.GetPath();
                if (!string.IsNullOrWhiteSpace(path))
                {
                    var source = new BitmapImage();
                    source.BeginInit();
                    source.UriSource   = new Uri(path, UriKind.Absolute);
                    source.CacheOption = BitmapCacheOption.OnLoad;
                    source.EndInit();

                    var x      = Math.Min(source.PixelWidth, spriteWrapper.Location.X);
                    var y      = Math.Min(source.PixelHeight, spriteWrapper.Location.Y);
                    var width  = Math.Min(source.PixelWidth - x, spriteWrapper.Size.X);
                    var height = Math.Min(source.PixelHeight - y, spriteWrapper.Size.Y);

                    var rect = new System.Windows.Int32Rect(x, y, width, height);
                    bitmap = new CroppedBitmap(source, rect);
                }
            }

            return(bitmap);
        }
    public static WriteableBitmap CreateLivePlayerRenderer(this Runtime runtime, int depthWidth, int depthHeight)
    {
        PlanarImage     depthImage = new PlanarImage();
        WriteableBitmap target     = new WriteableBitmap(depthWidth, depthHeight, 96, 96, PixelFormats.Bgra32, null);
        var             depthRect  = new System.Windows.Int32Rect(0, 0, depthWidth, depthHeight);


        runtime.DepthFrameReady += (s, e) =>
        {
            depthImage = e.ImageFrame.Image;
            Debug.Assert(depthImage.Height == depthHeight && depthImage.Width == depthWidth);
        };

        runtime.VideoFrameReady += (s, e) =>
        {
            // don't do anything if we don't yet have a depth image
            if (depthImage.Bits == null)
            {
                return;
            }

            byte[] color = e.ImageFrame.Image.Bits;

            byte[] output = new byte[depthWidth * depthHeight * 4];

            // loop over each pixel in the depth image
            int outputIndex = 0;
            for (int depthY = 0, depthIndex = 0; depthY < depthHeight; depthY++)
            {
                for (int depthX = 0; depthX < depthWidth; depthX++, depthIndex += 2)
                {
                    // combine the 2 bytes of depth data representing this pixel
                    short depthValue = (short)(depthImage.Bits[depthIndex] | (depthImage.Bits[depthIndex + 1] << 8));

                    // extract the id of a tracked player from the first bit of depth data for this pixel
                    int player = depthImage.Bits[depthIndex] & 7;

                    // find a pixel in the color image which matches this coordinate from the depth image
                    int colorX, colorY;
                    runtime.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(
                        e.ImageFrame.Resolution,
                        e.ImageFrame.ViewArea,
                        depthX, depthY,          // depth coordinate
                        depthValue,              // depth value
                        out colorX, out colorY); // color coordinate

                    // ensure that the calculated color location is within the bounds of the image
                    colorX = Math.Max(0, Math.Min(colorX, e.ImageFrame.Image.Width - 1));
                    colorY = Math.Max(0, Math.Min(colorY, e.ImageFrame.Image.Height - 1));

                    output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 0];
                    output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 1];
                    output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 2];
                    output[outputIndex++] = player > 0 ? (byte)255 : (byte)0;
                }
            }
            target.WritePixels(depthRect, output, depthWidth * PixelFormats.Bgra32.BitsPerPixel / 8, 0);
        };
        return(target);
    }
Beispiel #7
0
        private WriteableBitmap ByteArrayToBitmap()
        {
            var dest = new WriteableBitmap(Width, Height, 96.0, 96.0, Format, null);
            var rect = new System.Windows.Int32Rect(0, 0, Width, Height);

            dest.WritePixels(rect, RawData, ImageSize, Width * BytePerPixel);
            dest.Freeze();
            return(dest);
        }
        public static double CalculateAverageLuma(this WriteableBitmap bitmapSource, System.Windows.Int32Rect srcRect)
        {
            if (srcRect.X < 0 || srcRect.Y < 0 || srcRect.X + srcRect.Width >= bitmapSource.Width || srcRect.Y + srcRect.Height >= bitmapSource.Height)
            {
                return(0);
            }

            byte[] pixelArray = bitmapSource.ToArray(srcRect);
            return(CalculateAverageLuma(pixelArray, bitmapSource.Format.BitsPerPixel / 8));
        }
Beispiel #9
0
        internal static void CaptureWindow(IntPtr hwnd, System.Drawing.Bitmap img, System.Windows.Int32Rect clippingRect)
        {
            System.Diagnostics.Debug.Assert(img != null);
            using (var memg = System.Drawing.Graphics.FromImage(img))
            {
                memg.Clear(System.Drawing.Color.Transparent);
                IntPtr memDC = memg.GetHdc();
#if false
                // PrintWindow() は Windows XP で追加された API だが、
                // これはどうも各ウィンドウに再描画要求メッセージを送るらしく、
                // 短い時間間隔で呼び出すと Windows Calculator(電卓、calc.exe)などはちらつく。
                // Aero Glass が無効になった状態のウィンドウのスクリーンショットを撮れるので、
                // ヘルプ作成などの非リアルタイム用途であれば適している API かも。
                // たぶん Aero Auto Color も同様。
                // 最小化した状態ではタイトル バーのみがレンダリングされる。
                // http://d.hatena.ne.jp/madotate/
                User32DllMethodsInvoker.PrintWindow(hwnd, memDC, 0);
#else
                // BitBlt() を使ってウィンドウのデバイス コンテキスト経由で描画内容を DIB ビットマップに転送する。
                // 最小化した状態では PrintWindow() 同様、タイトル バーのみがレンダリングされる。
                // こちらは DWM API 同様、それなりに高速なのでリアルタイム用途に適している。
                // ただし Aero Glass の Window Chrome 領域(タイトル バー含む)がゴミデータになるときがある模様?
                // そのため、クライアント領域のみ(ただしメニューバーは含まれない)をキャプチャする。
                // DirectShow などのビデオ オーバーレイを使っているアプリでどうなるのかは試してみないと分からない。
                // キャプチャ自体は常にクライアント左上を基点、デスクトップ サイズを限界として、
                // 利用側で配置する際にそれらの情報を考慮するようにする。
                IntPtr winDC = User32DllMethodsInvoker.GetWindowDC(hwnd);
#if true
                var intersectRect = MyWin32InteropHelper.CalcClientIntersectRect(hwnd, clippingRect);
#if false
                // 切り出し元の相対位置を使う場合。
                int dstX = intersectRect.X;
                int dstY = intersectRect.Y;
#else
                // 切り出した領域を常に左上に配置する場合。
                const int dstX = 0;
                const int dstY = 0;
#endif
                // ウィンドウ クライアント領域の内容をさらにユーザー定義クリッピング矩形で切り出したものを、ビットマップに転送する。
                Gdi32DllMethodsInvoker.BitBlt(
                    memDC, dstX, dstY, intersectRect.Width, intersectRect.Height,
                    winDC, intersectRect.X, intersectRect.Y,
                    Gdi32DllMethodsInvoker.TernaryRasterOperationType.SRCCOPY);
#else
                var winRect = MyWin32InteropHelper.GetWindowRect(hwnd);
                Gdi32DllMethodsInvoker.BitBlt(
                    memDC, 0, 0, winRect.Width, winRect.Height,
                    winDC, 0, 0,
                    Gdi32DllMethodsInvoker.TernaryRasterOperationType.SRCCOPY);
#endif
#endif
                User32DllMethodsInvoker.ReleaseDC(hwnd, winDC);
                memg.ReleaseHdc(memDC);
            }
        }
        public static WriteableBitmap CreateLivePlayerRenderer(this Runtime runtime, int depthWidth, int depthHeight)
        {
            PlanarImage depthImage = new PlanarImage();
            WriteableBitmap target = new WriteableBitmap(depthWidth, depthHeight, 96, 96, PixelFormats.Bgra32, null);
            var depthRect = new System.Windows.Int32Rect(0, 0, depthWidth, depthHeight);

            runtime.DepthFrameReady += (s, e) =>
            {
                depthImage = e.ImageFrame.Image;
                Debug.Assert(depthImage.Height == depthHeight && depthImage.Width == depthWidth);
            };
            runtime.VideoFrameReady += (s, e) =>
            {
                // don't do anything if we don't yet have a depth image
                if (depthImage.Bits == null)
                    return;

                byte[] color = e.ImageFrame.Image.Bits;
                byte[] output = new byte[depthWidth * depthHeight * 4];

                // loop over each pixel in the depth image
                int outputIndex = 0;
                for (int depthY = 0, depthIndex = 0; depthY < depthHeight; depthY++)
                {
                    for (int depthX = 0; depthX < depthWidth; depthX++, depthIndex += 2)
                    {
                        // combine the 2 bytes of depth data representing this pixel
                        short depthValue = (short)(depthImage.Bits[depthIndex] | (depthImage.Bits[depthIndex + 1] << 8));

                        // extract the id of a tracked player from the first bit of depth data for this pixel
                        int player = depthImage.Bits[depthIndex] & 7;

                        // find a pixel in the color image which matches this coordinate from the depth image
                        int colorX, colorY;
                        runtime.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(
                                                    e.ImageFrame.Resolution,
                                                    e.ImageFrame.ViewArea,
                                                    depthX, depthY, // depth coordinate
                                                    depthValue,  // depth value
                                                    out colorX, out colorY);  // color coordinate

                        // ensure that the calculated color location is within the bounds of the image
                        colorX = Math.Max(0, Math.Min(colorX, e.ImageFrame.Image.Width - 1));
                        colorY = Math.Max(0, Math.Min(colorY, e.ImageFrame.Image.Height - 1));
                        output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 0];
                        output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 1];
                        output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 2];
                        output[outputIndex++] = player > 0 ? (byte)255 : (byte)0;
                    }
                }
                target.WritePixels(depthRect, output, depthWidth * PixelFormats.Bgra32.BitsPerPixel / 8, 0);
            };
            return target;
        }
 /// <summary>
 /// UI specific implementation extension method GetBoundingClientRect()
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 public static System.Windows.Int32Rect GetBoundingClientRectInt32( this GeckoElement element )
 {
     nsIDOMClientRect domRect = element.DOMElement.GetBoundingClientRect();
     if ( domRect == null ) return System.Windows.Int32Rect.Empty;
     var r = new System.Windows.Int32Rect(
         ( int ) domRect.GetLeftAttribute(),
         ( int ) domRect.GetTopAttribute(),
         ( int ) domRect.GetWidthAttribute(),
         ( int ) domRect.GetHeightAttribute() );
     return r;
 }
Beispiel #12
0
        private BitmapSource ConvertGdiToWPF(System.Drawing.Bitmap bm, System.Windows.Int32Rect rect)
        {
            BitmapSource bms = null;

            if (bm != null)
            {
                IntPtr h_bm = bm.GetHbitmap();
                bms = Imaging.CreateBitmapSourceFromHBitmap(h_bm, IntPtr.Zero, rect, BitmapSizeOptions.FromEmptyOptions());
            }

            return(bms);
        }
Beispiel #13
0
        public bool CaptureWindow(IntPtr hwnd, System.Windows.Int32Rect clippingRect)
        {
            System.Diagnostics.Debug.Assert(this.wicBitmap != null && this.gdipBitmap != null);
            if (!User32DllMethodsInvoker.IsWindow(hwnd))
            {
                return(false);
            }

            MyWpfGdiPlusInteropHelper.CaptureWindow(hwnd, this.gdipBitmap, clippingRect);

            return(MyWpfGdiPlusInteropHelper.CopyGdipBitmapToWicBitmap(this.gdipBitmap, this.wicBitmap));
        }
    public static WriteableBitmap CreateLivePlayerRenderer(this KinectSensor sensor, int depthWidth, int depthHeight)
    {
        AllFramesReadyEventArgs d = new AllFramesReadyEventArgs();

        using (DepthImageFrame depthImage = d.OpenDepthImageFrame())
        {
            WriteableBitmap target    = new WriteableBitmap(depthWidth, depthHeight, 96, 96, PixelFormats.Bgra32, null);
            var             depthRect = new System.Windows.Int32Rect(0, 0, depthWidth, depthHeight);
            sensor.DepthFrameReady += (s, e) =>
            {
                Debug.Assert(depthImage.Height == depthHeight && depthImage.Width == depthWidth);
            };
            sensor.ColorFrameReady += (s, e) =>
            {
                // don't do anything if we don't yet have a depth image
                DepthImageFrame colorImage = depthImage;
                if (colorImage.BytesPerPixel == null)
                {
                    return;
                }
                byte[] color = new byte[sensor.ColorStream.FramePixelDataLength];
                e.OpenColorImageFrame().CopyPixelDataTo(color);
                byte[] output = new byte[depthWidth * depthHeight * 4];
                // loop over each pixel in the depth image
                int outputIndex = 0;
                for (int depthY = 0, depthIndex = 0; depthY < depthHeight; depthY++)
                {
                    for (int depthX = 0; depthX < depthWidth; depthX++, depthIndex += 2)
                    {
                        short[] bits = new short[colorImage.BytesPerPixel];
                        depthImage.CopyPixelDataTo(bits);
                        // combine the 2 bytes of depth data representing this pixel
                        short depthValue = (short)(bits[depthIndex] | (bits[depthIndex + 1] << 8));
                        // extract the id of a tracked player from the first bit of depth data for this pixel
                        int player = bits[depthIndex] & 7;
                        // find a pixel in the color image which matches this coordinate from the depth image
                        int             colorX, colorY;
                        ColorImagePoint colorPoint = depthImage.MapToColorImagePoint(depthImage.Width, depthImage.Height, sensor.ColorStream.Format);
                        // ensure that the calculated color location is within the bounds of the image
                        colorX = colorPoint.X;
                        colorY = colorPoint.Y;
                        output[outputIndex++] = color[(4 * (colorX + (colorY * e.OpenColorImageFrame().Width))) + 0];
                        output[outputIndex++] = color[(4 * (colorX + (colorY * e.OpenColorImageFrame().Width))) + 1];
                        output[outputIndex++] = color[(4 * (colorX + (colorY * e.OpenColorImageFrame().Width))) + 2];
                        output[outputIndex++] = player > 0 ? (byte)255 : (byte)0;
                    }
                }
                target.WritePixels(depthRect, output, depthWidth * PixelFormats.Bgra32.BitsPerPixel / 8, 0);
            };
            return(target);
        }
    }
Beispiel #15
0
        public static void SetPixels(WIC_WRITABLE dstBmp, int dstX, int dstY, PointerBitmap srcPtr)
        {
            if (dstX < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(dstX));
            }
            if (dstY < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(dstY));
            }
            if (dstX + srcPtr.Width > dstBmp.PixelWidth)
            {
                throw new ArgumentOutOfRangeException(nameof(srcPtr.Width));
            }
            if (dstY + srcPtr.Height > dstBmp.PixelHeight)
            {
                throw new ArgumentOutOfRangeException(nameof(srcPtr.Height));
            }

            if (!TryGetExactPixelFormat(dstBmp.Format, out var dstFmt))
            {
                throw new Diagnostics.PixelFormatNotSupportedException(dstBmp.Format, nameof(dstBmp));
            }

            if (srcPtr.PixelFormat == dstFmt)
            {
                var rect = new System.Windows.Int32Rect(dstX, dstY, dstBmp.PixelWidth, dstBmp.PixelHeight);

                dstBmp.WritePixels(rect, srcPtr.Pointer, srcPtr.Info.BitmapByteSize, srcPtr.Info.StepByteSize);
                return;
            }

            try
            {
                dstBmp.Lock();

                var nfo    = new BitmapInfo(dstBmp.PixelWidth, dstBmp.PixelHeight, dstFmt, dstBmp.BackBufferStride);
                var dstPtr = new PointerBitmap(dstBmp.BackBuffer, nfo);

                dstPtr.AsSpanBitmap().SetPixels(0, 0, srcPtr.AsSpanBitmap());

                var w     = Math.Min(dstBmp.PixelWidth, srcPtr.Width);
                var h     = Math.Min(dstBmp.PixelHeight, srcPtr.Height);
                var drect = new System.Windows.Int32Rect(0, 0, w, h);

                dstBmp.AddDirtyRect(drect);
            }
            finally
            {
                dstBmp.Unlock();
            }
        }
Beispiel #16
0
        public void SetPixel(int x, int y, Color c)
        {
            bgraValues[x * 4 + y * data.Stride]     = c.B;
            bgraValues[x * 4 + y * data.Stride + 1] = c.G;
            bgraValues[x * 4 + y * data.Stride + 2] = c.R;
            bgraValues[x * 4 + y * data.Stride + 3] = c.A;

            byte[] ColorData = { c.B, c.G, c.R, c.A }; // B G R A

            System.Windows.Int32Rect rect = new System.Windows.Int32Rect(x, y, 1, 1);

            writeableBitmap.WritePixels(rect, ColorData, 4, 0);
        }
        /// <summary>
        /// UI specific implementation extension method GetBoundingClientRect()
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static System.Windows.Int32Rect GetBoundingClientRectInt32(this GeckoElement element)
        {
            nsIDOMClientRect domRect = element.DOMElement.GetBoundingClientRect();

            if (domRect == null)
            {
                return(System.Windows.Int32Rect.Empty);
            }
            var r = new System.Windows.Int32Rect(
                ( int )domRect.GetLeftAttribute(),
                ( int )domRect.GetTopAttribute(),
                ( int )domRect.GetWidthAttribute(),
                ( int )domRect.GetHeightAttribute());

            return(r);
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.writeablebitmap.adddirtyrect?view=netframework-4.8

                if (_BitmapSource != null)
                {
                    var rect = new System.Windows.Int32Rect(0, 0, _BitmapSource.PixelWidth, _BitmapSource.PixelHeight);
                    _BitmapSource.AddDirtyRect(rect);
                    _BitmapSource.Unlock();
                    _BitmapSource = null;
                }
            }

            base.Dispose(disposing);
        }
 public static System.Windows.Int32Rect[] GetClientRectsInt32( this GeckoElement element )
 {
     nsIDOMClientRectList domRects = element.DOMElement.GetClientRects();
     uint count = domRects.GetLengthAttribute();
     System.Windows.Int32Rect[] rects = new System.Windows.Int32Rect[count];
     for ( uint i = 0; i < count; i++ )
     {
         nsIDOMClientRect domRect = domRects.Item( i );
         rects[ i ] = new System.Windows.Int32Rect(
             ( int ) Math.Round( domRect.GetLeftAttribute() ),
             ( int ) Math.Round( domRect.GetTopAttribute() ),
             ( int ) Math.Round( domRect.GetWidthAttribute() ),
             ( int ) Math.Round( domRect.GetHeightAttribute() ) );
         // TODO - check code for memory leaks
         //	Marshal.ReleaseComObject( domRect );
     }
     //Marshal.ReleaseComObject( domRects );
     return rects;
 }
        public override void Apply(int Kr, int Kg, int Kb)
        {
            int itR     = 255 / (Kr - 1);
            int itG     = 255 / (Kg - 1);
            int itB     = 255 / (Kb - 1);
            var bmpRect = new System.Windows.Int32Rect(0, 0, width, height);

            bitmap.WritePixels(bmpRect, originalCopy, bitmap.BackBufferStride, 0); // Copy cached original image

            bitmap.Lock();

            unsafe
            {
                byte *bmpArray = (byte *)bitmap.BackBuffer.ToPointer();
                for (int i = 0; i < height; ++i)
                {
                    byte *   currPos = bmpArray + i * bitmap.BackBufferStride;
                    Position row     = GetPos(i, height);
                    for (int j = 0; j < width; ++j)
                    {
                        Position col = GetPos(j, width);

                        byte newVal = RoundToNeareastMultiple(currPos[0], itB).ToByte();
                        PropagateError(currPos[0] - newVal, 0, currPos, row, col);
                        currPos[0] = newVal;

                        newVal = RoundToNeareastMultiple(currPos[1], itG).ToByte();
                        PropagateError(currPos[1] - newVal, 1, currPos, row, col);
                        currPos[1] = newVal;

                        newVal = RoundToNeareastMultiple(currPos[2], itR).ToByte();
                        PropagateError(currPos[2] - newVal, 2, currPos, row, col);
                        currPos[2] = newVal;

                        currPos += bytesPerPixel;
                    }
                }
            }
            bitmap.AddDirtyRect(bmpRect);

            bitmap.Unlock();
        }
        public static byte[] ToArray(this WriteableBitmap bitmapSource, System.Windows.Int32Rect srcRect)
        {
            if (srcRect.IsEmpty)
            {
                return(new byte[1]);
            }
            try
            {
                // Stride = (width) x (bytes per pixel)
                int    stride = (int)srcRect.Width * (bitmapSource.Format.BitsPerPixel / 8);
                byte[] pixels = new byte[(int)srcRect.Height * stride];

                bitmapSource.CopyPixels(srcRect, pixels, stride, 0);

                return(pixels);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("********: " + ex.ToString());
                return(new byte[1]);
            }
        }
 private void WrapUp(object sender, EventArgs e)
 {
     System.Windows.Int32Rect dirtyRect = new System.Windows.Int32Rect(0, 0, _Width, _Height);
     try
     {
         unsafe
         {
             _bitmap.Lock();
             int intPtr = (int)_bitmap.BackBuffer;
             for (int i = 0; i < _ImageLength; i++)
             {
                 *((int *)intPtr) = _bufferCopy[i];
                 intPtr          += 4;
                 if (i % _Width == 0)
                 {
                     intPtr += _BufferSize;
                 }
             }
         }
         _bitmap.AddDirtyRect(dirtyRect);
     }
     catch { }
     finally { _bitmap.Unlock(); }
 }
Beispiel #23
0
        public FreeImageAlgorithmsWPFImage(string filepath) : base()
        {
            this.FilePath = filepath;

            try
            {
                this.Fib = Tile.LoadFreeImageBitmapFromFile(filepath);
            }
            catch (Exception e)
            {
                throw;
            }

            ThumbnailFib = new FreeImageAlgorithmsBitmap(this.Fib);
            Tile.ResizeToThumbnail(ThumbnailFib);

            if (ThumbnailFib.IsGreyScale)
            {
                ThumbnailFib.LinearScaleToStandardType(0, 0);
            }
            else
            {
                ThumbnailFib.ConvertToStandardType(true);
            }

            Bitmap bitmap = ThumbnailFib.ToBitmap();

            System.Windows.Int32Rect rect = new System.Windows.Int32Rect();

            rect.X      = 0;
            rect.Y      = 0;
            rect.Width  = bitmap.Width;
            rect.Height = bitmap.Height;

            this.Source = ConvertGdiToWPF(bitmap, rect);
        }
 public CroppedBitmap(BitmapSource source, System.Windows.Int32Rect sourceRect)
 {
 }
Beispiel #25
0
        private void BuildDeck(bool useImages)
        {
            // fill the base deck we have to work with
            stockDeck.Clear();
            for (int suit = 1; suit < 5; suit++)
            {
                for (int rank = 1; rank < 14; rank++)
                {
                    if (useImages)
                    {
                        int cardWidth = allCards.PixelWidth / 13;
                        int cardHeight = allCards.PixelHeight / 5;
                        int cardX = cardWidth * (rank - 1);
                        int cardY = cardHeight * (suit - 1);
                        System.Windows.Int32Rect rect = new System.Windows.Int32Rect(cardX, cardY, cardWidth, cardHeight);
                        CroppedBitmap subCard = new CroppedBitmap(allCards, rect);

                        // we know where our 'back' card is
                        rect.X = cardWidth * 2;
                        rect.Y = cardHeight * 4;
                        CroppedBitmap cardBack = new CroppedBitmap(allCards, rect);

                        stockDeck.Add(new Card(rank, suit, subCard, cardBack));
                    }
                    else
                    {
                        stockDeck.Add(new Card(rank, suit));
                    }

                }
            }
        }
Beispiel #26
0
        // FeatureDataTablet to shapefile
        private void WriteFeatureDataTable2shp(GeometryType gtype, FeatureDataTable ftable, IFeatureClass fc, String shapefilePath)
        {
            int rowCount = ftable.Rows.Count;
            int colCount = ftable.Columns.Count;
            int geometryColIndex = ftable.GeometryColumnIndex;
            //GeometryType gtype = selLayer.GeometryType;
            toolStripProgressBar1.Maximum = rowCount;
            toolStripProgressBar1.Value = 0;
            toolStripProgressBar1.Visible = true;

            // for each selected features
            for (int i = 0; i < rowCount; i++)
            {
                toolStripProgressBar1.Value = i + 1;
                selectionStripStatusLabel1.Text = toolStripProgressBar1.Value.ToString() + "/" + rowCount.ToString() + " features exported .";
                toolStripStatusLabel2.Text = shapefilePath;
                Application.DoEvents();

                // create a new feature
                IFeature feature = fc.CreateFeature();
                DataRow arow = ftable.Rows[i];
                string globalid;
                if (arow.Table.Columns.Contains("GlobalID"))
                {
                    globalid = arow["GlobalID"].ToString();
                }
                else
                {
                    globalid = arow["OBJECTID"].ToString();
                }

                // geometry
                ESRI.ArcGIS.Mobile.Geometries.Geometry mobileGeometry = arow[geometryColIndex] as ESRI.ArcGIS.Mobile.Geometries.Geometry;
                byte[] mobileGeometryByteArray = mobileGeometry.ExportToEsriShape();
                int len = mobileGeometryByteArray.Length;
                switch (gtype)
                {
                    case GeometryType.Point:
                        ESRI.ArcGIS.Geometry.IPoint aoShape = new ESRI.ArcGIS.Geometry.PointClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape;
                        break;

                    case GeometryType.Multipoint:
                        ESRI.ArcGIS.Geometry.IMultipoint aoShape2 = new ESRI.ArcGIS.Geometry.MultipointClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape2).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape2;
                        break;

                    case GeometryType.Polyline:
                        ESRI.ArcGIS.Geometry.IPolyline aoShape3 = new ESRI.ArcGIS.Geometry.PolylineClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape3).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape3;
                        break;

                    case GeometryType.Polygon:
                        ESRI.ArcGIS.Geometry.IPolygon aoShape4 = new ESRI.ArcGIS.Geometry.PolygonClass();
                        ((ESRI.ArcGIS.Geometry.IESRIShape)aoShape4).ImportFromESRIShape(ref len, ref mobileGeometryByteArray[0]);
                        feature.Shape = aoShape4;
                        break;
                }

                // insert other attributes
                // in mobile cache, the last col is for geometry
                // in shapefile, fid and shape fields are first two, for other fields index = +2
                for (int col = 0; col < colCount - 1; col++)
                {
                    // type
                    DataColumn dc = ftable.Columns[col];
                    Type dt = dc.DataType;

                    // guid or globalid, change to string
                    if (dt == typeof(Guid) || (dt == typeof(ESRI.ArcGIS.Mobile.GlobalId)))
                    {
                        feature.set_Value(col + 2, arow[col].ToString());
                        //feature.Store();
                        continue;
                    }

                    // if blob field, write to file
                    if (dt == typeof(Byte[]))
                    {
                        continue;
                    }
                    // raster field, write to jpg files
                    if (dt == typeof(Bitmap))
                    {
                        string photofoldername = shapefilePath + "\\" + dc.ColumnName;
                        if (!Directory.Exists(photofoldername))
                            continue;

                        // get bitmap from a raster field, save to ImageSource
                        System.Windows.Media.ImageSource imgsrc = null;
                        Bitmap bitmap = arow[col] as Bitmap;
                        if (bitmap == null)
                            continue;

                        System.Windows.Int32Rect rect = new System.Windows.Int32Rect(0, 0, bitmap.Width, bitmap.Height);
                        IntPtr hBitmap = IntPtr.Zero;
                        try
                        {
                            hBitmap = bitmap.GetHbitmap();
                            imgsrc = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                                     hBitmap, IntPtr.Zero, rect, BitmapSizeOptions.FromEmptyOptions());

                            // write the ImageSource to jpg
                            if (imgsrc == null)
                                continue;
                            JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                            encoder.Frames.Add(BitmapFrame.Create(imgsrc as BitmapSource));
                            string fileName = photofoldername + "\\" + globalid + ".jpg";
                            using (System.IO.FileStream file = File.OpenWrite(fileName))
                            {
                                encoder.Save(file);
                            }

                            continue;

                        }
                        finally
                        {
                            if (hBitmap != IntPtr.Zero)
                                DeleteObject(hBitmap);
                        }
                    }  // end of bitmap

                    // other data types, just set the value
                    if (arow[col].ToString() != "")
                        feature.set_Value(col + 2, arow[col]);
                    else
                        feature.set_Value(col + 2, 0);

                }

                feature.Store();
            }

            //MessageBox.Show(rowCount.ToString() + " features saved into a shapefile at: " + shapefilePath);
            toolStripProgressBar1.Value = 0;
            selectionStripStatusLabel1.Text = "";
            toolStripProgressBar1.Visible = false;

            return;
        }
Beispiel #27
0
 public void AddDirtyRect(System.Windows.Int32Rect dirtyRect)
 {
 }
Beispiel #28
0
 public void WritePixels(System.Windows.Int32Rect sourceRect, IntPtr sourceBuffer, int sourceBufferSize, int sourceBufferStride, int destinationX, int destinationY)
 {
 }
Beispiel #29
0
 public virtual new void CopyPixels(System.Windows.Int32Rect sourceRect, Array pixels, int stride, int offset)
 {
 }
Beispiel #30
0
        private static void SaveImageAsPngFile(System.Windows.Media.Imaging.WriteableBitmap bitmap, string fileName, IntPtr hwnd, System.Windows.Int32Rect clippingRect)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException("Invalid bitmap!!");
            }

            if (!User32DllMethodsInvoker.IsWindow(hwnd))
            {
                throw new ArgumentException("Invalid window!!");
            }

            // クライアント矩形やユーザー定義クリッピング矩形で切り出した内容のみを保存する。
            var intersectRect = MyWin32InteropHelper.CalcClientIntersectRect(hwnd, clippingRect);

            System.Diagnostics.Debug.Assert(intersectRect.HasArea);

            var tempSubBitmap = new System.Windows.Media.Imaging.WriteableBitmap(intersectRect.Width, intersectRect.Height,
                                                                                 MyDeviceHelper.DefaultDpi, MyDeviceHelper.DefaultDpi, System.Windows.Media.PixelFormats.Pbgra32, null);

            try
            {
                tempSubBitmap.Lock();
                bitmap.CopyPixels(new System.Windows.Int32Rect(0, 0, intersectRect.Width, intersectRect.Height),
                                  tempSubBitmap.BackBuffer,
                                  tempSubBitmap.PixelWidth * tempSubBitmap.PixelHeight * 4,
                                  tempSubBitmap.PixelWidth * 4);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                tempSubBitmap.Unlock();
            }

            using (var stream = new System.IO.FileStream(fileName,
                                                         System.IO.FileMode.Create, System.IO.FileAccess.Write))
            {
                var encoder = new System.Windows.Media.Imaging.PngBitmapEncoder();
                //encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bitmap));
                encoder.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(tempSubBitmap));
                encoder.Save(stream);
            }
            tempSubBitmap = null;
        }
Beispiel #31
0
 public void SaveImageAsPngFile(string fileName, IntPtr hwnd, System.Windows.Int32Rect clippingRect)
 {
     SaveImageAsPngFile(this.wicBitmap, fileName, hwnd, clippingRect);
 }
Beispiel #32
0
 /// <summary>Casts the <see cref="WpfInt32Rect"/> to a <see cref="Rectangle2I"/>.</summary>
 public static Rectangle2I ToRectangle2I(this WpfInt32Rect rect)
 {
     return(new Rectangle2I(rect.X, rect.Y, rect.Width, rect.Height));
 }
        public int calcMacbethStats(byte[] pixels, int width, int height)
        {
            // //create array of rectangles
            System.Windows.Int32Rect[] macbethRects = new System.Windows.Int32Rect[24];

            for (int i = 0; i < 24; i++) {
                macbethRects[i].Width = (int)(width * 0.06);
                macbethRects[i].Height = (int)(height * 0.09);

                if (i % 6 == 0)
                    macbethRects[i].X = (int)(width * 0.04);
                else if (i % 6 == 1)
                    macbethRects[i].X = (int)(width * 0.21);
                else if (i % 6 == 2)
                    macbethRects[i].X = (int)(width * 0.38);
                else if (i % 6 == 3)
                    macbethRects[i].X = (int)(width * 0.56);
                else if (i % 6 == 4)
                    macbethRects[i].X = (int)(width * 0.72);
                else if (i % 6 == 5)
                    macbethRects[i].X = (int)(width * 0.89);
            }

            for (int i = 0; i < 24; i++) {
                if (i < 6)
                    macbethRects[i].Y = (int)(height * 0.06);
                else if (i < 12)
                    macbethRects[i].Y = (int)(height * 0.33);
                else if (i < 18)
                    macbethRects[i].Y = (int)(height * 0.58);
                else if (i < 24)
                    macbethRects[i].Y = (int)(height * 0.84);
            }

            // get patch stats for each rectangle
            for (int i = 0; i < 24; i++){
                byte[] patch = new byte[macbethRects[0].Width * macbethRects[0].Height*2];
                BitmapSource bmpSource = BitmapSource.Create(width, height, 96, 96, PixelFormats.Gray16, null, pixels, width * 2);
                //image1.Source = bmpSource;
                CroppedBitmap chunk = new CroppedBitmap(bmpSource, macbethRects[i]);

                try
                {
                    chunk.CopyPixels(patch, macbethRects[i].Width * 2, 0); // stuff data into 4 pixel (8 byte) array
                    calculateStats(patch, macbethRects[i].Width, macbethRects[i].Height);
                    MacbethMean[i] = getMeanValues();
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.Message);
                }
            }

            // calculate average colors
            /*int patchrow = 0, patchcol, row;
            for (row = 0; row < height; row++) {

                if ((row > (0.06 * height)) && (row < (0.15 * height)))
                    patchrow = 0;
                else if ((row > (0.33 * height)) && (row < (0.42 * height)))
                    patchrow = 1;
                else if ((row > (0.58 * height)) && (row < (0.67 * height)))
                    patchrow = 2;
                else if ((row > (0.84 * height)) && (row < (0.93 * height)))
                    patchrow = 3;
                else
                    patchrow = 4;

                for (int col = 0; col < width; col++) {

                    if ((col > (0.04 * width)) && (col < (0.1 * width)))
                        patchcol = 0;
                    else if ((col > (0.21 * width)) && (col < (0.27 * width)))
                        patchcol = 1;
                    else if ((col > (0.38 * width)) && (col < (0.44 * width)))
                        patchcol = 2;
                    else if ((col > (0.56 * width)) && (col < (0.62 * width)))
                        patchcol = 3;
                    else if ((col > (0.72 * width)) && (col < (0.78 * width)))
                        patchcol = 4;
                    else if ((col > (0.89 * width)) && (col < (0.95 * width)))
                        patchcol = 5;
                    else
                        patchcol = 6;

                    if ((patchcol < 6) && (patchrow < 4)) {
                        meanvalues[patchrow * 6 + patchcol, (row % 2) * 2 + col % 2] += values[row * width + col]; // assign index according to bayer position
                        pixelcount[patchrow * 6 + patchcol]++;
                    }
                }
            }*/
            return 0;
        }
Beispiel #34
0
 public void WritePixels(System.Windows.Int32Rect sourceRect, Array pixels, int stride, int offset)
 {
 }
Beispiel #35
0
 public void WritePixels(System.Windows.Int32Rect sourceRect, IntPtr buffer, int bufferSize, int stride)
 {
 }
Beispiel #36
0
 public virtual new void CopyPixels(System.Windows.Int32Rect sourceRect, IntPtr buffer, int bufferSize, int stride)
 {
 }
Beispiel #37
0
        private ImageSource GetItem(int index)
        {
            if (index < 0 || index >= Count)
                throw new IndexOutOfRangeException();

            if(m_Cache.ContainsKey(index))
            {
                return m_Cache[index];
            }

            int startPoint = IconWidth * index;
            var Frame = new System.Windows.Int32Rect(startPoint, 0, IconWidth, IconHeight);
            byte[] bits = new byte[m_CompleteImage.PixelHeight * stride];
            m_CompleteImage.CopyPixels(Frame, bits, stride, 0);

            WriteableBitmap target = new WriteableBitmap(
              IconWidth,
              IconHeight,
              m_CompleteImage.DpiX, m_CompleteImage.DpiY,
              m_CompleteImage.Format, null);

            // Write the pixel data to the WriteableBitmap.
            target.WritePixels(
                new System.Windows.Int32Rect(0, 0, IconWidth, IconHeight),
                bits, stride, 0);

            target.Freeze();
            m_Cache.Add(index, target);

            return target;

        }
 void RedrawEitherPreview(WriteableBitmap bmp, byte[] pixels, int width, int height)
 {
     var rect = new System.Windows.Int32Rect(0, 0, width, height);
     bmp.WritePixels(rect, pixels, width * 4, 0);
 }
Beispiel #39
0
        internal static BitmapFrame ToBitmapFrame(this Image image)
        {
            // calculate pixel format
            System.Windows.Media.PixelFormat pixelFormat = PixelFormats.Indexed1;
            switch (image.BitsPerPixel)
            {
            case 1:
                pixelFormat = PixelFormats.Indexed1;
                break;

            case 2:
                pixelFormat = PixelFormats.Indexed2;
                break;

            case 4:
                pixelFormat = PixelFormats.Indexed4;
                break;

            case 8:
                pixelFormat = PixelFormats.Indexed8;
                break;

            case 32:
                pixelFormat = PixelFormats.Bgr32;
                break;

            default:
                throw new NotImplementedException(
                          string.Format(CultureInfo.InvariantCulture, Properties.Resources.E_UnsupportedDepth, image.BitsPerPixel));
            }

            // get palette
            BitmapPalette bitmapPalette = null;

            Color[] palette = Image.CreatePalette(image.BitsPerPixel);
            if (palette != null)
            {
                bitmapPalette = new BitmapPalette(palette.Select(x => System.Windows.Media.Color.FromArgb(x.A, x.R, x.G, x.B)).ToArray());
            }

            WriteableBitmap bitmapSource = new WriteableBitmap(
                image.Width,
                image.Height,
                image.HorizontalResolution,
                image.VerticalResolution,
                pixelFormat,
                bitmapPalette);

            System.Windows.Int32Rect sourceRect = new System.Windows.Int32Rect(0, 0, image.Width, image.Height);
            if (image.BitsPerPixel < 8)
            {
                // swap bits to make storage big-endian
                ulong[] bits = new ulong[image.Bits.Length];
                Vectors.SwapBits(image.Bits.Length, image.Bits, 0, image.BitsPerPixel, bits, 0);
                bitmapSource.WritePixels(sourceRect, bits, image.Stride8, 0);
            }
            else
            {
                bitmapSource.WritePixels(sourceRect, image.Bits, image.Stride8, 0);
            }

            return(BitmapFrame.Create(bitmapSource));
        }