How to use the different size images based on current DPI scaling in ToolStripItem?











up vote
0
down vote

favorite












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










share|improve this question
























  • 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: docs.microsoft.com/en-us/dotnet/framework/winforms/…
    – taffer
    3 hours ago










  • 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
    3 hours ago










  • @taffer I have enabled DPI aware using application manifest file in my project.
    – keerthi vasan
    3 hours ago












  • I have edited the content for better understand. Please refer it and let me know your ideas.
    – keerthi vasan
    22 mins ago















up vote
0
down vote

favorite












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










share|improve this question
























  • 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: docs.microsoft.com/en-us/dotnet/framework/winforms/…
    – taffer
    3 hours ago










  • 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
    3 hours ago










  • @taffer I have enabled DPI aware using application manifest file in my project.
    – keerthi vasan
    3 hours ago












  • I have edited the content for better understand. Please refer it and let me know your ideas.
    – keerthi vasan
    22 mins ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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










share|improve this question















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







c# winforms dpi toolstrip toolstripdropdown






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 25 mins ago

























asked 5 hours ago









keerthi vasan

62




62












  • 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: docs.microsoft.com/en-us/dotnet/framework/winforms/…
    – taffer
    3 hours ago










  • 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
    3 hours ago










  • @taffer I have enabled DPI aware using application manifest file in my project.
    – keerthi vasan
    3 hours ago












  • I have edited the content for better understand. Please refer it and let me know your ideas.
    – keerthi vasan
    22 mins ago


















  • 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: docs.microsoft.com/en-us/dotnet/framework/winforms/…
    – taffer
    3 hours ago










  • 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
    3 hours ago










  • @taffer I have enabled DPI aware using application manifest file in my project.
    – keerthi vasan
    3 hours ago












  • I have edited the content for better understand. Please refer it and let me know your ideas.
    – keerthi vasan
    22 mins ago
















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: docs.microsoft.com/en-us/dotnet/framework/winforms/…
– taffer
3 hours ago




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: docs.microsoft.com/en-us/dotnet/framework/winforms/…
– taffer
3 hours ago












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
3 hours ago




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
3 hours ago












@taffer I have enabled DPI aware using application manifest file in my project.
– keerthi vasan
3 hours ago






@taffer I have enabled DPI aware using application manifest file in my project.
– keerthi vasan
3 hours ago














I have edited the content for better understand. Please refer it and let me know your ideas.
– keerthi vasan
22 mins ago




I have edited the content for better understand. Please refer it and let me know your ideas.
– keerthi vasan
22 mins ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371438%2fhow-to-use-the-different-size-images-based-on-current-dpi-scaling-in-toolstripit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371438%2fhow-to-use-the-different-size-images-based-on-current-dpi-scaling-in-toolstripit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]