void Draw(WebData data, int color, int nose, int eyes, int mouth, int face, int rotate) { using (var stream = new MemoryStream()) using (var bmp = new Bitmap32(AvatarSize, AvatarSize)) { var faceColor = ARGB.FromHSI(color / 256.0f, 1, 1); DrawFace(face, faceColor, faces, bmp); DrawEyes(eyes, this.eyes, bmp); DrawMouth(mouth, mouths, bmp); DrawNose(nose, noses, bmp); using (var result = new Bitmap32(AvatarSize, AvatarSize)) { result.Draw(bmp, 0, 0, new Translation() { Rotation = ((rotate % 16) - 7) * 0.02f }); result.Save(stream); } var msg = WebMessage.Create(data.Method, "Avatar created"); data.Answer = WebAnswer.Raw(data.Request, msg, stream.GetBuffer(), "image/png"); data.Answer.AllowCompression = false; data.Answer.SetCacheTime(TimeSpan.FromDays(1)); } }