Supporting HiDPI programmatically (no UIDescription)

Hi Federico,
CBitmap already supports HiDPI rendering. You only have to set it up to know about the bitmaps for the different scale factors. To do so, you have to create IPlatformBitmaps yourself set the scale factor accordingly and add it to the CBitmap instance.
For example, you have 2 bitmaps:

    • b1.png (for scale factor 1)
  • b2.png (for scale factor 2)

Then you can do:

auto bitmap = makeOwned<CBitmap> (CResourceDescription ("b1.png"));
auto tmp = makeOwned<CBitmap> (CResourceDescription ("b2.png"));
if (auto platformBitmap = tmp->getPlatformBitmap ())
{
  platformBitmap->setScaleFactor (2.);
  bitmap->addBitmap (platformBitmap);
}

now the bitmap variable has 2 images set and will use b2.png when rendering on a screen with a scale factor of 2.

You can also register for scale factor changes via the IScaleFactorChangedListener interface on the CFrame instance and you can also ask the CFrame instance of the current scale factor with CFrame::getScaleFactor().

I hope this helps.

Cheers,
Arne