.
1: private Image CreaAvatar(string viso, string capelli, string occhi, string naso, string bocca)
2: {
3: Image m = null;
4:
5: try
6: {
7: Graphics graphics = null;
8:
9: // jpg
10: Image imgViso = Image.FromFile(viso);
11:
12: // png con trasparenza
13: Image imgCapelli = Image.FromFile(capelli);
14: Image imgOcchi = Image.FromFile(occhi);
15: Image imgNaso = Image.FromFile(naso);
16: Image imgBocca = Image.FromFile(bocca);
17:
18: // creo la nuova immagine
19: m = Image.FromFile(viso);
20: graphics = System.Drawing.Graphics.FromImage(m);
21: graphics.DrawImageUnscaled(imgViso, 0, 0);
22: graphics.DrawImageUnscaled(imgCapelli, 0, 0);
23: graphics.DrawImageUnscaled(imgOcchi, 0, 0);
24: graphics.DrawImageUnscaled(imgNaso, 0, 0);
25: graphics.DrawImageUnscaled(imgBocca, 0, 0);
26: graphics.Save();
27: }
28: catch (Exception ex)
29: {
30: throw new Exception("Errore nel creare l'avatar", ex);
31: }
32:
33: return m;
34: }