Click here to Skip to main content
15,889,216 members
Home / Discussions / C#
   

C#

 
QuestionExtracting Body From E-mail Pin
NortonC22-Oct-05 23:45
NortonC22-Oct-05 23:45 
QuestionUrgent help needed for sound streaming Pin
IT-Kamla22-Oct-05 23:13
IT-Kamla22-Oct-05 23:13 
QuestionBitmap class Pin
naglbitur22-Oct-05 22:27
naglbitur22-Oct-05 22:27 
AnswerRe: Bitmap class Pin
S. Senthil Kumar23-Oct-05 1:57
S. Senthil Kumar23-Oct-05 1:57 
GeneralRe: Bitmap class Pin
naglbitur23-Oct-05 2:09
naglbitur23-Oct-05 2:09 
GeneralRe: Bitmap class Pin
S. Senthil Kumar23-Oct-05 2:52
S. Senthil Kumar23-Oct-05 2:52 
GeneralRe: Bitmap class Pin
Ravenash23-Oct-05 12:18
Ravenash23-Oct-05 12:18 
AnswerRe: Bitmap class Pin
Rob Graham23-Oct-05 5:47
Rob Graham23-Oct-05 5:47 
The code below works for me.
Bitmap bmp = new Bitmap(w,h,PixelFormat.Format24bppRgb);<br />
               //create drawing surface<br />
               float res = 300f; //default resolution of 300dpi<br />
               bmp.SetResolution(res,res);<br />
               bmp.MakeTransparent(Color.White);<br />
               //Create new graphics canvas from the bitmap<br />
               Graphics G = Graphics.FromImage(bmp);<br />
               //set graphics properties for good bitmap rendering<br />
               G.PageUnit = GraphicsUnit.Pixel;<br />
               G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;<br />
               G.CompositingQuality = CompositingQuality.HighQuality;<br />
               G.CompositingMode = CompositingMode.SourceCopy;<br />
               G.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;<br />
               G.InterpolationMode = InterpolationMode.High;<br />
               //clear the bitmap background (set to white)<br />
               G.Clear(Color.White);<br />
               // draw a 2px border  around the grid image area<br />
               G.DrawRectangle(new Pen(Color.Black,2),0,0,w-2,h-2);<br />
              ....<br />
              // draw the rest of the graphics, including text <br />
               ...<br />
                G.Dispose();<br />
               // save the image<br />
               bmp.Save(imagefilePath,ImageFormat.Bmp);<br />
               bmp.Dispose();


Note: the trick here is to create the bitmap in memory first, using PixelFormat.Format24bppRgb,
then create the graphics surface from it using Graphics.FromImage(). Then anything drawn on the graphics will also be drawn on the bitmap. When done, dispose the graphics and save the bitmap to a file using Image.Save(), then dispose the bitmap.

Absolute faith corrupts as absolutely as absolute power
Eric Hoffer

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke



-- modified at 12:09 Sunday 23rd October, 2005
GeneralRe: Bitmap class Pin
naglbitur25-Oct-05 4:34
naglbitur25-Oct-05 4:34 
GeneralRe: Bitmap class Pin
naglbitur25-Oct-05 4:37
naglbitur25-Oct-05 4:37 
QuestionExcluding DLLs Pin
AB777122-Oct-05 20:25
AB777122-Oct-05 20:25 
AnswerRe: Excluding DLLs Pin
User 167325222-Oct-05 21:07
User 167325222-Oct-05 21:07 
AnswerRe: Excluding DLLs Pin
leppie22-Oct-05 22:08
leppie22-Oct-05 22:08 
Questionabout webbrower Pin
wangfenli22-Oct-05 17:39
wangfenli22-Oct-05 17:39 
QuestionRegular Expression ? Pin
Skoder22-Oct-05 17:13
Skoder22-Oct-05 17:13 
AnswerRe: Regular Expression ? Pin
Guffa22-Oct-05 18:40
Guffa22-Oct-05 18:40 
GeneralRe: Regular Expression ? Pin
Skoder23-Oct-05 5:29
Skoder23-Oct-05 5:29 
GeneralRe: Regular Expression ? Pin
Matt Gerrans23-Oct-05 8:42
Matt Gerrans23-Oct-05 8:42 
GeneralRe: Regular Expression ? Pin
Skoder23-Oct-05 10:28
Skoder23-Oct-05 10:28 
GeneralRe: Regular Expression ? Pin
Guffa25-Oct-05 13:35
Guffa25-Oct-05 13:35 
AnswerRe: Regular Expression ? Pin
Matt Gerrans22-Oct-05 19:42
Matt Gerrans22-Oct-05 19:42 
GeneralRe: Regular Expression ? Pin
Skoder23-Oct-05 5:32
Skoder23-Oct-05 5:32 
Questionhelp please, set focus to control Pin
CandyMe22-Oct-05 16:14
CandyMe22-Oct-05 16:14 
AnswerRe: help please, set focus to control Pin
MoustafaS22-Oct-05 16:44
MoustafaS22-Oct-05 16:44 
GeneralRe: help please, set focus to control Pin
CandyMe23-Oct-05 15:33
CandyMe23-Oct-05 15:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.