Skip to main content

Overview

ImageGlass is built using a modular architecture with multiple components that work together to provide a fast and lightweight image viewing experience. The application is built on .NET 10 and uses Windows Forms for the UI framework.

Component Architecture

ImageGlass is organized into the following main components:

Core Components

ImageGlass (Main Application)

Location: Source/ImageGlass/ Purpose: The main executable and entry point for the application. Key Responsibilities:
  • Application initialization and lifecycle management
  • Main window (FrmMain) and UI orchestration
  • Event handling and user interactions
  • Integration of all components
Key Files:
  • FrmMain/ - Main window implementation
  • ImageGlass.csproj - Project configuration
  • app.manifest - Application manifest for Windows
Dependencies:

ImageGlass.Base

Location: Source/Components/ImageGlass.Base/ Purpose: Core functionality and utilities used across all components. Directory Structure:
Key Classes:
  • App.cs - Application-level utilities and constants
  • BHelper/Extensions/ - Extension methods for Bitmap, Color, Control, etc.
  • Types/Const.cs - Application constants
  • Types/Enums.cs - Common enumerations
Example - Extension Methods:
Source/Components/ImageGlass.Base/BHelper/Extensions/BitmapExtensions.cs
Major Dependencies:
  • Magick.NET (ImageMagick for .NET) - Image processing
  • Microsoft.Web.WebView2 - Embedded browser control
  • PhotoSauce.MagicScaler - High-performance image scaling
  • DirectNStandard - Direct2D and DirectX interop
  • WicNet - Windows Imaging Component
  • Microsoft.Windows.CsWin32 - Windows API source generation

ImageGlass.UI

Location: Source/Components/ImageGlass.UI/ Purpose: Custom UI controls and components. Key Features:
  • Modern UI controls with custom styling
  • Theme support and visual customization
  • Reusable UI components
Key Components:
  • Custom labels and buttons
  • Modern link labels
  • Toolbar components
  • Dialog and form bases
Dependencies:

ImageGlass.Viewer

Location: Source/Components/ImageGlass.Views/ Purpose: The core image viewing canvas with rendering capabilities. Key Files:
  • ViewerCanvas.cs - Main image viewer control
  • ViewerCanvas_Touch.cs - Touch input handling
  • ViewerCanvas_Webview2.cs - WebView2 integration for web content
  • SelectionResizer.cs - Image selection and cropping
  • VHelper.cs - Viewer helper utilities
Features:
  • Hardware-accelerated rendering
  • Zoom and pan functionality
  • Touch and gesture support
  • Selection and cropping tools
  • WebView2 integration for SVG, HTML, and other web formats
Dependencies:
Location: Source/Components/ImageGlass.Gallery/ Purpose: Thumbnail gallery and image list management. Directory Structure:
Key Features:
  • Efficient thumbnail generation and caching
  • Virtual scrolling for large image collections
  • Background thumbnail loading
  • Memory-efficient rendering
Dependencies:

ImageGlass.Settings

Location: Source/Components/ImageGlass.Settings/ Purpose: Application settings and configuration management. Directory Structure:
Key Features:
  • JSON-based configuration storage
  • Settings validation and migration
  • Settings dialog forms
  • Tool and external app configuration
Dependencies:

ImageGlass.WebP

Location: Source/Components/ImageGlass.WebP/ Purpose: Native WebP image format support. Key Features:
  • WebP decoding and encoding
  • Integration with libwebp
  • Optimized performance for WebP images
Dependencies:

ImageGlass.WinTouch

Location: Source/Components/ImageGlass.WinTouch/ Purpose: Windows touch and gesture input handling. Key Features:
  • Multi-touch gesture recognition
  • Touch-optimized interactions
  • Windows Ink support

igcmd (Command-Line Utility)

Location: Source/igcmd/ Purpose: Command-line interface for ImageGlass operations. Key Features:
  • Batch image operations
  • Automation and scripting support
  • Integration with shell scripts
Dependencies:

Data Flow

Image Loading Pipeline

  1. File System (ImageGlass.Base) - Detects and lists image files
  2. Image Loading (ImageGlass.Base) - Loads image data using appropriate codec
  3. Processing (ImageGlass.Base) - Applies transformations, color management
  4. Rendering (ImageGlass.Viewer) - Renders to the viewer canvas
  5. Display (ImageGlass Main) - Shows in the main window

Settings Management

  1. Configuration Files (JSON) - Stored in user profile
  2. Settings Service (ImageGlass.Settings) - Loads and validates settings
  3. UI Binding (ImageGlass.UI) - Reflects settings in the interface
  4. Change Notification (Events) - Updates all components when settings change

Performance Considerations

Unsafe Code

ImageGlass uses unsafe code blocks for performance-critical operations:
  • Direct pixel manipulation in BitmapExtensions
  • Memory-efficient image processing
  • Hardware-accelerated rendering

Hardware Acceleration

The viewer component uses:
  • Direct2D - GPU-accelerated 2D rendering
  • DirectX - Hardware acceleration for transforms
  • WIC (Windows Imaging Component) - Native image decoding

Memory Management

  • Image Caching - Configurable cache for recently viewed images
  • Thumbnail Cache - Separate cache for gallery thumbnails
  • Lazy Loading - Images loaded on-demand
  • Proper Disposal - IDisposableAnalyzers ensures resource cleanup

Threading Model

  • UI Thread - Main window and user interactions
  • Background Workers (QueuedWorker) - Image loading and processing
  • Thumbnail Generator - Separate thread for gallery thumbnails
  • File Watcher - Monitors directory changes asynchronously

Platform-Specific Features

x64 vs ARM64

ImageGlass supports both x64 and ARM64 platforms with platform-specific dependencies:

Windows 10/11 APIs

Targets net10.0-windows10.0.17763.0 (Windows 10 version 1809+):
  • Modern Windows APIs
  • WebView2 integration
  • Touch and pen input
  • Windows Imaging Component (WIC)

Next Steps