Force the graphic to load in @2x mode

Hi everybody,

How can I force my plugin to load the @2x graphics? It doesn’t look sharp enough when resized with the regular size images.

Any light on the issue will be appreciated.

The “sharpness” of the image depends on the video monitor resolution (ppi). High resolution monitors will load the @2x images (if available). Standard definition monitors will load the 1x images.

If you somehow “force” load the @2x graphics when the system doesn’t call for it the image will be drawn 2x larger, not sharper.

Now, that said, I have found a couple of tricks in iPlug2:

  1. IME, NanoVG draws sharper bitmap images than SKIA - especially when resized >1
  2. I load only @2x pngs in my projects which forces the system to downsample for standard definition monitors. This seems to make the images sharper when resized upward on standard def monitors (because we’re resizing up toward it’s source size rather than bigger than source size). This “trick” doesn’t help on high def monitors where @2x, I believe, at least for now, is the best we can do.

For the sharpest images on all monitors use Vector graphics wherever possible.

Thanks for your answer.

How do you load the @x2 only?

in config.h
#define PNGBACKGROUND_FN “bg.png” //Just coment out this line?
#define PNGBACKGROUND_2X_FN “bg@2x.png”

in main.rc

in MyPlug.cpp
const IBitmap backgroundBitmap = pGraphics->LoadBitmap(PNGBACKGROUND_FN); //Should I change that to PNGBACKGROUND_2X_FN?

Thanks again.

The magic combination - that seems to work properly in all formats (VST, VST3, AAX and AU) on both Mac and PC - is:

  1. in config.h - list BOTH the 1x and 2x file names
    #define PNGBACKGROUND_FN “bg.png”
    #define PNGBACKGROUND_2X_FN “bg@2x.png”

  2. in main.rc - list ONLY the 2x file names

  3. in MyPlug.cpp - use the 1x resource name
    const IBitmap backgroundBitmap = pGraphics->LoadBitmap(PNGBACKGROUND_FN);

  4. place ONLY the @2x.png files in the project “resources/img” folder

  5. use the 1x size when setting PLUG_WIDTH and PLUG_HEIGHT in config.h and all control x/y locations in mLayoutFunc.

This approach forces the plugin to load the @2x files for every situation. The advantage is that 1) we only need to create 1 set of bitmap files (the 2x ones) and 2) bitmaps render somewhat sharper on standard def monitors.

I design all my plugin backgrounds and IBitmap controls at 2x size and then simply export a 50% version to find the 1x coordinates for the controls, PLUG_HEIGHT/WIDTH, etc.

This is working for me everywhere I have tested it but if anyone knows of any potential issues please advise.

1 Like

Thank you for for all the info, that’s exactly what I was looking for. Works great.

1 Like