public static Bitmap CreateImage(List<TextDataModel> textData) { const int lineHeight = 50; var currentLineHeight = 0; Image = new Bitmap(550, textData.Count * lineHeight); foreach (var textItem in textData) { Image.DrawText(textItem.Text, Color.FromName(textItem.Color), 0, currentLineHeight); currentLineHeight += lineHeight; } Image.DrawPattern(); return Image; }
public void DrawText() { using (Bitmap TestObject = new Bitmap(@"..\..\Data\Image\Lenna.jpg")) { using (Bitmap Image = Assert.Do<Bitmap>(() => TestObject.DrawText("Test text.", new Font(FontFamily.GenericSansSerif, 20.0f), Brushes.Black, new RectangleF(0, 0, 300, 300), @".\Testing\LennaDrawText.jpg"))) { Assert.NotNull(Image); } } }