Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


VB .net scale images wrongly!

This topic is 5550 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've made the beginning of a game where you see a guy from a top-down perspective. So far the map is a matrix that consists of either Floor or Obstacle. I have made two 32x32 bitmaps for those tiles, and for the character too, of course. I load the character into a PictureBox, and he looks alright after I set the AutoSize property. But I draw the map directly from file to the form. Screenshot: http://forum.sweclockers.com/attachment.php?s=&postid=2007862 The code for randomizing the map and drawing it:

	Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
		dim generator as Double
		dim i,j, MAPSIZE, hasPlayerPos as Integer
		dim map2(MAPSIZE, MAPSIZE) as String
		for j = 0 to MAPSIZE
			for i = 0 to MAPSIZE
				generator = Rnd()
				if generator < 0.3
					if hasPlayerPos = 1
						hasPlayerPos = 1
					end if
				End If
				label1.Text += map2(i,j)
			label1.Text += "|"
		'Dim g1 As Graphics										
		'g1 = Me.CreateGraphics									
		'Dim beam As New Pen(Color.Red)							
		Dim MyImage1 As Image
		Dim x as Int16
		for j = 0 to MAPSIZE
			for i = 0 to MAPSIZE
				if map2(i,j) <> "Player"
					myimage1 = Image.FromFile("C:\Documents and Settings\Anders\Mina dokument\anders\Visual Studio Projects\Tactics\" & map2(i,j) & ".bmp")
						e.Graphics.DrawImage(myimage1, new Point(i*myimage1.Width,j*myimage1.Height))
				end if
	End Sub

Obviously VB knows that the images are 32x32, since that is how far it "jumps" when drawing the tiles. However, for some reason it draws them too big so that they don't fit! ------------------ "Kaka e gott" - Me Current project: An RPG with tactical, real-time combat with a realistic damage system, and randomly generated world and dialogue. [edited by - Srekel on August 5, 2003 2:24:55 PM] [edited by - Srekel on August 5, 2003 2:26:34 PM]

Share this post

Link to post
Share on other sites
Nevermind, I solved it

There was an overloaded function that took four integers, where the last two were the height and width of the image.

I don''t know why I had to do it thought, I mean VB should''ve taken care of that by itself?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!