vidiware Posted December 3, 2002 Posted December 3, 2002 Is it possible to read picturefiles with many pictures in one, and read from pixel x to y when certain conditions are met, and from y to z at other conditions? Hope you understand what im meaning. Quote
*Gurus* Derek Stone Posted December 3, 2002 *Gurus* Posted December 3, 2002 System.Drawing.Image.FromFile() System.Drawing.Graphics.DrawImage() Quote Posting Guidelines
vidiware Posted December 4, 2002 Author Posted December 4, 2002 thank you... Does this code load an image from file? To make a sprite image: How do you load it then? 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 here are 10 images in one .bmp file... all the small images are 32x32 how can you load picture 1, into image 1, picture 2 into image 2? Quote
*Gurus* Derek Stone Posted December 4, 2002 *Gurus* Posted December 4, 2002 Dim imgMain As Image = Image.FromFile("C:\mybitmap.bmp") You shouldn't be loading more Image objects after this. Use the DrawImage method I posted above to draw the individual sprites where they need to go. DrawImage allows you to specify which part of a larger image you want to paint. Quote Posting Guidelines
vidiware Posted December 5, 2002 Author Posted December 5, 2002 I really can't get this to work... can you write an example? Quote
Machaira Posted December 12, 2002 Posted December 12, 2002 If you're looking to do animation try this: Paste this into a project with Timer and Button controls: Imports System.Drawing.Image Public Class Form1 Inherits System.Windows.Forms.Form Private imgAnim As Image Private gr As Graphics Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Enabled = True End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load imgAnim = Image.FromFile(Application.StartupPath & "\explosion.bmp") gr = Me.CreateGraphics End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Static iFrame As Byte = 0 Dim rect As New Rectangle(iFrame * 65, 0, 65, 65) gr.DrawImage(imgAnim, 50, 50, rect, GraphicsUnit.Pixel) iFrame += 1 If iFrame = 6 Then iFrame = 0 End Sub End Class Place the attached graphic in the apps folder. Click the button to start the animation. If you're not doing animation the theory is still the same. Use a rectangle to get whichever sprite you want.explosion.bmp Quote Here's what I'm up to.
vidiware Posted January 4, 2003 Author Posted January 4, 2003 thank you for this... i was unavailible to ansver for a while... but this is what i was looking for Quote
vidiware Posted January 4, 2003 Author Posted January 4, 2003 But can you pub in comments... what variables that does wich part of the animation Quote
dellanooch Posted January 4, 2003 Posted January 4, 2003 I'm not entirely sure if this can suit you, but instead of doing animations manually with code you can just use an animated gif file instead. I formatted that explosion.bmp and attached it, I've used this technique with VB.NET before and it works fine. http://www.geocities.com/ackillmer/explosion.htm Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.