auto copy and convert icons for release

Rich

Active Member
3rd Party Module Dev
Joined
Sep 9, 2017
Hello
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. http://www.imagemagick.org/

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
Code:
        ' 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 )
                End
                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 )
                End
                i+=1
            Wend
        End
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