cancel
Showing results for 
Search instead for 
Did you mean: 

how to remove unused graphic not referred in screens..

andrea venturi
Associate III

hi,

slowly slowly i've got my growing TouchGFX project to become too fat for the2MB flash on a STM32F429..

as i've put too much graphic assets on the "database" and i'm not using all of them in the screens, i'm wondering if there's a way to find out "programmatically" which assets are not really referenced.. ( i know which "few" icons i put up with a routine..)

i only found this thread, 4 year old, that's really shows a manual procedure (and tedious..) ��

https://touchgfx.zendesk.com/hc/en-us/community/posts/207462585-Removing-unused-bitmap

thanx for hints!

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

There's no "tool" to do this if you're having a hard time getting an overview of unused assets, but if i have time i could write a script for you. Should be easy to do if you want to do it yourself. Hints:

  1. BitmapDatabase.hpp (generated in generated/images/include) contains all the bitmap ids
  2. Transform filenames (assets/images/) into IDs (e.g. BITMAP_BLUE_BACKGROUNDS_MAIN_BG_800X480PX_ID might be blue_backgrounds_main_bg_800x480px.png)
  3. Search all gui code (generated or otherwise) for references to the ids - If not found, add the filename to a list
  4. Delete all unused files contained in the list
  5. Re-generate assets (will clean up the bitmap database)
  6. Commit the removal of the assets from assets/images to your git repo

/Martin

View solution in original post

4 REPLIES 4
Martin KJELDSEN
Chief III

There's no "tool" to do this if you're having a hard time getting an overview of unused assets, but if i have time i could write a script for you. Should be easy to do if you want to do it yourself. Hints:

  1. BitmapDatabase.hpp (generated in generated/images/include) contains all the bitmap ids
  2. Transform filenames (assets/images/) into IDs (e.g. BITMAP_BLUE_BACKGROUNDS_MAIN_BG_800X480PX_ID might be blue_backgrounds_main_bg_800x480px.png)
  3. Search all gui code (generated or otherwise) for references to the ids - If not found, add the filename to a list
  4. Delete all unused files contained in the list
  5. Re-generate assets (will clean up the bitmap database)
  6. Commit the removal of the assets from assets/images to your git repo

/Martin

Martin KJELDSEN
Chief III

Here's some dirty Ruby-pseudo-code to get you started:

found = false
unused = []
 
pngs = Dir["assets/images/*.png"].collect {|a| "BITMAP_" + File.basename(a, ".png").upcase + "_ID" }
Dir["**/*View*.cpp"].each { |f| 
	pngs.each { |p|
	  found = true if File.open(f).grep(/p/) 
	}
 
	unused << p if !found
        found = false
}

andrea venturi
Associate III

than again Martin for the fast and constructive reply.. i'll try to make up something next days and report!

Sweet! Let me know how you do :)