Image Asset Optimization - davidortinau/ControlGallery GitHub Wiki

๐Ÿ’ฌ Copilot Chat Prompt

Audit my .NET MAUI appโ€™s image usage. Look for oversized images, bitmaps loaded at runtime instead of using ImageSource, and missing UriImageSource caching. Suggest resizing strategies and use of SVGs where appropriate.

Improper image usage can lead to high memory usage and laggy UI.

๐Ÿ” What to Look For

  • Images that are larger than their display size
  • Bitmaps not cached and loaded repeatedly
  • Use of bitmap formats for icons instead of SVGs

โœ… Fix Examples

  • Provide downsampled images matched to display size (donโ€™t display a 2000px-wide image at 100px)
  • Enable caching on remote images:
    new UriImageSource
    {
        Uri = new Uri("https://example.com/image.jpg"),
        CachingEnabled = true,
        CacheValidity = TimeSpan.FromDays(7)
    }
    
  • Use SVG or vector icons when supported (e.g., via SvgImageSource or a custom handler)
  • Remove unused image assets from the Resources/Images folder to reduce app size

๐Ÿ“š Additional Resources


โžก๏ธ Next: Optimize Startup Performance