Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.91 KB | None | 0 0
  1. using (Bitmap bmp = new Bitmap(bigW, bigH))
  2.             {
  3.                 using (Graphics g = Graphics.FromImage(bmp))
  4.                 {
  5.                     foreach (Individual person in indList)
  6.                     {
  7.                         individualName = person.fullName;
  8.                         dateBirth = person.dateOfBirth.ToString();
  9.                         dateDeath = person.dateOfDeath.ToString();
  10.                         yCoordinate = yCoordinate + 130;
  11.  
  12.                         //Draws a rectangle and fills it with the information retrieved from the database
  13.                         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  14.                         g.Clear(Color.Bisque);
  15.  
  16.                         g.DrawRectangle(Pens.Brown, xCoordinate, yCoordinate, width, height);
  17.  
  18.                         g.DrawString(individualName,
  19.                             new Font("Arial", 10, FontStyle.Bold),
  20.                             SystemBrushes.WindowText,
  21.                             new PointF(20, yCoordinate),
  22.                             new StringFormat());
  23.  
  24.                         g.DrawString(dateBirth,
  25.                             new Font("Arial", 10, FontStyle.Bold),
  26.                             SystemBrushes.WindowText,
  27.                             new PointF(20, yCoordinate + 15),
  28.                             new StringFormat());
  29.  
  30.                         g.DrawString(dateDeath, new Font("Arial", 10, FontStyle.Bold),
  31.                             SystemBrushes.WindowText,
  32.                             new PointF(20, yCoordinate + 30),
  33.                             new StringFormat());
  34.  
  35.                         g.DrawString(familyName, new Font("Arial", 10, FontStyle.Bold),
  36.                             SystemBrushes.WindowText,
  37.                             new PointF(titleLocation, 10),
  38.                             new StringFormat());
  39.  
  40.                         g.FillRectangle(new SolidBrush(Color.FromArgb(alpha, red,
  41.                             green, blue)), xCoordinate, yCoordinate, width, height);
  42.  
  43.                         g.DrawRectangle(Pens.Azure, (bigW/2), 1, 1, bigH); //Draws a line down the middle of the page, currently only testing for Johnson
  44.                     }
  45.  
  46.  
  47.                     // Saves it?? Outputs an image??
  48.                     string filename = Server.MapPath("/") + Guid.NewGuid().ToString("N");
  49.                     bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
  50.                     byte[] bytes;
  51.                     using (System.IO.FileStream stream = new System.IO.FileStream(filename, System.IO.FileMode.Open))
  52.                     {
  53.                         bytes = new byte[stream.Length];
  54.                         stream.Read(bytes, 0, bytes.Length);
  55.                     }
  56.                     System.IO.File.Delete(filename);
  57.                     return new FileContentResult(bytes, "image/jpeg");
  58.                 }
  59.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement