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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:31:05+00:00 2026-06-14T19:31:05+00:00

Basically the code is trying to take a source image, draw some custom text

  • 0

Basically the code is trying to take a source image, draw some custom text on it and save the new image to the file system.

When I run the code in Windows 7, it runs fine, but when I run it in WinXP it creates an exception in the imgCopy.Save line anytime after the first DrawString.

The exception is ArgumentException (parameter is not valid). It’s like the DrawString corrupts the image under WinXP…?

The build is for the x86/.NET 4.0 runtime. Any ideas why the exception under XP?

// imgSrc is actually passed into the method with the rec object
// this is just for repro
using (var imgSrc = new System.Drawing.Bitmap(rec.SrcFile))
using (var imgCopy = imgSrc.Clone() as Bitmap)
using (var gImg = Graphics.FromImage(imgCopy)) //shorten var names for this post
{
    imgCopy.Save(rec.DstFile, ImageFormat.Jpeg); //Happy here
    gImg.SmoothingMode = SmoothingMode.AntiAlias;
    imgCopy.Save(rec.DstFile, ImageFormat.Jpeg); //Also no problem
    gImg.DrawString(rec.Name, fntArial16, Brushes.Black, new Rectangle(170, 105, 650, 50), sfCenter);
    imgCopy.Save(rec.DstFile, ImageFormat.Jpeg); //<-- Fails here
}

Edit: Code for the parameters:

private static Font fntArial16 = new Font("Arial", 16, FontStyle.Bold);

private static StringFormat _sfCenter;
private static StringFormat sfCenter {
    get {
        if (_sfCenter == null) {
            _sfCenter = new StringFormat();
            sfCenter.Alignment = StringAlignment.Center;
            sfCenter.LineAlignment = StringAlignment.Center;
        }
        return _sfCenter;
    }
}
  • 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-14T19:31:06+00:00Added an answer on June 14, 2026 at 7:31 pm

    We narrowed the problem down to the .jpg file containing XMP (Extensible Metadata Platform) data. Once we removed that from the file it worked on WinXP correctly. Unfortunately the tool that generated the file didn’t have the option to exclude this, so we went with the .png file instead and that works fine as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically this is a program which I take a text file with some code
Basically I'm trying to run some code (Python 3.2) if a value on a
So I'm basically just trying to take in some file input, and then take
Basically the code below reads in a text file and diplays it on the
This is basically what I am trying to do. I wanna take a File
Trying to write a code at the moment that basically tests to see if
I'm trying to translate the following JS code to ObjC; It basically defines a
I'm trying to modify the code from this script . Basically I'm trying to
My code below won't compile. What am i doing wrong? I'm basically trying to
I am trying to refactor a working code. The code basically derives an interface

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.