Solved

C# wants to save Bitmap to High resolution

Posted on 2008-10-13
5
3,011 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
  • 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 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now