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

  • SEARCH
  • Home
  • 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

Update: since I'm not getting any answers, I've rewritten the entire post using a
Newbie question since I'm not up to speed using maven at all. I'm trying
Hope this question is not stupid since I am an amateur web designer. I
Well it's not realy causing any errors. Anyways i'm sending ajax request and getting
I need to add namespace defintion to an element since its not getting added
I have been scratching my head since long now but not getting around to
I'm having the code as like below. But I'm not getting all the x
I am learing C and would like to know is it possible to replace
I'm trying to implement mutexes inside my standard library but I'm not getting anywhere
I'm writing a wide component infrastructure, to be used in my projects. Since not

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.