Jump to content
Xtreme .Net Talk

Nerseus

*Experts*
  • Posts

    2607
  • Joined

  • Last visited

Everything posted by Nerseus

  1. I have sample projects of Direct3D in C# if anyone would care to take a look. They utilize Vertex Buffers for some 3D work. They also use textures and sprites. It uses the VB DirectX COM DLL so you'll need the DirectX SDK installed (DirectX 8). Other than calling into the DirectX DLL, there is no unmanaged code. If enough people would like to see it, I can post the two projects here. -ner
  2. Attached is a sample VB.NET project that shows how to reference an embedded image file. To recreate, do this: Create a new project named "embedded image". Add the file "testimage.bmp" For the image's properties, change it's "Build Action" to "Embedded Resource". In Form_Load, add the following: ' The project name is "embedded image" - look at Solution Explorer to see it ' You must reference the image by "namespace.filename.extension". ' The namespace can be seen by looking at the project properties. In this case, ' it's "embedded_image". The underscore was added because the project name has a space ' The filename is "testimage.bmp" ' Together, they form: "embedded_image.testimage.bmp" Me.Button1.Image = New Bitmap(Me.GetType().Assembly.GetManifestResourceStream("embedded_image.testimage.bmp")) Obviously, you can leave out the comments if you want :) Hope that helps! -nerseus
  3. You can put the images in the same folder as the executable, sure. They won't be embedded in the EXE, but that's fine (probably better, actually). For development, just put the image in \bin\Debug or \bin\Release then reference the picture without any path information, such as: button1.Image = New Bitmap("blah.bmp") Or you could store them in a subfolder (such as \bin\Debug\images) and use: button1.Image = New Bitmap("images\\blah.bmp") (The double backslash is used in C#, not sure about VB) When you give someone your EXE, just create a subfolder named "images" under the location of the EXE. Yet another alternative is to have a dummy form that contains the pictures embedded already (or in a PictureBox or multiple PictureBoxes on your form). Set the Image property at design time and .NET will embed the picture in your RESX file. When you compile to an EXE, the picture will get embedded automatically. Then you can do something like: button1.Image = picBox1.Image Hope that helps! -nerseus
  4. Add the image to your project as normal (don't worry about copying it anywhere - .NET will copy it to your project folder when you add it). Select the BMP file (or whatever type it is) and change it's "Build Action" to "Embedded Resource". Now you'll want to use the Assembly's GetManifestResourceStream method to load the embedded resource. It returns a Stream object, which can be passed to a Bitmap object to get the image. You can use something like the following. Note that the name of the file has the namespace attached to it ("WinTest" in my sample): (this may not be right, I'm typing from memory): ' Assume this is loading the form's background image Me.BackgroundImage = New Bitmap(Me.GetType().Assembly.GetManifestResourceStream("WinTest.test.bmp") Hope that helps! If it still doesn't work, let me know. I use C#, but I can probably wiggle it out in VB.NET :) -nerseus
×
×
  • Create New...