0

I need to change the image size based on DPI scaling. In my project, i'm using "ToolStripDropDownItem" with images. I'm having different size images for 100DPI and 175 DPI. In 100 DPI (12 * 12 image is using), its working fine.

In 175 DPI, i'm setting another size (24*24)image, its not working fine. It displays as shown in below image. Actually its not original image i think. ToolStrip automatically scaling the image from 100 DPI i think (I don't want it).

Is there any possibility to change the images based on DPI factor?

        topBorderToolStripMenu.ImageAlign = ContentAlignment.MiddleLeft;

        topBorderToolStripMenu.ImageScaling = ToolStripItemImageScaling.None;
        topBorderToolStripMenu.Size = new Size(225,25);
        topBorderToolStripMenu.AutoSize = false;

Please find the issue snap shot

ToolStripImage

  • Normally the constrols should be DPI-unaware (use the same size everywhere) and let the environment resize your controls. DPI awareness for WinForms can be adjusted in `app.settings` in newer framework versions: https://learn.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms – György Kőszeg Nov 19 '18 at 10:31
  • Devices don't have a "100dpi" or "200dpi" setting. Surely the unit is %, not dpi. 100% is 96 dots per inch. Bitmaps record the DPI of the device when they are created. For a photo it is based on the camera, for a bitmap that is created with a painting program it is based on the video adapter setting. At runtime the image is rescaled to ensure it gets the correct physical size. Go back to your painting program and correct the DPI of those 24x24 images. And ensure you program is dpiAware or they get rescaled twice. – Hans Passant Nov 19 '18 at 10:37
  • @taffer I have enabled DPI aware using application manifest file in my project. – keerthi vasan Nov 19 '18 at 10:55
  • I have edited the content for better understand. Please refer it and let me know your ideas. – keerthi vasan Nov 19 '18 at 13:59

0 Answers0