我需要制作多少尺寸的ImageList图标

我需要制作多少尺寸的ImageList图标

本文介绍了我需要制作多少尺寸的ImageList图标?为我的应用加载(考虑更高的DPI)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个。因此,我一直在寻找一种动态的方法来确定CListCtrl的图像列表的合适大小。



还有问题的第一部分,我应该使图标大小为多少



编辑
PS:既然出现了DPI缩放比例,您如何找到它?我当前正在使用以下方法:

  //为简洁起见,没有错误处理
HDC hDC = :: GetDC (hAppsMainWindowHandle);
int nCx = :: GetDeviceCaps(hDC,LOGPIXELSX);
int nCy = :: GetDeviceCaps(hDC,LOGPIXELSY);
:: ReleaseDC(hAppsMainWindowHandle,hDC);

//从技术上讲,我得到了水平&垂直缩放-
//可以不同吗?
double scaleCx =(double)nCx / 96.0; //1.0 = 100%
double scaleCy =(double)nCy / 96.0;

字体缩放是否有所不同?

解决方案

列表视图根据其模式使用小或大图像列表。在报告模式下,它使用小图像列表。您可以使用使用 SM_CXSMICON SM_CYSMICON 指标来获取小图像的尺寸(将 SM_CXICON SM_CYICON 用于大图像)。



请注意,如果您的应用程序不支持DPI,则返回的值将是虚拟的/缩放的,因此要获取准确的值,请通过,或DPI



更新:我刚刚遇到了此功能,在编写支持DPI的应用程序时可能对您有用:





制作更大的图像并让API将它们缩小为更小的尺寸。


I have a CListCtrl control (or a ListView in Win32) that is created with LVS_REPORT style.

I am intending to display icons in its items as such:

But the question is what size of icons do I need to make and load?

Let me explain. From the old Win32 samples, I can see that everyone creates image lists with 15x15 pixel icons. But the issue with those is that it looks horribly pixelated on any modern PC with higher DPI settings. Thus I was looking for a dynamic way to determine the appropriate size of image lists for the CListCtrl.

And also the first part of the question, what icon size should I make originally?

EDITPS: Since DPI scaling came up, how do you find it out? I'm currently using the following approach:

//No error handling for brevity
HDC hDC = ::GetDC(hAppsMainWindowHandle);
int nCx = ::GetDeviceCaps(hDC, LOGPIXELSX);
int nCy = ::GetDeviceCaps(hDC, LOGPIXELSY);
::ReleaseDC(hAppsMainWindowHandle, hDC);

//I technically get horizontal & vertical scaling --
//can those be different?
double scalingCx = (double)nCx / 96.0;  //1.0 = 100%
double scalingCy = (double)nCy / 96.0;

Is font scaling something different?

解决方案

A list view uses a "small" or "large" image list depending on its mode. In report mode, it uses the "small" image list. You can use GetSystemMetrics() to get the dimensions of "small" images using the SM_CXSMICON and SM_CYSMICON metrics (use SM_CXICON and SM_CYICON for "large" images).

Note that the returned values will be virtual/scaled if your app is not DPI-aware, so to get accurate values, make sure it is DPI-aware via SetProcessDPIAware(), SetProcessDpiAwareness(), or a DPI manifest.

Update: I just ran across this function, might be useful for you when writing a DPI-aware app:

LoadIconWithScaleDown()

Make larger images and let the API scale them down to smaller sizes.

这篇关于我需要制作多少尺寸的ImageList图标?为我的应用加载(考虑更高的DPI)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 14:28