j
No files matched your search
@@ -4,4 +4,6 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
eframe = { version = "0.37", default-features = false, features = ["default_fonts", "glow"] }
|
||||||
image = "0.24"
|
image = "0.24"
|
||||||
|
rfd = "0.18"
|
||||||
@@ -1,87 +1,28 @@
|
|||||||
# Media Viewer Application
|
# Media Viewer
|
||||||
|
|
||||||
A high-performance media viewer for Windows 11 using Rust.
|
A desktop image viewer for Windows, written in Rust. It opens a native window using eframe/egui; no browser or WebView is involved.
|
||||||
|
|
||||||
## Features
|
## Run
|
||||||
|
|
||||||
- Native Windows UI integration (no WebView components)
|
```powershell
|
||||||
- Support for common image formats: JPG, PNG, BMP, GIF, TIFF, WebP
|
|
||||||
- Keyboard navigation controls (arrow keys, zoom controls)
|
|
||||||
- Fullscreen mode capability
|
|
||||||
- File browsing functionality
|
|
||||||
- Modern Windows 11 styling patterns
|
|
||||||
|
|
||||||
## Implementation Status
|
|
||||||
|
|
||||||
This is a prototype implementation with the following characteristics:
|
|
||||||
|
|
||||||
### Core Functionality Implemented
|
|
||||||
- Media viewer configuration and state management
|
|
||||||
- Image metadata handling
|
|
||||||
- Navigation controls (previous/next images)
|
|
||||||
- Zoom functionality (in/out/reset)
|
|
||||||
- Fullscreen toggle capability
|
|
||||||
|
|
||||||
### Limitations of Current Implementation
|
|
||||||
1. **No actual image loading**: The code structure is present but does not actually load or display images
|
|
||||||
2. **No Windows API integration**: The application is a console-based prototype that demonstrates the architecture but lacks native UI elements
|
|
||||||
3. **No real file browsing**: File system integration is not implemented
|
|
||||||
|
|
||||||
### Architecture Components
|
|
||||||
|
|
||||||
The application follows a modular architecture:
|
|
||||||
|
|
||||||
1. **Core Viewer Logic**
|
|
||||||
- State Management
|
|
||||||
- Configuration
|
|
||||||
- Metadata Handling
|
|
||||||
|
|
||||||
2. **Image Processing**
|
|
||||||
- Format Support
|
|
||||||
- Loading & Rendering (prototype only)
|
|
||||||
- Optimization
|
|
||||||
|
|
||||||
3. **UI Framework**
|
|
||||||
- Windows Integration
|
|
||||||
- Native Controls
|
|
||||||
- Styling
|
|
||||||
|
|
||||||
4. **Navigation System**
|
|
||||||
- File Browsing
|
|
||||||
- Image Sequences
|
|
||||||
- Playback Controls
|
|
||||||
|
|
||||||
5. **Performance Features**
|
|
||||||
- Caching
|
|
||||||
- Memory Management
|
|
||||||
- Rendering Optimization
|
|
||||||
|
|
||||||
## Build Instructions
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cargo build
|
|
||||||
cargo run
|
cargo run
|
||||||
|
cargo run -- "C:\path\to\photo.jpg"
|
||||||
|
cargo run -- "C:\path\to\folder"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
To create an executable, run `cargo build --release`. The result is `target\release\media-viewer.exe`.
|
||||||
|
|
||||||
The application demonstrates the intended functionality through console output. To see a working media viewer, additional implementation would be required for:
|
## Use
|
||||||
|
|
||||||
1. Actual image loading capabilities with format support
|
- **Open image** or **Ctrl+O** selects an image. The viewer also finds other supported images in the same folder for navigation.
|
||||||
2. Windows UI components using winapi or other native UI crates
|
- **Open folder** loads the images in a folder, sorted by filename.
|
||||||
3. File browsing and selection functionality
|
- Drag and drop an image or folder into the window.
|
||||||
4. Real rendering of images in the application window
|
- **Left/Right** or the toolbar buttons move between images. Navigation wraps at either end.
|
||||||
5. Extension to support video and audio formats
|
- **+ / -** or the toolbar buttons change zoom; **Ctrl+mouse wheel** also zooms. **0** or **Fit** fits the image in the window.
|
||||||
|
- **F11** toggles fullscreen; **Esc** exits it.
|
||||||
|
- **Play slides** advances through the folder every three seconds; **Pause slides** stops it.
|
||||||
|
- Animated GIFs play at their embedded frame timing. Use **Pause GIF** or **Play GIF** to control them independently of the folder slideshow.
|
||||||
|
|
||||||
## Future Enhancements
|
Supported image types: JPEG, PNG, BMP, animated GIF, TIFF, and WebP. Images are prefiltered when reduced to fit the window, which avoids harsh edges and aliasing. The status bar shows the filename, position, dimensions, and file size. Decoding errors appear in the window.
|
||||||
|
|
||||||
- Implement actual image loading capabilities with format support
|
The `test_images` folder contains working examples of every supported format, including a two-frame animated GIF. Regenerate them with `cargo run --example generate_samples`.
|
||||||
- Add proper Windows UI components using winapi or similar crates
|
|
||||||
- Implement file system browsing for media files
|
|
||||||
- Add real-time rendering of images in the UI
|
|
||||||
- Extend to support video and audio formats
|
|
||||||
- Implement advanced features like batch processing and metadata editing
|
|
||||||
|
|
||||||
## Development Notes
|
|
||||||
|
|
||||||
This prototype provides a foundation for building a full-featured media viewer. The current code demonstrates the structure and intended architecture but lacks actual implementation of core features.
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
//! Regenerate the small, valid sample images in `test_images`.
|
||||||
|
use image::{codecs::gif::GifEncoder, Delay, DynamicImage, Frame, Rgba, RgbaImage};
|
||||||
|
use std::{
|
||||||
|
fs::{self, File},
|
||||||
|
path::Path,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let directory = Path::new("test_images");
|
||||||
|
fs::create_dir_all(directory)?;
|
||||||
|
let image = RgbaImage::from_fn(480, 320, |x, y| {
|
||||||
|
let stripe = ((x / 32) + (y / 32)) % 2 == 0;
|
||||||
|
if stripe {
|
||||||
|
Rgba([57, 107, 155, 255])
|
||||||
|
} else {
|
||||||
|
Rgba([244, 172, 85, 255])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let rgba = DynamicImage::ImageRgba8(image.clone());
|
||||||
|
rgba.to_rgb8().save(directory.join("test_image_1.jpg"))?;
|
||||||
|
rgba.save(directory.join("test_image_2.png"))?;
|
||||||
|
rgba.save(directory.join("test_image_3.bmp"))?;
|
||||||
|
rgba.save(directory.join("test_image_5.tiff"))?;
|
||||||
|
rgba.save(directory.join("test_image_6.webp"))?;
|
||||||
|
|
||||||
|
let path = directory.join("test_image_4.gif");
|
||||||
|
let mut encoder = GifEncoder::new(File::create(path)?);
|
||||||
|
for (background, foreground) in [
|
||||||
|
([57, 107, 155], [244, 172, 85]),
|
||||||
|
([244, 172, 85], [57, 107, 155]),
|
||||||
|
] {
|
||||||
|
let frame = RgbaImage::from_fn(480, 320, |x, y| {
|
||||||
|
let inside = (x as i32 - 240).pow(2) + (y as i32 - 160).pow(2) < 100 * 100;
|
||||||
|
let color = if inside { foreground } else { background };
|
||||||
|
Rgba([color[0], color[1], color[2], 255])
|
||||||
|
});
|
||||||
|
encoder.encode_frame(Frame::from_parts(
|
||||||
|
frame,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
Delay::from_numer_denom_ms(400, 1),
|
||||||
|
))?;
|
||||||
|
}
|
||||||
|
println!("Generated samples in {}", directory.display());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 53 B After Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 53 B After Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 53 B After Width: | Height: | Size: 600 KiB |
|
Before Width: | Height: | Size: 53 B After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 54 B After Width: | Height: | Size: 480 B |