Skip to content

Commit

Permalink
Merge pull request #632 from B-LechCode/609_Channel_Picker_with_shader
Browse files Browse the repository at this point in the history
609 channel picker with shader
  • Loading branch information
woelper authored Jan 30, 2025
2 parents b134b3e + 4a513df commit 8698de6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
32 changes: 21 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn init(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins) -> OculanteSt
// Set up egui style / theme
plugins.egui(|ctx| {
// FIXME: Wait for https://github.com/Nazariglez/notan/issues/315 to close, then remove

let mut fonts = FontDefinitions::default();
egui_extras::install_image_loaders(ctx);

Expand Down Expand Up @@ -349,10 +349,8 @@ fn init(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins) -> OculanteSt
.unwrap()
.insert(0, "inter".to_owned());


let fonts = load_system_fonts(fonts);


debug!("Theme {:?}", state.persistent_settings.theme);
apply_theme(&mut state, ctx);
ctx.set_fonts(fonts);
Expand Down Expand Up @@ -950,27 +948,39 @@ fn drawe(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut O
debug!("Received image buffer: {:?}", img.dimensions(),);
state.image_geometry.dimensions = img.dimensions();

state
.current_texture
.set_image(&img, gfx, &state.persistent_settings);
if let Err(error) =
state
.current_texture
.set_image(&img, gfx, &state.persistent_settings)
{
state.send_message_warn(&format!("Error while displaying image: {error}"));
}
state.current_image = Some(img);
}
Frame::UpdateTexture => {
// Only update the texture.

// Prefer the edit result, if present
if state.edit_state.result_pixel_op != Default::default() {
state.current_texture.set_image(
if let Err(error) = state.current_texture.set_image(
&state.edit_state.result_pixel_op,
gfx,
&state.persistent_settings,
);
) {
state.send_message_warn(&format!("Error while displaying image: {error}"));
}
} else {
// update from image
if let Some(img) = &state.current_image {
state
.current_texture
.set_image(&img, gfx, &state.persistent_settings);
if let Err(error) =
state
.current_texture
.set_image(&img, gfx, &state.persistent_settings)
{
state.send_message_warn(&format!(
"Error while displaying image: {error}"
));
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/texture_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ impl TextureWrapperManager {
&& tex.height() as u32 == img.height()
&& img.color() == tex.image_format
{
debug!("Re-using texture as it is the same size and type.");
match tex.update_textures(gfx, img) {
Ok(_) => {}
Ok(_) => return Ok(()),
Err(error) => {
self.clear();
error!("{error}");
Expand Down
4 changes: 3 additions & 1 deletion src/ui/edit_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ pub fn edit_ui(app: &mut App, ctx: &Context, state: &mut OculanteState, gfx: &mu
if ui.add(egui::Button::new("Original").min_size(vec2(ui.available_width()/2., 0.))).clicked() {
if let Some(img) = &state.current_image {
state.image_geometry.dimensions = img.dimensions();
state.current_texture.set_image(img, gfx, &state.persistent_settings);
if let Err(error) = state.current_texture.set_image(img, gfx, &state.persistent_settings){
state.send_message_warn(&format!("Error while displaying image: {error}"));
}
}
}
if ui.add(egui::Button::new("Modified").min_size(vec2(ui.available_width(), 0.))).clicked() {
Expand Down

0 comments on commit 8698de6

Please sign in to comment.