Exemplo n.º 1
0
        private DXImage GetImageForImageElement(ImageElement element)
        {
            DXImage result = null;

            if (!_imageCache.TryGetValue(element, out result))
            {
                result = ToDispose(new DXImage(_device, _deviceContext));
                result.Initialise(element.Bitmap);
                _imageCache[element] = result;
            }

            return(result);
        }
Exemplo n.º 2
0
        public void DrawImage(int x, int y, float scale, float angle, Color?color, DXImage image)
        {
            Debug.Assert(_initialized);

            var    blendFactor = new Color4(1.0f);
            Color4 backupBlendFactor;
            int    backupMask;

            using (
                var backupBlendState = _deviceContext.OutputMerger.GetBlendState(out backupBlendFactor, out backupMask))
            {
                _deviceContext.OutputMerger.SetBlendState(_transparentBS, blendFactor);

                BeginBatch(image.GetSRV());

                Draw(new Rectangle(x, y, (int)(scale * image.Width), (int)(scale * image.Height)),
                     new Rectangle(0, 0, image.Width, image.Height),
                     color.HasValue ? ToColor4(color.Value) : Color4.White, 1.0f, angle);

                EndBatch();
                _deviceContext.OutputMerger.SetBlendState(backupBlendState, backupBlendFactor, backupMask);
            }
        }
Exemplo n.º 3
0
        public void DrawImage(int x, int y, float scale, float angle, Color? color, DXImage image)
        {
            Debug.Assert(_initialized);

            var blendFactor = new Color4(1.0f);
            Color4 backupBlendFactor;
            int backupMask;
            using (
                var backupBlendState = _deviceContext.OutputMerger.GetBlendState(out backupBlendFactor, out backupMask))
            {
                _deviceContext.OutputMerger.SetBlendState(_transparentBS, blendFactor);

                BeginBatch(image.GetSRV());

                Draw(new Rectangle(x, y, (int) (scale*image.Width), (int) (scale*image.Height)),
                    new Rectangle(0, 0, image.Width, image.Height),
                    color.HasValue ? ToColor4(color.Value) : Color4.White, 1.0f, angle);

                EndBatch();
                _deviceContext.OutputMerger.SetBlendState(backupBlendState, backupBlendFactor, backupMask);
            }
        }