Example #1
0
        public void DrawImage(Image2D image, Vector2 location)
        {
            var previous = NativeDeviceContext.Transform;

            NativeDeviceContext.Transform = Matrix3x2.Multiply(NativeDeviceContext.Transform, Matrix3x2.Translation(new SharpDX.Vector2(location.X, location.Y)));
            NativeDeviceContext.DrawBitmap(image.nativeBitmap, 1.0f, BitmapInterpolationMode.Linear);
            NativeDeviceContext.Transform = previous;
        }
Example #2
0
        public static Image2D LoadFromFile(string path, Canvas canvas)
        {
            ImagingFactory   imagingFactory = new ImagingFactory();
            NativeFileStream fileStream     = new NativeFileStream(path,
                                                                   NativeFileMode.Open, NativeFileAccess.Read);
            BitmapDecoder     bitmapDecoder = new BitmapDecoder(imagingFactory, fileStream, DecodeOptions.CacheOnDemand);
            BitmapFrameDecode frame         = bitmapDecoder.GetFrame(0);
            FormatConverter   converter     = new FormatConverter(imagingFactory);

            converter.Initialize(frame, PixelFormatWic.Format32bppPRGBA);

            var result = new Image2D();

            result.nativeBitmap = Bitmap2D.FromWicBitmap(canvas.NativeDeviceContext, converter);
            return(result);
        }