2

For a Mac/iOS application to support retina/high fidelity screens, additional double-resolution bitmap images need to be included with "@2x" just before the file extension. E.g.:

logo.png    (32x32)
logo@2x.png (64x64)

In code we only need to refer to the original base name (minus the file extension). E.g.:

imageView.image = [NSImage imageNamed:@"logo"];

CSS does something very similar of course.

I have all of these same image assets included in the corresponding WPF project for Windows.

When I include them in the application resources file (.resx) the '@' becomes '_'.

That's fine I guess, but what now?

I have googled everything I can think of (against site:learn.microsoft.com) but none of the docs I can find talk about this type of thing. There's a lot of talk about high fidelity/res/dpi screens, but I don't see anything about this bitmap auto-substitution concept.

I don't have a retina display handy for testing and the place I'm contracting for doesn't have any QA engineers. The people who casually test the app (manager + a couple other EE/firmware devs) don't either, so I need to be certain I'm setting up the WPF port of this app correctly since I can't verify... at least for the next few weeks.

Clemens
  • 123,504
  • 12
  • 155
  • 268
Greg
  • 143
  • 1
  • 7
  • 1
    WPF does not support this feature. – Clemens Aug 29 '19 at 17:53
  • @Clemens, the documentation is pretty clear that retina/hires awareness is available in WPF. Part of that has to be a way to substitute double-res graphics for their low-res counterparts at runtime. Are you saying that it doesn't do this or are that it does it but differently or that it's the same but it's not automatic? – Greg Aug 29 '19 at 18:59
  • 1
    You're confusing things. Of course WPF supports high res screens by its DPI awareness. There is still no mechanism to automatically use different bitmap resources for different resolutions. You'd use a single bitmap for all resolutions. You can try out how it behaves if you change the DPI setting of your system. – Clemens Aug 29 '19 at 19:14
  • @Clemens, so assuming you're correct that there is no **automatic** image substitution mechanism in WPF, and assuming I have valid reasons for not wanting to scale-down a 2x bitmap in 1x scenarios, how can I check at runtime to see if I'm on a HiDPI screen so that I can do the swap myself? if ( highres ) // <<<<< this check would be the part i'd be interested in for manual swap methodology { BackgroundImage = global::XYZ.Properties.Resources.Background_2x; } else { BackgroundImage = global::XYZ.Properties.Resources.Background; } – Greg Aug 29 '19 at 19:40
  • 1
    @Clemens, the original/actual question here is in no way a duplicate of that other question. Only the tangent you and I are on is leading in that direction. Please retract the duplicate flag. I'm still holding out for other takes on the original question. – Greg Aug 29 '19 at 20:23
  • I don't get which part of "there is no such feature" you're having problems with. Manually switching between different resources is all you can do. – Clemens Aug 29 '19 at 21:15
  • I'm not convinced that's correct. I prefer to give the question a little more time for other people to weigh in. – Greg Aug 29 '19 at 22:32
  • Unbelievable. Thanks a lot, @Clemens. – Greg Aug 30 '19 at 14:58

1 Answers1

-1

Convert your PNGs to vector graphics and it will look perfect everywhere.

pindumb
  • 30
  • 8
  • assuming you mean "redesign/as" rather than "convert/to", I agree that vector graphics are ideal for a lot of situations, but not all situations. Also I'm not the designer. He's more of a brush guy than a bezier path guy TBH. Also keep in mind that the question is about how **bitmap** graphics are handled in WPF in HiDPI scenarios. So even though redesigning everything as vector graphics is a viable alternative, the fact remains that WPF obviously has **some** way to handle bitmap images in HiDPI situations and I want to know what that is. – Greg Aug 29 '19 at 19:17