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
FrmMain/- Main window implementationImageGlass.csproj- Project configurationapp.manifest- Application manifest for Windows
ImageGlass.Base
Location:Source/Components/ImageGlass.Base/
Purpose: Core functionality and utilities used across all components.
Directory Structure:
App.cs- Application-level utilities and constantsBHelper/Extensions/- Extension methods for Bitmap, Color, Control, etc.Types/Const.cs- Application constantsTypes/Enums.cs- Common enumerations
Source/Components/ImageGlass.Base/BHelper/Extensions/BitmapExtensions.cs
- 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
- Custom labels and buttons
- Modern link labels
- Toolbar components
- Dialog and form bases
ImageGlass.Viewer
Location:Source/Components/ImageGlass.Views/
Purpose: The core image viewing canvas with rendering capabilities.
Key Files:
ViewerCanvas.cs- Main image viewer controlViewerCanvas_Touch.cs- Touch input handlingViewerCanvas_Webview2.cs- WebView2 integration for web contentSelectionResizer.cs- Image selection and croppingVHelper.cs- Viewer helper utilities
- Hardware-accelerated rendering
- Zoom and pan functionality
- Touch and gesture support
- Selection and cropping tools
- WebView2 integration for SVG, HTML, and other web formats
ImageGlass.Gallery
Location:Source/Components/ImageGlass.Gallery/
Purpose: Thumbnail gallery and image list management.
Directory Structure:
- Efficient thumbnail generation and caching
- Virtual scrolling for large image collections
- Background thumbnail loading
- Memory-efficient rendering
ImageGlass.Settings
Location:Source/Components/ImageGlass.Settings/
Purpose: Application settings and configuration management.
Directory Structure:
- JSON-based configuration storage
- Settings validation and migration
- Settings dialog forms
- Tool and external app configuration
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
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
Data Flow
Image Loading Pipeline
- File System (ImageGlass.Base) - Detects and lists image files
- Image Loading (ImageGlass.Base) - Loads image data using appropriate codec
- Processing (ImageGlass.Base) - Applies transformations, color management
- Rendering (ImageGlass.Viewer) - Renders to the viewer canvas
- Display (ImageGlass Main) - Shows in the main window
Settings Management
- Configuration Files (JSON) - Stored in user profile
- Settings Service (ImageGlass.Settings) - Loads and validates settings
- UI Binding (ImageGlass.UI) - Reflects settings in the interface
- Change Notification (Events) - Updates all components when settings change
Performance Considerations
Unsafe Code
ImageGlass usesunsafe 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
Targetsnet10.0-windows10.0.17763.0 (Windows 10 version 1809+):
- Modern Windows APIs
- WebView2 integration
- Touch and pen input
- Windows Imaging Component (WIC)
Next Steps
- Getting Started - Set up your development environment
- Building from Source - Detailed build instructions
- Contributing Guide - Learn how to contribute