In the visual asset files for a Windows Universal App what does scale-240 signify? - visual-studio-2013

When I make a new Universal App in Visual Studio 2013 I get a number of graphics files for the logos, splash screens, etc. in the Assets folder, for example Square71x71Logo.scale-240.png. The Package.appxmanifest then maps these files to the various required things. For example Square71x71Logo.scale-240.png is mapped in Package.appxmanifest to Square 71x71 Logo.
The actual file is 170 pixels wide, 170 pixels high, Photoshop reads it as having 72 pixels per inch, and it has an 8 bit colour depth.
What does the .scale-240 part of the file name signify?
I'm replacing the file and I am not sure how to scale-240-ify the new image.

The scale-240 part of the file name is a resource qualifier that indicates that the file is used for 240% DPI systems.
Resource qualifiers allow the app to provide different versions of the same resource for different scenarios and refer them all internally by the base name:
Scaling for different DPI systems: .scale-100, .scale-140, .scale-180, .scale-240
Language (if the image has text in it): .lang-de-DE, .lang-en-us
Contrast (to simplify for high contrast modes): .contrast-high, .contrast-standard
Layout direction (if the image should be different in LTR vs RTL language settings): .layoutdir-RTL, .layoutdir-LTR
DirectX feature level: .DXFL-DX9, .DXFL-DX11
The app can reference the image by its base name (e.g. logo.png) and the version which best matches the current scale, contrast level, language, etc. will be automatically used.
The default phone template provides scale-240 images since high-DPI phones are fairly common and it is generally better to scale down from a larger image than to scale up a small image. Best would be for you to provide multiple resolutions when you replace the stock ones with your own, especially if your images are complicated and don't scale well by default.
See How to name resources using qualifiers (XAML)

Universal apps need to be able to run on very different screens. You cannot predict up front what kind of device the user might have. Big difference if he has a cheap contract phone, an expensive slate or a desktop machine. WinRT helps by automatically scaling your app to match the screen resolution.
Supported scaling percentages for a desktop/slate app are 80, 100, 140 or 180%. For a phone it is 100, 140 or 240%.
Text can auto-scale easily but images do not. They get blurry when they get rescaled, a single pixel in the image no longer coincides with a single screen pixel. Pretty noticeable when the image contains fine line art or text. Scaling down necessarily loses pixels, details may disappear.
So the Visual Assets tab of the manifest editor allows you to select multiple images, each suitable for a specific scaling percentage. You found the -240 version in your phone project's Assets directory, the 240% scaling version that were auto-generated when you created the project. The desktop version has -100 assets by default, 100% scaling.
You may want to add your own. You don't have to.

.scale-xxx appears to refer to pre-scaled image resources.
If you are using a an image logo.png with size 100x100px then logo.scale-240.png should be an image of size 240x240px, i.e. scaled by a factor of 240 percent. The idea behind this concept is apparently to avoid potentially expensive and inaccurate rescaling by the displaying device, by supplying several prescaled images at defined scales.
In your case: 170px / 2.40 = ~71px
See also the corresponding MSDN article. (The linked article is in German, I will leave it to the interested reader to find the matching English one ;-)

Related

How to set DPI scale to less than 100% on Windows 10 - With multiple displays

