Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
App. WinForms / WPF .NET
[c#] Aiuto disegnare rettangolo
lunedì 08 gennaio 2007 - 16.36
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
er tikre
Profilo
| Newbie
14
messaggi | Data Invio:
lun 8 gen 2007 - 16:36
ragazzi non riesco a disegnare un rettangolo su un'immagine bmp posto la procedura qui sotto:
private void disegnaRettangolo(string nomeImg, string c, double larg, double alt)
{
int x1, y1, l, a;
string[] appo = new string[9];
appo = c.Split(' ');
x1 = Convert.ToInt32(appo[1]);
y1 = Convert.ToInt32(appo[2]);
l = Convert.ToInt32(larg);
a = Convert.ToInt32(alt);
Bitmap myBitmap = new Bitmap(nomeImg);
Graphics g = Graphics.FromImage(myBitmap);
System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
//System.Drawing.Graphics formGraphics;
//Point punto = new Point();
myPen.Width = 3;
g = this.CreateGraphics();
g.DrawRectangle(myPen, new Rectangle(x1, y1, l, a));
g.DrawImage(myBitmap, 1, 1);
//myBitmap.Save(nomeImg);
myPen.Dispose();
g.Dispose();
}
dove sbaglio??
www.expoline.it Cosa volete? qui lo troverete! il portale Anormale!!
maurosegato
Profilo
| Newbie
31
messaggi | Data Invio:
lun 8 gen 2007 - 16:41
Ecco la soluzione...
private void disegnaRettangolo(string nomeImg, string c, double larg, double alt)
{
int x1, y1, l, a;
string[] appo = new string[9];
appo = c.Split(' ');
x1 = Convert.ToInt32(appo[1]);
y1 = Convert.ToInt32(appo[2]);
l = Convert.ToInt32(larg);
a = Convert.ToInt32(alt);
Bitmap myBitmap = new Bitmap(nomeImg);
Graphics g = Graphics.FromImage(myBitmap);
System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
//System.Drawing.Graphics formGraphics;
//Point punto = new Point();
myPen.Width = 3;
g.DrawRectangle(myPen, new Rectangle(x1, y1, l, a));
g.Dispose();
g = this.CreateGraphics();g.DrawImage(myBitmap, 1, 1);
//myBitmap.Save(nomeImg);
myPen.Dispose();
g.Dispose();
}
la chiamata a g.DrawRectangle(...) la richiamavi quando l'oggetto grafico era riferito al form e non alla bitmap..
ciao
Mauro Segato
er tikre
Profilo
| Newbie
14
messaggi | Data Invio:
mar 9 gen 2007 - 10:04
Non mi funziona ......Aiuto non salva l'immagine .....
private void disegnaRettangolo(string nomeImg, string c, double larg, double alt)
{
int x1, y1, l, a;
string[] appo = new string[9];
appo = c.Split(' ');
x1 = Convert.ToInt32(appo[1]);
y1 = Convert.ToInt32(appo[2]);
l = Convert.ToInt32(larg);
a = Convert.ToInt32(alt);
Bitmap myBitmap = new Bitmap(nomeImg);
Graphics g = Graphics.FromImage(myBitmap);
System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Red);
g.DrawRectangle(myPen, new Rectangle(x1, y1, l, a));
g = this.CreateGraphics();
g.DrawImage(myBitmap, 1, 1);
myPen.Dispose();
g.Dispose();
}
www.expoline.it Cosa volete? qui lo troverete! il portale Anormale!!
er tikre
Profilo
| Newbie
14
messaggi | Data Invio:
mar 9 gen 2007 - 16:00
in effetti ho risolto grazie bisognava salvarla!!!!
www.expoline.it Cosa volete? qui lo troverete! il portale Anormale!!
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !