Entra

View Full Version : [C#] immagine di sfondo per form da file.


nikel
01-03-2010, 22:36
ciao ragazzi..

per mettere un immagine di sfondo nella form ho trovato questo codice


assembly asm = Assembly.GetExecutingAssembly();
bitmap backgroundImage = new Bitmap(asm.GetManifestResourceStream("image.bmp"));

e.Graphics.DrawImage(backgroundImage, this.ClientRectangle,
new Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height),
GraphicsUnit.Pixel);



però funziona solo se l'immagine è "embedded" nell'applicazione.. mentre io devo caricarla da file....

come posso fare?
grazie!

ah dimenticavo niente metodo form.backgroundimage perchè non c'è su WM ;)

nikel
02-03-2010, 14:49
Non funziona nemmeno così


bitmap backgroundImage;

//nel paint
backgroundImage = new Bitmap("image.bmp");
e.Graphics.DrawImage(backgroundImage, this.ClientRectangle,
new Rectangle(0, 0, backgroundImage.Width, backgroundImage.Height),
GraphicsUnit.Pixel);


Idee?