Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# wants to save Bitmap to High resolution

Posted on 2008-10-13
5
Medium Priority
?
3,391 Views
Last Modified: 2013-12-17
HEllo All,
   I need a help to save drawn image to some good resolution.

I am drawing My project related Graphs on C# Form using Drawline,drawsrtring etc.....
Up to hee it wwas fine. i am able to see the drawn image on Form with good resolution.

Now i need to save this "Graph image: to .jpeg format.when i am saving this the resolution is very low on the saved file.how can i overcome this problem? is there any solution to increase the Resolution of the image before saving.

Please help.....

code sample which i am using to save the image to file is

ImageFormat format = ImageFormat.JPEG  ;
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = JPEGFiles(*.jpg)|*.jpg";
            if (sfd.ShowDialog() == DialogResult.OK)
            {        // now save the image in the DrawArea    
                DrawArea.Save(sfd.FileName, format);
               
            }


image.jpg
0
Comment
Question by:SS_NN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:rendaduiyan
ID: 22709313
Bitmap b = new Bitmap(img.Width, img.Height, PixelFormat.Format32bppRgb);
Graphics g = Graphics.FromImage(b);
b.SetResolution(img.HorizontalResolution, img.VerticalResolution);

g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

b.Save(filename, ImageFormat.Jpeg);

From the example, you can see you need decide the color resolution when creating bitmap
and then resolution at two direction for graph.

try it.
0
 

Author Comment

by:SS_NN
ID: 22709697
Hi rendaduiyan,

  Thank you for your solution.but still i am not able to see good resolution one.....
battery.bmp
0
 
LVL 5

Expert Comment

by:rendaduiyan
ID: 22717898
it would be better if I can see your code.

I think it is the way you draw those strings that makes you think they are not in good resolution.

can you change the font, background and foreground color?

Or what the size of your area? what the font size?
0
 
LVL 5

Accepted Solution

by:
rendaduiyan earned 2000 total points
ID: 22718263
And please try different smoothmode, say,
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
different interpolation mode, say,
grfx.InterpolationMode = InterpolationMode.HighQualityBilinear;
when initializing component,

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            this.ClientSize = new System.Drawing.Size(292, 273);
0
 

Author Comment

by:SS_NN
ID: 22720653
Thnkas for your solution. i was able to see the grpah with good resolution.
with the above code snippet i have increased the thickness of the line.

Thanks you verymuch for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question