Skip to content

Commit 08c6aff

Browse files
committed
Interaction with file system has been commented
1 parent 5c8e54b commit 08c6aff

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/app/headless_renderer.rs

+7
Original file line numberDiff line numberDiff line change
@@ -495,25 +495,32 @@ mod frame_capture {
495495
}
496496
if !image_data.is_empty() {
497497
for image in images_to_save.iter() {
498+
// Fill correct data from channel to image
498499
let img_bytes = images.get_mut(image.id()).unwrap();
499500
img_bytes.data.clone_from(&image_data);
500501

502+
// Create RGBA Image Buffer
501503
let img = match img_bytes.clone().try_into_dynamic() {
502504
Ok(img) => img.to_rgba8(),
503505
Err(e) => panic!("Failed to create image buffer {e:?}"),
504506
};
505507

508+
// Prepare directory for images, test_images in bevy folder is used here for example
509+
// You should choose the path depending on your needs
506510
let images_dir =
507511
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("test_images");
508512
info!("Saving image to: {images_dir:?}");
509513
std::fs::create_dir_all(&images_dir).unwrap();
510514

515+
// Search for the first unoccupied number
511516
let mut number = 0;
512517
let mut image_path = images_dir.join(format!("{number:03}.png"));
513518
while image_path.exists() {
514519
number += 1;
515520
image_path = images_dir.join(format!("{number:03}.png"));
516521
}
522+
523+
// Finally saving image to file
517524
if let Err(e) = img.save(image_path) {
518525
panic!("Failed to save image: {}", e);
519526
};

0 commit comments

Comments
 (0)