Ejemplo n.º 1
0
        public ILockedFramebuffer Lock()
        {
            var bytesPerPixel = 4; // TODO: derive from ColorType
            var dpi           = Scaling * 96.0;
            var width         = (int)(Size.Width * Scaling);
            var height        = (int)(Size.Height * Scaling);

            if (_fbData is null || _fbData?.Size.Width != width || _fbData?.Size.Height != height)
            {
                _fbData?.Dispose();
                _fbData = new FramebufferData(width, height, bytesPerPixel);
            }

            var pixelFormat = ColorType.ToPixelFormat();
            var data        = _fbData.Value;

            return(new LockedFramebuffer(
                       data.Address, data.Size, data.RowBytes,
                       new Vector(dpi, dpi), pixelFormat, _onDisposeAction));
        }