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 8416409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:44:48+00:00 2026-06-10T01:44:48+00:00

So I am using the following code to take an existing image, text from

  • 0

So I am using the following code to take an existing image, text from an input form, and then place the text from the input form onto the existing image and save it as a new image:

using (FileStream output = new FileStream(match_outputFile, FileMode.Create))
{
    BitmapImage bitmap = new BitmapImage(new Uri(match_sourceFile, UriKind.Relative));
    DrawingVisual visual = new DrawingVisual();

    using (DrawingContext image = visual.RenderOpen())
    {
        image.DrawImage(bitmap, new Rect(0, 0, bitmap.PixelWidth, bitmap.PixelHeight));

        buildText(image, "text1", this.text1.Text);
        buildText(image, "text2", this.text2.Text);
        buildText(image, "text3", this.text3.Text);
    }

    RenderTargetBitmap target = new RenderTargetBitmap(bitmap.PixelWidth, bitmap.PixelHeight, bitmap.DpiX, bitmap.DpiY, PixelFormats.Default);
    target.Render(visual);

    BitmapEncoder encoder = new PngBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(target));
    encoder.Save(output);
}

As you can see, it calls the following function to draw the text:

private void buildText(DrawingContext image, string settings, string input)
{
    string[] setting = (Properties.Settings.Default[settings].ToString()).Split(',');

    FormattedText text = new FormattedText(
        input,
        System.Globalization.CultureInfo.InvariantCulture,
        FlowDirection.LeftToRight,
        new Typeface(new FontFamily(setting[0]), FontStyles.Normal, FontWeights.Bold, FontStretches.Normal),
        Convert.ToDouble(setting[5]),
        (Brush) new BrushConverter().ConvertFromString(setting[4])
    );
    text.MaxTextWidth = Convert.ToDouble(setting[8]);
    text.MaxTextHeight = Convert.ToDouble(setting[9]);

    Point position = new Point(Convert.ToDouble(setting[7]), Convert.ToDouble(setting[6]));

    switch (setting[2])
    {
        case "center": position.X += (Convert.ToDouble(setting[8]) - text.Width) / 2; break;
        case "right": position.X += Convert.ToDouble(setting[8]) - text.Width; break;
    }

    switch (setting[3])
    {
        case "middle": position.Y += (Convert.ToDouble(setting[9]) - text.Height) / 2; break;
        case "bottom": position.Y += Convert.ToDouble(setting[9]) - text.Height; break;
    }

    image.DrawText(text, position);
}

Now what I need is simple… I need to draw text2 (and ONLY text2) at an ANGLE from the center position. The center position is simple, it would be:

centerX = (setting[8] - setting[7]) / 2;
centerY = (setting[9] - setting[6]) / 2;

So what if I wanted to draw this text, at a -30 degree angle rotated at the center position? Remember I want ONLY text 2 rotated, not the other text, and not the original image source either.

  • 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-06-10T01:44:50+00:00Added an answer on June 10, 2026 at 1:44 am

    You could simply push a RotateTransform onto the DrawingContext before drawing the text. After drawing, pop the transform.

    buildText(image, "text1", this.text1.Text);
    image.PushTransform(new RotateTransform(angle, centerX, centerY));
    buildText(image, "text2", this.text2.Text);
    image.Pop();
    buildText(image, "text3", this.text3.Text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following C code to take input from user until EOF
Well I am using the following code to take any old image into a
I'm using the following code (credit to Dolph Larson) to take a pre-made image
Im using the following code to take an image, convert it to grayscale, and
Using following code I try to get updated list of checkbuttons' corresponding text values,
I am creating date using following code try { newdatetime = new DateTime(2012, 2,
I am using following code to get bitmap from url. This function is used
I am using following code to get source for image in wpf (image is
I am using the following code to take a screenshot of a TableLayout. I
I am using following code to enable my text box to write in Urdu

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.