Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5848293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:50:20+00:00 2026-05-22T12:50:20+00:00

Since I am not getting anywhere with my previous question , I would like

  • 0

Since I am not getting anywhere with my previous question, I would like to know, are there any ways I can create icons on the fly on WPF?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:50:21+00:00Added an answer on May 22, 2026 at 12:50 pm

    This is what I ended up doing, I don’t fully understand the details, if you find anything that can be improved, please do comment. Thanks for all the answers and comments.

     public static ImageSource GetIconWithText(int digit)
     {
         BitmapImage myBitmapImage = new BitmapImage(new Uri(@"Images\PomoDomo.ico", 
             UriKind.RelativeOrAbsolute));
    
         DrawingVisual drawingVisual = new DrawingVisual();
    
         using (DrawingContext drawingContext = drawingVisual.RenderOpen())
         {
             // Draw image
             drawingContext.DrawImage(myBitmapImage, new Rect(0, 0, myBitmapImage.Width, 
                 myBitmapImage.Height));
    
             var typeFace = new Typeface(new FontFamily("Verdana"), FontStyles.Normal, 
                 FontWeights.ExtraBold, FontStretches.UltraCondensed);
             var formatedText = new FormattedText(digit.ToString(),
                   CultureInfo.InvariantCulture,
                   FlowDirection.LeftToRight,
                   typeFace,
                   40, 
                   System.Windows.Media.Brushes.White);
    
             //Center the text on Image
             int pointY = (int)(myBitmapImage.Height - formatedText.Height) / 2;
             int pointX = (int)(myBitmapImage.Width - formatedText.Width) / 2;
    
             drawingContext.DrawText(formatedText, new Point(pointX, pointY));
         }
    
         RenderTargetBitmap finalBitmap = new RenderTargetBitmap((int)myBitmapImage.Width, 
             (int)myBitmapImage.Height, myBitmapImage.DpiX, myBitmapImage.DpiY, 
             PixelFormats.Pbgra32);
         finalBitmap.Render(drawingVisual);
         return finalBitmap;
     }
    
     private static void SaveImage(RenderTargetBitmap returnBitmap, string pngFileName)
     {
         string fileName = string.Format("{0}.png", pngFileName)
         PngBitmapEncoder image = new PngBitmapEncoder();
         image.Frames.Add(BitmapFrame.Create(returnBitmap));
         using (Stream fs = File.Create(fileName))
         {
             image.Save(fs);
         }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm cross-posting this from math.stackexchange.com because I'm not getting any feedback and it's a
This has probably been asked before but I can't find it anywhere. I have
I'm not sure how to word the question but here is what I am
I have an issue with my javascript not waiting for the return of the
I'm super new to programming and I've been using appengine to help me learn
I am trying to use Authorize.net's SIM payment gateway process and am using the
I want to place some handles on a UIView I have on-screen. So, I'm
We have an application which stores its data in SQL Server. Each table has
Ok, I’ve spent two days on this and am losing confidence in both myself
I'm dev'ing an MVC 2 website targeting .NET 4.0 and using Ninject 2.0 (dev

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.