b3ta.com board
You are not logged in. Login or Signup
Home » Messageboard » Message 10755806 (Thread)

# that's the amateur version
mine selects a random background and randomly composites images on top of it

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = 'image/jpeg';
context.Response.Expires = -1;
string[] fNamesBG = Directory.GetFiles(context.Server.MapPath('~/images/BG'));
string[] fNamesItem = Directory.GetFiles(context.Server.MapPath('~/images/items'));
Random r = new Random();

Image imgBG = Image.FromFile(fNamesBG[(int)Math.Floor(r.NextDouble() * fNamesBG.Length)]);

for (int i = 0; i < 10; i++)
{

string path = fNamesItem[(int)Math.Floor(r.NextDouble() * fNamesItem.Length)];
Image imgItem = Image.FromFile(path);
Graphics g = Graphics.FromImage(imgBG);
g.DrawImage(imgItem, (float) r.NextDouble() * imgBG.Width, (float) r.NextDouble() * imgBG.Height);
g.Dispose();
imgItem.Dispose();
}

imgBG.Save(context.Response.OutputStream, ImageFormat.Jpeg);
imgBG.Dispose();
}
(, Thu 26 Apr 2012, 21:54, archived)
# is this about Star Wars or football because I don't get it
oh no, it's manga isn't it?
(, Thu 26 Apr 2012, 22:06, archived)
# blimey, look at me calling Dispose() when I've finished with an object
(, Thu 26 Apr 2012, 22:06, archived)
#
blimey, look at me calling Dispose() when I've finished with an object
(, Thu 26 Apr 2012, 22:16, archived)
# nooo don't look at teh code!
i can't help it, it's so beautiful :D
(, Thu 26 Apr 2012, 22:11, archived)