mirror of
https://github.com/xzeldon/rdr2_screenshot_converter.git
synced 2025-07-15 18:34:40 +03:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
0d715f2fdd
|
1750
Cargo.lock
generated
1750
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,21 +4,30 @@ Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
Mirror on my [<img src="https://git.zeldon.ru/assets/img/logo.svg" align="center" width="20" height="20"/> Git](https://git.zeldon.ru/zeldon/rdr2_screenshot_converter)
|
||||||
|
|
||||||
## QuickStart
|
## QuickStart
|
||||||
|
|
||||||
Just [download](https://github.com/xzeldon/rdr2_screenshot_converter/releases) the executable file from releases and run it. It will automatically find your screenshots and save them.
|
Just [download](https://github.com/xzeldon/rdr2_screenshot_converter/releases) the executable file from releases and run it. It will automatically find your screenshots and save them.
|
||||||
|
|
||||||
## Arguments
|
## Arguments
|
||||||
|
|
||||||
You can define a path for saving screenshots. To do this, open a command prompt, specify the path to the executable file and the path to save the screenshots.
|
You can define a path for saving screenshots. To do this, open a command prompt, specify the path to the executable file and the path to save the screenshots.
|
||||||
|
|
||||||
```
|
```
|
||||||
cli.exe C:\screenshots
|
cli.exe C:\screenshots
|
||||||
```
|
```
|
||||||
|
|
||||||
This command will save screenshots to ```C:\screenshots```
|
This command will save screenshots to ```C:\screenshots```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
All instructions tested on Windows 10 Pro for workstations 19042.928.
|
All instructions tested on Windows 10 Pro for workstations 19042.928.
|
||||||
|
|
||||||
You need:
|
You need:
|
||||||
|
|
||||||
* [Rust](https://www.rust-lang.org)
|
* [Rust](https://www.rust-lang.org)
|
||||||
|
|
||||||
```
|
```
|
||||||
cargo build --release --bin cli
|
cargo build --release --bin cli
|
||||||
```
|
```
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
edition = "2021"
|
|
||||||
name = "gui"
|
name = "gui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cli = {path = "../cli"}
|
|
||||||
core = {path = "../core"}
|
|
||||||
eframe = "0.16.0"
|
|
||||||
image = "0.23.14"
|
|
||||||
rfd = "0.6.4"
|
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
use eframe::egui::{Separator, Ui};
|
|
||||||
use eframe::epi::Image;
|
|
||||||
use eframe::{egui, epi};
|
|
||||||
|
|
||||||
const PADDING: f32 = 5.0;
|
|
||||||
|
|
||||||
pub fn render_header(ui: &mut Ui) {
|
|
||||||
ui.vertical_centered(|ui| {
|
|
||||||
ui.heading("RDR2Converter");
|
|
||||||
});
|
|
||||||
ui.add_space(PADDING);
|
|
||||||
let sep = Separator::default().spacing(20.);
|
|
||||||
ui.add(sep);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn decode_image(buffer: &[u8]) -> Option<epi::Image> {
|
|
||||||
use image::GenericImageView;
|
|
||||||
let image = image::load_from_memory(buffer).ok()?;
|
|
||||||
let image_buffer = image.to_rgba8();
|
|
||||||
let size = [image.width() as usize, image.height() as usize];
|
|
||||||
let pixels = image_buffer.into_vec();
|
|
||||||
Some(epi::Image::from_rgba_unmultiplied(size, &pixels))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn render_image(
|
|
||||||
ui: &mut egui::Ui,
|
|
||||||
frame: &epi::Frame,
|
|
||||||
tex_mngr: &mut TextureManager,
|
|
||||||
image: Option<epi::Image>,
|
|
||||||
) {
|
|
||||||
egui::ScrollArea::vertical()
|
|
||||||
.auto_shrink([false; 2])
|
|
||||||
.show(ui, |ui| {
|
|
||||||
if let Some(image) = image {
|
|
||||||
if let Some(texture_id) = tex_mngr.texture(frame, &image) {
|
|
||||||
let mut size = egui::Vec2::new(image.size[0] as f32, image.size[1] as f32);
|
|
||||||
size *= (ui.available_width() / size.x).min(1.0);
|
|
||||||
ui.image(texture_id, size);
|
|
||||||
} else {
|
|
||||||
ui.monospace("ERROR");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct TextureManager {
|
|
||||||
texture_id: Option<egui::TextureId>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TextureManager {
|
|
||||||
pub fn texture(&mut self, frame: &epi::Frame, image: &Image) -> Option<egui::TextureId> {
|
|
||||||
if let Some(texture_id) = self.texture_id.take() {
|
|
||||||
frame.free_texture(texture_id);
|
|
||||||
}
|
|
||||||
self.texture_id = Some(frame.alloc_texture(image.clone()));
|
|
||||||
self.texture_id
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +1,3 @@
|
|||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
|
||||||
|
|
||||||
use core::buffer;
|
|
||||||
use eframe::{
|
|
||||||
egui::{CentralPanel, Vec2},
|
|
||||||
epi::App,
|
|
||||||
run_native, NativeOptions,
|
|
||||||
};
|
|
||||||
use gui::TextureManager;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct RDR2Converter {
|
|
||||||
pub tex_mngr: TextureManager,
|
|
||||||
picked_path: Option<PathBuf>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl App for RDR2Converter {
|
|
||||||
fn update(&mut self, ctx: &eframe::egui::CtxRef, frame: &eframe::epi::Frame) {
|
|
||||||
CentralPanel::default().show(ctx, |ui| {
|
|
||||||
gui::render_header(ui);
|
|
||||||
|
|
||||||
if ui.button("Open file...").clicked() {
|
|
||||||
if let Some(path) = rfd::FileDialog::new().pick_file() {
|
|
||||||
self.picked_path = Some(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: use threads and channels
|
|
||||||
if let Some(picked_path) = &self.picked_path {
|
|
||||||
let buf = buffer::read_file(&picked_path).unwrap();
|
|
||||||
let pic = buffer::parse_buf(&buf, b"JPEG", b"JSON", 12);
|
|
||||||
let image = gui::decode_image(&pic);
|
|
||||||
gui::render_image(ui, frame, &mut self.tex_mngr, image);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self) -> &str {
|
|
||||||
"RDR2Converter"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let app = RDR2Converter::default();
|
println!("Hello, world!");
|
||||||
let mut win_option = NativeOptions::default();
|
|
||||||
win_option.initial_window_size = Some(Vec2::new(540., 960.));
|
|
||||||
run_native(Box::new(app), win_option);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user