Original implementation of Sharpen Image filters

This commit is contained in:
Bruno Herbelin
2022-05-31 22:53:28 +02:00
parent e3bb95b3dd
commit 7c850b0405
12 changed files with 153 additions and 57 deletions

View File

@@ -818,6 +818,51 @@ void ImGuiVisitor::visit (BlurFilter& f)
}
void ImGuiVisitor::visit (SharpenFilter& f)
{
std::ostringstream oss;
oss << "Blur ";
// Method selection
if (ImGuiToolkit::IconButton(7, 16)) {
f.setMethod( 0 );
oss << SharpenFilter::method_label[0];
Action::manager().store(oss.str());
}
ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
int m = (int) f.method();
if (ImGui::Combo("Method", &m, SharpenFilter::method_label, IM_ARRAYSIZE(SharpenFilter::method_label) )) {
f.setMethod( m );
oss << SharpenFilter::method_label[m];
Action::manager().store(oss.str());
}
// List of parameters
std::map<std::string, float> filter_parameters = f.program().parameters();
for (auto param = filter_parameters.begin(); param != filter_parameters.end(); ++param)
{
ImGui::PushID( param->first.c_str() );
float v = param->second;
if (ImGuiToolkit::IconButton(13, 14)) {
v = 0.f;
f.setProgramParameter(param->first, v);
}
ImGui::SameLine(0, IMGUI_SAME_LINE);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
if (ImGui::SliderFloat( param->first.c_str(), &v, 0.f, 1.f, "%.2f")) {
f.setProgramParameter(param->first, v);
}
if (ImGui::IsItemDeactivatedAfterEdit()) {
oss << SharpenFilter::method_label[ f.method() ];
oss << " : " << param->first << " " << std::setprecision(3) <<param->second;
Action::manager().store(oss.str());
}
ImGui::PopID();
}
}
void ImGuiVisitor::visit (ImageFilter& f)
{
// Selection of Algorithm