public void FromTextToImg(string inputPath, string imagePath, Size imageSize) { var englishWords = parser.Parse(inputPath); var goodEnglishWords = wordListUpdater.UpdateWordList(englishWords); var tagsList = getterFrequancy.GetProperty(goodEnglishWords); var tagsRectanglesDict = tagMaker.MakeCloud(tagsList, imageSize); var bitmap = cloudDrawer.Draw(tagsRectanglesDict); bitmap.Save(imagePath); }
public Bitmap CreatePictureWithItems(IList <TagItem> items) { if (items == null) { throw new ArgumentException("Array can't be null"); } if (items.Count == 0) { throw new ArgumentException("Array can't be empty"); } var picture = new Bitmap(pictureSize.Width, pictureSize.Height); using (var graphics = Graphics.FromImage(picture)) { graphics.SmoothingMode = SmoothingMode.HighQuality; graphics.PageUnit = GraphicsUnit.Pixel; graphics.TextRenderingHint = TextRenderingHint.AntiAlias; graphics.Clear(Settings.Color); graphics.TranslateTransform(pictureSize.Width / 2, pictureSize.Height / 2); var cloudItems = new List <CloudItem>(); foreach (var tagItem in items) { var font = new Font(Settings.Font.FontFamily, tagItem.FontSize, Settings.Font.Style); var stringSize = Size.Round(graphics.MeasureString(tagItem.Word, font)); var item = new CloudItem( tagItem.Word, layouter.PutNextRectangle(stringSize), font); cloudItems.Add(item); } CheckResultSize(cloudItems); cloudDrawer.Draw(graphics, cloudItems, Settings); } return(picture); }