How to set a custom icon - daniel-tran/snake-boxer-collection GitHub Wiki

Windows only

Run the following code in the setup function, under the assumption that the icon name is called icon.png and is stored in the "data" folder:

surface.setIcon(loadImage("icon.png"));

Note that:

  • This only changes the application icon when running, and not the desktop icon.
  • Keeping this line in the sketch means it can't be compiled for Android, unless manually removed.

Android only

This is documented on this Processing Forum post, and involves the following steps:

  • Add the following files into the same folder as the main .pde file (image dimensions are based on the sizes on this page of Android documentation):
    • icon-36.png
    • icon-48.png
    • icon-72.png
    • icon-96.png
    • icon-144.png
    • icon-192.png
  • Build the sketch for Android, which should now use the icon on your device.

If redeploying, you might need to uninstall the sketch manually from your device to have the icon appear correctly.

Windows and Android

Currently, there is no single way to add a custom icon for both Windows and Android

As a potential workaround, you can:

  • Implement the image files for Android.
  • Use rcedit or other means to modify the desktop icon of the Windows executable.
  • (Optional) Use surface.setIcon only when exporting for Windows. This can be skipped if you don't expect multiple Processing sketches to be running at once, or simply don't care about using the same icon for both the running application and the executable file.