So I have a big 32 inch display with a resolution of 1440p, and I want to set the DPI scaling to 75% instead of 100%. But I can't find any way to do so on multiple monitors.
I currently have:
Display 1 [2560 x 1440] (Main display I want to change)
Display 2 [2560 x 1440] (This one is 27 inches so it's fine as is)
Display 3 [3840 x 2160] (Set to 100%, fine as it is)
This trick (click me) changes DPI scaling via some registry keys (LogPixels & Win8DpiScaling), but when I use that trick it downscales display 3 instead of display 1.
Is there a way to get this to work? I see no reason for Microsoft to limit the scaling in displays.
Note: I have a 2070 super, all the displays are plugged into the GPU via displayport directly, with the latest avalible firmware at the time of writing (september 2021)
The tl;dr:
Technical limitations aside, there are very solid user experience reasons why this probably isn't allowed.
No, Windows will not let you set UI scaling below 100%.
(even if a stable workaround were to be discovered, most users would probably be quite unhappy with the results)
While I would love¹ to be proven incorrect, the implications of scaling at less than 100% are so fraught that this limitation is unlikely to change in the near future.
Background:
This has been the case for ages, likely since Windows first introduced the feature.
Compatibility with current software
The only ~purely technical~ reason I can think of:
The 100% scaling size likely uses the smallest base image (e.g. Explorer and Taskbar icons, mouse and text cursors) resources included in various existing Microsoft and 3rd-party applications.
User experience
Going below the 100% point may cause small UI text and icons, especially in application toolbars and the Taskbar to be blurred to the point of ambiguity.
Those fine lines in the taskbar 'Windows' menu icon? Blurred or gone.
Taken to the extreme, the UI ~might~ become so unreadable that the user is effectively prevented from being able to read the text even in the 'Settings' window and therefore is 'stuck': i.e. not able to navigate through 'Settings' to restore the original '100%' scaling mode.
(Luckily, Windows is never used to run any SCADA software where confusing two icons could theoretically cost money or lives.)
Performance:
Since those carefully-designed graphic assets don't exist, if sub-100% scaling were allowed, it would also likely cause extra CPU/GPU workload - that is why only certain fixed sizes of up-sampling are shown on the normal Display settings screen and why the Advanced scaling settings screen warns that custom scaling between 100-500% is "not recommended".
That might also apply to any fixed scaling option offered below 100%, and absolutely would for custom scaling sizes.
Some people enjoy reading:
Vector-based TrueType/OpenType fonts usually contain a ~lot~ of manual tweaking / hints to enable readable display of very small point sizes.
The marketing department & friends of the C-suite
Could they implement this at a limited range of options? 90%? 75%?
Perhaps - but it's extra testing for a horrible-looking edge case.
The existence of the option, even if only available as a registry hack, might cause some people to actually use it in kiosks and other public-facing displays; this risks the same sort of bad PR as when a BSOD is seen on the 'arrivals' screen at a train station or airport monitor.
Combined with the first example below, even a 90% option could cause trouble in some environments.
Example and tutorial:
Imagine how Windows might look displayed on one of those cheapo '1080p-supported' projectors that actually only contains an imager with a native pixel resolution of, say, 1024x576 (or even 480x234).
Windows thinks it can send 1080p, since that what the HDMI connection advertises, so it does: any text / vector content looks atrocious.
(At least in this case the user could normally² unplug the projector and reconnect to a normal monitor to restore functionality.)
See for yourself... while connected to any monitor (at that monitor's native resolution), with Windows set to 100% scaling:
Open Windows Notepad
Type or paste in any block of text
Now, use the Zoom Out command from the View menu³ five or more times in a row
While not an exact analogue, you may still see how hard it could be to read down-sampled text, even when very high-contrast (the best-case scenario).
   ¹: As someone currently typing this very answer on a 1080p connection to a 55" 4K television as a second monitor, I came across the question very much hoping this was possible. Sadly, logic intervened and killed my potential joy.
   ²: Unless the computer is actually stored somewhere locked or inaccessible, such as a NUC-style PC hidden above the false ceiling in a conference room.
   ³: Alternatively, press <CTRL>-<Minus> five or more times.

Get Windows 10 Jump List pin button icons

Windows 10 has new pin icons in the Jump List. Black and white for different themes.
Old Windows 7 pin icons stayed inside imageres.dll, ID 5100, 5101.
Where are new icons stored? How get they with WinAPI?
Icons have traditionally been raster images. The benefit of raster images is, that they are blazingly fast to render. That speed comes with a downside, namely that raster images only look good at a narrow range of pixel densities. That was great for as long as most displays had a pixel density of 96 PPI (pixels per inch). With pixel densities increasing, raster images stopped being as useful as they used to be. On high-density displays, icons would either render too small, or had to be scaled up with all sorts of visual artifacts.
To address this, Windows 8 introduced font-based icons as the Windows UI Symbol font, that was superseded in Windows 10 by the Segoe MDL2 Assets font. Fonts are vector-based, and can be scaled across a wide range without (or very little) visual artifacts.
While I have not verified, whether the Windows Shell actually does use font icons, the icons you are looking for are available in the Segoe MDL2 Assets font with Unicode code points in the private use area:
U+E718 ("Pin")
U+E77A ("Unpin")
Since Windows 10 version 1903, icon resource files have been relocated to: C:\Windows\SystemResources\imageres.dll.mun
There is now a new extension for these files .mun instead of .mui (which still exist in system32 and syswow64 sub folders.
Also see the answer to the question Can I trust imageres.dll system icons indexes?:
The correct way to get the icons is to use SHGetStockIconInfo. It will tell you where the icon is in the current version of Windows.
If you want the system's current folder icons (which may not be the standard ones due to user customization), use SHGetFileInfo.

What sizes should be the images when loading from some CDN for Android

I'm creating an app for Android and I should load images from a CDN and I want to support all the possible screen sizes. How should be done?
Should be many different versions of the same image stored in the CDN in different folders? Or one only resolution can cover all the screen sizes if it has high resolution?
Also How I know the exact numberXnumber? how I can know that? I should try manually or there are guidelines?
For example if that helps I have an ImageView 100dpX100dp how I know how much should be the pixels?
Thanks
You should probably set up essentially the basic ranges that android uses, mdpi, hdpi, hdpi-x, hdpi-xx. So you would have low and medium resolution screens request cdn.com/mdpi/image.png, high resolution request cdn.com/hdpi/image.png and so on... You define the resolutions within each grouping, for example on hdpi-xx Your images may be 1920x1080, but on hdpi it is only 1280x720. Those are just examples pulled out of the air, but you can adjust to suit your needs.
You can even use the base android resource system to pull the correct url for each screensize.
i.e.
In the folder values-mdpi you put a string resource that will have the url with mdpi, and hdpi with the base url for hdpi, you get the idea.
For further information you the documentation here provides very clear examples and more detail.

display.newImage() vs display.newImageRect() in corona

What is the difference between display.newImage() and display.newImageRect()?
Which one is better to use?
The documentation of display.newImage() mentions specifically:
NOTE: display.newImageRect() should be used instead to load images
when dynamic content scaling is enabled.
And similarly, on display.newImageRect()
dispaly.newImageRect() automatically substitutes higher-resolution
assets on higher-resolution devices. The actual image chosen will
depend on the current content scale determined by Corona, which is the
ratio between the current screen and the base content dimensions
defined in config.lua.
Based on this scale, Corona uses the
imageSuffix table (also defined in config.lua), which lists the
suffixes for the same family of images, to find the best match from
the image choices available.

How to change the Icon of a MFC-Application without changing each sub-image?

when I open the application icon of a MFC-project with Visual Studio 2008 there are 13 images (different sizes, different color palette). How would you change the icon of your MFC-application without changing each image?
Thanks!
I like to use the Icons file type extension with Paint.NET. When you open a .ICO file it will prompt you for which image to open - select only the largest / highest-bit image. Make your changes, and then save. You will be prompted for which sizes and bitness to save - select the same list that was present in the original icon.
Using this method, you will get automatically scaled and dithered icons at the smaller sizes. A designer would actually tweak the icons at each size to get the best look, but for most applications this technique produces something that is usable.
An icon resource typically contains many different versions of an icon. For an application icon you would expect 16x16, 32x32, 48x48 and 256x256. You'd also expect to see the 3 smaller ones at 32 bit colour, 8 bit colour 4 bit colour. Or some variant on that. Microsoft publishes guidelines.
Why so many different versions of the same icon?
Well, the icon will be drawn in different settings. On a window caption bar, the 16px version will typically be shown. On the Windows 7 taskbar the 48px version will be shown. When usint ALT+TAB in XP the 32px will be shown. In Vista/7 explorer with ultra large icon view, the 256px will be shown.
To obtain the best visual appearance you must have different versions of the image for different sizes because small raster images aren't easy to scale. What's more, you may present a slightly different version of the icon at different resolutions. For example you may use 3D effects only on larger resolution, partial transparency versions.
When using remote desktop, lower colour depths may be used if the connection is bandwidth challenged.
The MS guidelines go into these issues in detail.
The normal practice of for the graphic designer to design the icon and once you are happy with it the designer will produce rasterised versions for all the required sizes and colour depths, typically in a single .ico file.

Resources