This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static MemoryStream GenerateBlogPostMetaCardWithDescription(string description) | |
{ | |
StringFormat format = new StringFormat(); | |
format.Alignment = StringAlignment.Center; | |
format.LineAlignment = StringAlignment.Center; | |
Bitmap newBitmap; | |
using (var bitmap = (Bitmap)LoadImageTemplate())//load the image file | |
{ | |
using (Graphics graphics = Graphics.FromImage(bitmap)) | |
{ | |
using (Font arialFont = new Font("Arial", 22)) | |
{ | |
Rectangle rect1 = new Rectangle(20, 220, 550, 40); | |
graphics.DrawString(description, arialFont, Brushes.White, rect1, format); | |
} | |
} | |
newBitmap = new Bitmap(bitmap); | |
} | |
MemoryStream memoryStream = new MemoryStream(); | |
newBitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); | |
memoryStream.Position = 0; | |
return memoryStream; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment