Beispiel #1
0
        public BitmapImage(int width, int height)
        {
            Width  = width;
            Height = height;

            // create a bitmap and return the WritableGraphics handle
            UnderlyingImage = new Bitmap(width, height);
            var g = System.Drawing.Graphics.FromImage(UnderlyingImage);

            Graphics = new WritableGraphics(null, g, height, width);
        }
Beispiel #2
0
        public void MakeTransparent(RGBA color)
        {
            UnderlyingImage.MakeTransparent(Color.FromArgb(color.A, color.R, color.G, color.B));

            // recreate the graphics after making transparent
            // marking an image transparent has a material impact to the bitmap such that we need
            // a new graphics instance
            var g = System.Drawing.Graphics.FromImage(UnderlyingImage);

            Graphics = new WritableGraphics(null, g, Height, Width);
        }
Beispiel #3
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            try
            {
                SuspendLayout();

                // initial setup
                AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
                AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
                ClientSize          = new System.Drawing.Size(1484, 1075);
                Name           = "shootMup";
                Text           = "shootMup";
                DoubleBuffered = true;

                // double buffer
                Surface = new WritableGraphics(BufferedGraphicsManager.Current, CreateGraphics(), Height, Width);

                // timers
                OnPaintTimer          = new Timer();
                OnPaintTimer.Interval = Common.Constants.GlobalClock / 2;
                OnPaintTimer.Tick    += OnPaintTimer_Tick;
                OnMoveTimer           = new Timer();
                OnMoveTimer.Interval  = Common.Constants.GlobalClock / 2;
                OnMoveTimer.Tick     += OnMoveTimer_Tick;

                // setup game
                World = new World(Surface, new Sounds());

                // setup callbacks
                KeyPress   += OnKeyPressed;
                MouseUp    += OnMouseUp;
                MouseDown  += OnMouseDown;
                MouseMove  += OnMouseMove;
                MouseWheel += OnMouseWheel;
                Resize     += OnResize;

                OnPaintTimer.Start();
            }
            finally
            {
                ResumeLayout(false);
            }
        }