Solved

C# wants to save Bitmap to High resolution

Posted on 2008-10-13
5
2,986 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 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

12 Experts available now in Live!

Get 1:1 Help Now