blinc_image
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
Image loading and rendering for Blinc UI.
Overview
blinc_image provides image loading, decoding, and rendering utilities for the Blinc UI framework.
Features
- Multiple Sources: Load from files, URLs, and base64 data
- Format Support: PNG, JPEG, GIF, WebP, BMP
- Object Fit: CSS-style object-fit options
- Image Filters: Grayscale, sepia, brightness, contrast, blur
- Async Loading: Non-blocking URL loading (with
networkfeature) - Platform Assets: Load from app bundles
Quick Start
use ;
// Load from file
let image = load?;
// Load from URL (async)
let image = load_url.await?;
// Load from base64
let image = load_base64?;
Object Fit
use ObjectFit;
// CSS object-fit equivalent
Cover // Fill container, crop if needed
Contain // Fit within container, letterbox
Fill // Stretch to fill (ignores aspect ratio)
ScaleDown // Scale down only if larger
None // No scaling, original size
Object Position
use ObjectPosition;
// CSS object-position equivalent
CENTER // Center (default)
TOP_LEFT // Align to top-left
BOTTOM_RIGHT // Align to bottom-right
new // Custom position (0-1 range)
Image Filters
use ImageFilter;
let filter = new
.grayscale // 0-1 (0 = none, 1 = full)
.sepia // 0-1
.brightness // 1 = normal, >1 = brighter
.contrast // 1 = normal, >1 = more contrast
.saturate // 1 = normal, >1 = more saturated
.blur; // Blur radius in pixels
Usage in Layout
use *;
// Basic image
img
.size
// With object-fit
img
.size
.cover // ObjectFit::Cover
.rounded
// Lazy loading
img
.lazy
.placeholder_color
// With border
img
.size
.circular
.border
// With filters
img
.grayscale
.blur
Supported Formats
| Format | Extension | Notes |
|---|---|---|
| PNG | .png |
Full support including transparency |
| JPEG | .jpg, .jpeg |
Standard JPEG |
| GIF | .gif |
Static only (no animation) |
| WebP | .webp |
Lossy and lossless |
| BMP | .bmp |
Basic support |
License
MIT OR Apache-2.0