auto copy and convert icons for release


Active Member
3rd Party Module Dev
Sep 9, 2017
Ive made some updates to my android.cxs part of transcc that will copy and convert 2 icons into the relevant release folders ready for compilation.
This only works cause I have ImageMagick installed.

If you place icon.png and icon_round.png in the root along with your project files, this will convert when compiled in release
These icons must be square to begin with. Mine are 512x512.

Added in android.cxs around line 160
        ' compile icons in release mode
        If tcc.opt_config = "release"
            Local sizes:=["48","72","96","144","192"]
            Local folders:=["mipmap-mdpi","mipmap-hdpi","mipmap-xhdpi","mipmap-xxhdpi","mipmap-xxxhdpi"]
            Local imagecmd:="magick"
            Local i=0
            While i<sizes.Length()
                If FileStream.Open("../../icon.png","r")
                    Local param:="convert ../../icon.png -resize "+sizes[i]+"x"+sizes[i]
                    Local iconfile:="app/src/main/res/"+folders[i]+"/ic_launcher.png"
                    Execute( imagecmd + " "+param + " "+iconfile )
                If FileStream.Open("../../icon_round.png","r")
                    Local param:="convert ../../icon_round.png -resize "+sizes[i]+"x"+sizes[i]
                    Local iconfile:="app/src/main/res/"+folders[i]+"/ic_launcher_round.png"
                    Execute( imagecmd + " "+param + " "+iconfile )
The code can probably be improved ;-)

This got me thinking about trying to write a simple image convertor in CX, but CPP doesnt support mojo commands and will need to plug into libpng or something and adding relevant code for the other target CX files
(maybe a project for another time)
Last edited:
Top Bottom