What quality level does Image.Save() use for jpeg files?

Using reflector, it turns out Image.Save() boils down to the GDI+ function GdipSaveImageToFile, with the encoderParams NULL. So I think the question is what the JPEG encoder does when it gets a null encoderParams. 75% has been suggested here, but I can’t find any solid reference. EDIT You could probably find out for yourself by … Read more

What is the difference between GetClientRect and GetWindowRect in WinApi?

The window rect includes the non-client area, i.e. the window borders, caption bar etc. The client rect does not. GetWindowRect returns a rect in screen coordinates whereas GetClientRect returns a rect in client coordinates. InvalidateRect receives a rect in client coordinates. If you want to invalidate your entire client area, then pass NULL to InvalidateRect. … Read more

Saving image to file

You could try to save the image using this approach SaveFileDialog dialog=new SaveFileDialog(); if (dialog.ShowDialog()==DialogResult.OK) { int width = Convert.ToInt32(drawImage.Width); int height = Convert.ToInt32(drawImage.Height); using(Bitmap bmp = new Bitmap(width, height)) { drawImage.DrawToBitmap(bmp, new Rectangle(0, 0, width, height)); bmp.Save(dialog.FileName, ImageFormat.Jpeg); } }

How to find reason for Generic GDI+ error when saving an image?

While I still did not find out the reason what exactly caused the error when saving the image, I found a workaround to apply: const string i1Path = @”c:\my\i1.jpg”; const string i2Path = @”c:\my\i2.jpg”; var i = Image.FromFile(i1Path); var i2 = new Bitmap(i); i2.Save(i2Path, ImageFormat.Jpeg); I.e. by copying the image internally into a Bitmap instance … Read more

Rendering controls on glass: Solution found, needs double-buffering/perfecting

Here is a version with much less flickering, still not perfect though. public class GlassControlRenderer : NativeWindow { private Control Control; private Bitmap Bitmap; private Graphics ControlGraphics; private object Lock = new object(); protected override void WndProc(ref Message m) { switch (m.Msg) { case 0x14: // WM_ERASEBKGND this.CustomPaint(); break; case 0x0F: // WM_PAINT case 0x85: … Read more

How to find the actual printable area? (PrintDocument)

Your question lacks a little clarity as to what the “best” rectangle is. I’m going to assume you mean the largest rectangle that will be 100% visible when printed. So lets start by making sure we understand what the print document graphics object “origins” are and how the OriginAtMargins property affects this origin. OriginAtMargins – … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)