draw a new bitmap on button press?

p_dog_2007

Active member
Joined
Sep 6, 2003
Messages
28
Location
MIchigan
I have a program that Im going to use to make a map, I made it so on button press it draws the bitmap I want, in the next location, I want it to draw a new bitmap and leave the other there.

Ive atached the file, can any one help?
 

Attachments

you should make a big bitmap which is empty at start and then you just draw in the bitmaps for every location and at the paint event you just draw the whole big bitmap (like doublebuffering)
 
after noticing that i forgot you and making the promise to code it, i noticed (again) that your code is in vb.net, which is a problem since i am coding in c#

nevertheless i coded it in c# and hope you understand everything, if not just ask!

C#:
using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ButtonBitmap
{
	public class Form1 : System.Windows.Forms.Form
	{
		private string Filename = "ground.bmp";
		private int X = 0;
		private int Y = 0;
		private int MaxX = 5;
		private int MaxY = 5;
		private Bitmap Tile = null;
		private Bitmap Map = null;
		
		private System.Windows.Forms.Button GroundBtn;

		private System.ComponentModel.Container components = null;

		public Form1()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Erforderliche Methode f
 
thanks!

Thank you so much, Just what I needed. One more prob. tho, if I added Another button, say "PathBtn", I can change it so it makes the path just fine but when I click the ground btn agan then it makes a path....? I did it useing, Tile=new bitmap("tiles/path.bmp"), In the PathBtn_Click, now if i put, Tile=new Bitmap("tiles/gtound.bmp"), In the groundbtn_click, when I run the program Neither buttion does any thing, with only the tile= new bitmap("tiles/path.bmp") in the pathbtn_click it changes over, but then if I add the tile=new bitmap("tiles/ground.bmp") in the groundbtn_click then it wont do anything for either.
 
Back
Top