Problem with resource picture

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

Ok first of me new to C#sharp. At the moment I am still learning the language. The problem I am running into is that I just can't seem to get a picture embedded into my program and then read it. Everytime I get a error from the debugger. I tried all kinds of thinks but can figure out what is going wrong. Using the C#builder from Borland I get it working, but not with VS. What am I doing wrong ? I included the program so you can see what I did. the line marked with ==> is where the debugger holds


using System.Drawing
using System.Reflection
using System.Windows.Forms
using System.Resources

namespace Apple

public class Programma: System.Windows.Forms.Form

private System.Drawing.Image buffer
private System.Drawing.Graphics display
public Programma()
InitializeComponent()


private void InitializeComponent()
SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true)
SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true)
SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true)
ClientSize = new Size(392, 60)
buffer = new System.Drawing.Bitmap(392, 60)
display = System.Drawing.Graphics.FromImage(buffer)
new System.Threading.Thread(new System.Threading.ThreadStart(Animation_Start)).Start()


private void Animation_Start()
Assembly assembly = Assembly.GetExecutingAssembly()
==> Image image = Image.FromStream(assembly.GetManifestResourceStream "Apple.Bitmap1.bmp"))
Bitmap bitmap = new Bitmap(56, 60)
Graphics graphics = Graphics.FromImage(bitmap)
graphics.DrawImage(image, -338, 0)
display.DrawImage(bitmap, 0, 0)
Refresh()


protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
System.Drawing.Graphics g = e.Graphics
g.DrawImage(buffer, 0, 0)
base.OnPaint(e)


public static void Main()
System.Windows.Forms.Application.Run(new Programma())
System.Environment.Exit(0)



}
 
Extra info.

When I look in the soluction explore it says the following
Solution 'Apple' (1 project)
- Apple
+ References
App.ico
AssemblyInfo.cs
Bitmap1.bmp
Class1.cs
Form1.cs

Bardo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top