Ejemplo n.º 1
0
 static void ValidateCannotCreateRenderTarget(CanvasDevice device, DirectXPixelFormat format, CanvasAlphaMode alphaMode)
 {
     ValidateUnsupportedPixelFormatException(() =>
     {
         new CanvasRenderTarget(device, 16, 16, 96, format, alphaMode);
     });
 }
Ejemplo n.º 2
0
 static void ValidateCannotCreateBitmap(CanvasDevice device, DirectXPixelFormat format, CanvasAlphaMode alphaMode)
 {
     ValidateUnsupportedPixelFormatException(() =>
     {
         CanvasBitmap.CreateFromBytes(device, new byte[1024], 4, 4, format, 96, alphaMode);
     });
 }
Ejemplo n.º 3
0
        private void CreatePanelSizeDependentResources()
        {
            _panelWidth  = (float)layoutPanel.ActualWidth;
            _panelHeight = (float)layoutPanel.ActualHeight;

            // Regardless of display AC type, use the same render code.
            DirectXPixelFormat fmt = DirectXPixelFormat.R16G16B16A16Float;
            int numBuffers         = 2;

            if (_swapChain == null)
            {
                _swapChain = new CanvasSwapChain(
                    _device,
                    _panelWidth,
                    _panelHeight,
                    _dispInfo.LogicalDpi,
                    fmt,
                    numBuffers,
                    CanvasAlphaMode.Ignore);
            }
            else
            {
                _swapChain.ResizeBuffers(
                    _panelWidth,
                    _panelHeight,
                    _dispInfo.LogicalDpi,
                    fmt,
                    numBuffers);
            }

            swapChainPanel.SwapChain = _swapChain;
        }
Ejemplo n.º 4
0
        public void RestoreSuspendedState(CanvasDevice device, BinaryReader reader)
        {
            bitmapFormat = (DirectXPixelFormat)reader.ReadInt32();
            bitmapData   = reader.ReadByteArray();

            Size = reader.ReadVector2();

            reader.ReadCollection(Edits, () => EditGroup.RestoreSuspendedState(this, reader));

            RecoverAfterDeviceLost(device);
        }
Ejemplo n.º 5
0
        public async Task Load(CanvasDevice device, StorageFile file)
        {
            using (var stream = await file.OpenReadAsync())
            {
                SourceBitmap = await CanvasBitmap.LoadAsync(device, stream);
            }

            bitmapFormat = sourceBitmap.Format;
            bitmapData   = sourceBitmap.GetPixelBytes();

            Size = sourceBitmap.Size.ToVector2();

            Edits.Clear();
            Edits.Add(new EditGroup(this));

            SelectedEffect = null;
        }
Ejemplo n.º 6
0
        public async Task Load(CanvasDevice device, StorageFile file)
        {
            using (var stream = await file.OpenReadAsync())
            {
                SourceBitmap = await CanvasBitmap.LoadAsync(device, stream);
            }

            bitmapFormat = sourceBitmap.Format;
            bitmapData = sourceBitmap.GetPixelBytes();

            Size = sourceBitmap.Size.ToVector2();

            Edits.Clear();
            Edits.Add(new EditGroup(this));

            SelectedEffect = null;
        }
Ejemplo n.º 7
0
        public void RestoreSuspendedState(CanvasDevice device, BinaryReader reader)
        {
            bitmapFormat = (DirectXPixelFormat)reader.ReadInt32();
            bitmapData = reader.ReadByteArray();

            Size = reader.ReadVector2();

            reader.ReadCollection(Edits, () => EditGroup.RestoreSuspendedState(this, reader));

            RecoverAfterDeviceLost(device);
        }
Ejemplo n.º 8
0
 static CanvasAlphaMode FirstSupportedAlphaMode(DirectXPixelFormat format)
 {
     return formatFlags.ContainsKey(format) ? SupportedAlphaModes(format).First() 
                                            : CanvasAlphaMode.Premultiplied;
 }
Ejemplo n.º 9
0
 static IEnumerable<CanvasAlphaMode> UnsupportedAlphaModes(DirectXPixelFormat format)
 {
     return GetAlphaModes(~formatFlags[format]);
 }
Ejemplo n.º 10
0
 static void ValidateCannotCreateRenderTarget(CanvasDevice device, DirectXPixelFormat format, CanvasAlphaMode alphaMode)
 {
     ValidateUnsupportedPixelFormatException(() =>
     {
         new CanvasRenderTarget(device, 16, 16, 96, format, alphaMode);
     });
 }
Ejemplo n.º 11
0
 static void ValidateCannotCreateBitmap(CanvasDevice device, DirectXPixelFormat format, CanvasAlphaMode alphaMode)
 {
     ValidateUnsupportedPixelFormatException(() =>
     {
         CanvasBitmap.CreateFromBytes(device, new byte[1024], 4, 4, format, 96, alphaMode);
     });
 }
Ejemplo n.º 12
0
 static CanvasAlphaMode FirstSupportedAlphaMode(DirectXPixelFormat format)
 {
     return(formatFlags.ContainsKey(format) ? SupportedAlphaModes(format).First()
                                            : CanvasAlphaMode.Premultiplied);
 }
Ejemplo n.º 13
0
 static IEnumerable <CanvasAlphaMode> UnsupportedAlphaModes(DirectXPixelFormat format)
 {
     return(GetAlphaModes(~formatFlags[format]));
 }