Skip to content

Commit 53d9a13

Browse files
committed
added checking to see if an extension is specified
1 parent 290f7ff commit 53d9a13

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/util/data_export.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,28 @@ impl DataExport {
335335
}
336336
}
337337

338-
fn save_colour(&mut self, filename: &str) {
338+
pub fn save_colour(&mut self, filename: &str) {
339+
// Extension is specified
340+
match filename.split_terminator(".").last() {
341+
Some(extension) => {
342+
match extension {
343+
"jpg" | "jpeg" | "png" => {
344+
image::save_buffer(
345+
filename.to_owned(),
346+
&self.rgb,
347+
self.image_width as u32,
348+
self.image_height as u32,
349+
image::ColorType::Rgb8).unwrap();
350+
351+
return;
352+
}
353+
_ => {}
354+
}
355+
356+
}
357+
_ => {}
358+
}
359+
339360
image::save_buffer(
340361
filename.to_owned() + ".png",
341362
&self.rgb,
@@ -344,7 +365,7 @@ impl DataExport {
344365
image::ColorType::Rgb8).unwrap();
345366
}
346367

347-
fn save_raw(&mut self, filename: &str, approximation_order: usize, zoom: &str) {
368+
pub fn save_raw(&mut self, filename: &str, approximation_order: usize, zoom: &str) {
348369
let iterations = simple_image::Channel::non_color_data(simple_image::Text::from("N").unwrap(), simple_image::Samples::U32(self.iterations.clone()));
349370
let smooth = simple_image::Channel::non_color_data(simple_image::Text::from("NF").unwrap(), simple_image::Samples::F16(self.smooth_f16.clone()));
350371

@@ -375,7 +396,7 @@ impl DataExport {
375396
image.write_to_file(filename.to_owned() + ".exr", simple_image::write_options::high()).unwrap();
376397
}
377398

378-
fn save_kfb(&mut self, filename: &str) {
399+
pub fn save_kfb(&mut self, filename: &str) {
379400
let mut file = File::create(filename.to_owned() + ".kfb").unwrap();
380401

381402
file.write_all(b"KFB").unwrap();

test.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)