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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:21:33+00:00 2026-05-20T01:21:33+00:00

I have some code that creates a graph using the Bitmap class. The quality

  • 0

I have some code that creates a graph using the Bitmap class. The quality of the produced bitmap, however, is pretty poor, how can I improve the quality of this? Note that I am using the Compact Framework!

Here is a few snippets of how I do various things:

Create a bitmap with a background based on an existing jpg

Bitmap bitmap = new Bitmap(filename);

I then create a Graphics class from the bitmap

Graphics myG = Graphics.FromImage(bitmap);

I then draw to the graphics like so:

myG.DrawLine(majorAxisPen, graphRect.Left, graphRect.Bottom, graphRect.Right, graphRect.Bottom);

After drawing everything I need to I then save out the Bitmap like so:

bitmap.Save(fileDestination, System.Drawing.Imaging.ImageFormat.Jpeg);

Here is the image it produces
Poor quality image

  • 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-20T01:21:33+00:00Added an answer on May 20, 2026 at 1:21 am

    There are two sources of “low quality” you may encounter.

    1. The actual drawing to the graphics object may be low quality – i.e. the lines you draw may be aliased (pixelated).
    2. The low quality can be a side effect of the jpeg encoding when you output the graphics to a stream.

    Every Graphics object has a number of properties that control the “quality” of the operations you can perform on the object. In particular, you should set SmoothingMode to HighQuality to avoid jaggies on line drawings. Unsupported in .NET Compact Framework.

    To avoid compression artifacts, you can control jpeg compression parameters by manually controlling compression rather than using the (low-quality) default ImageFormat.Jpeg – unfortunately, doing so on CF is not possible without resorting to manual P/Invoking or a third party library. For a more extensive code sample for the full .NET Framework, see an answer I wrote to a similar question: How do you conver a HttpPostedFileBase to an Image?.

    An easy alternative is to use use PNG, a lossless image format that does not degrade quality each time it is saved – given the simple geometric shapes of the example you posted, this won’t even cost you anything in terms of file-size. Using another format may be your only option; customizing jpeg encoder parameters isn’t possible in the Compact Framework since the ImageCodecInfo isn’t available. If you really need Jpeg, you could attempt to use an external library (e.g. http://www.opennetcf.com/library/sdf/), or P/Invoke native methods directly to access platform-specific encoders.

    Some possible approaches for anti-aliasing:

    • A simple Faux-antialiasing for .NET CF is described here: Anti aliasing DrawLine on CE
    • A related question with suggestions for graph drawing on .NET CF: Graphs in .NET CF
    • An external library e.g. http://www.opennetcf.com/library/sdf/, http://drawingcf.codeplex.com/
    • P/Invoke
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that creates some span tags and each span has its
I have some code that creates a Process instance and later starts it. There's
I have some code that creates a bunch of UITextViews and puts them into
I have some code that dynamically creates a new button through JavaScript that when
I have some javascript code that creates an img tag with a mouseover callback,
I have some Javascript code that creates 2 arrays: One for Product Category and
So I have a chunk of code that declares some classes, creates data, uses
I have some code that creates a popup and assign it an XML layout
So I have some Objective-c code that was created in Xcode 3.1 on OSX
we have some C++ code that we need to create a make file in.

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.