Skip to content

Commit

Permalink
Completed Dissolve
Browse files Browse the repository at this point in the history
  • Loading branch information
danvim committed Feb 28, 2019
1 parent 294e992 commit f325bec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
17 changes: 12 additions & 5 deletions ImpressionistUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,17 @@ void ImpressionistUI::cb_tracer_update(Fl_Widget* o, void* v)
uiPtr->m_paintView->redraw();
}

void ImpressionistUI::cb_open_dissolve_dialog(Fl_Widget* o, void*)
{
whoami(dynamic_cast<Fl_Menu_*>(o))->m_dissolveDialog->show();
}


void ImpressionistUI::cb_dissolve(Fl_Widget* o, void*)
{
auto* uiPtr = static_cast<ImpressionistUI*>(o->user_data());

const auto dissolveRatio = uiPtr->m_dissolveOpacitySlider->value();
const auto dissolveRatio = uiPtr->m_dissolveOpacitySlider->value() / 100.0;

auto* fileName = fl_file_chooser("Open File?", "*.bmp", nullptr);
if (fileName != nullptr) {
Expand All @@ -636,15 +642,15 @@ void ImpressionistUI::cb_dissolve(Fl_Widget* o, void*)
{ width, height }
};

ImageUtils::eachPixel<unsigned char>(uiPtr->m_pDoc->m_ucPainting, {uiPtr->m_pDoc->m_nPaintWidth, uiPtr->m_pDoc->m_nPaintHeight }, [&](unsigned char* rgbArray, long x, long y)
ImageUtils::eachPixel<unsigned char>(uiPtr->m_pDoc->m_ucPainting, {uiPtr->m_pDoc->m_nPaintWidth, uiPtr->m_pDoc->m_nPaintHeight }, [&](unsigned char* rgbArray, const long x, const long y)
{
auto* otherPixel = imageWrapper.getPixelPtr(x, y);
rgbArray[0] = static_cast<unsigned char>(dissolveRatio * rgbArray[0] + (1 - dissolveRatio) * otherPixel[0]);
rgbArray[1] = static_cast<unsigned char>(dissolveRatio * rgbArray[1] + (1 - dissolveRatio) * otherPixel[1]);
rgbArray[2] = static_cast<unsigned char>(dissolveRatio * rgbArray[2] + (1 - dissolveRatio) * otherPixel[2]);
});

uiPtr->m_paintView->draw();
uiPtr->m_paintView->redraw();
}
else
{
Expand Down Expand Up @@ -785,6 +791,7 @@ Fl_Menu_Item ImpressionistUI::menuitems[] = {
{ "&Swap Content", FL_ALT + 's', (Fl_Callback*)ImpressionistUI::cb_swap_content },
{ "&Undo", FL_ALT + 'z', (Fl_Callback*)ImpressionistUI::cb_undo },
{ "Tracer...", 0, cb_open_tracer_dialog },
{ "Dissolve...", 0, cb_open_dissolve_dialog },
{ "&Auto Fill", FL_ALT + 'f', (Fl_Callback*)ImpressionistUI::cb_auto_fill_menu },
{ "&Load Another Img", FL_ALT + 'l', (Fl_Callback*)ImpressionistUI::cb_load_another_image },
{ "&Load Mural Img", FL_ALT + 'm', (Fl_Callback*)ImpressionistUI::cb_load_mural_image },
Expand Down Expand Up @@ -1165,10 +1172,10 @@ ImpressionistUI::ImpressionistUI()
m_dissolveOpacitySlider->minimum(0.0);
m_dissolveOpacitySlider->maximum(100.0);
m_dissolveOpacitySlider->step(1.0);
m_dissolveOpacitySlider->value(20.0);
m_dissolveOpacitySlider->value(50.0);
m_dissolveOpacitySlider->align(FL_ALIGN_BOTTOM);

m_dissolveLoadImageBtn = new Fl_Button(270, 65, 100, 25, "Load Image");
m_dissolveLoadImageBtn = new Fl_Button(110, 65, 100, 25, "Load Image");
m_dissolveLoadImageBtn->user_data(static_cast<void*>(this));
m_dissolveLoadImageBtn->callback(cb_dissolve);
}
Expand Down
2 changes: 1 addition & 1 deletion impressionist.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<WarningLevel>Level3</WarningLevel>
<MinimalRebuild>true</MinimalRebuild>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>local\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>local\include;$(MSBuildProjectDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerListingLocation>c:\temp\</AssemblerListingLocation>
<PrecompiledHeaderOutputFile>c:\temp\impressionist.pch</PrecompiledHeaderOutputFile>
Expand Down
1 change: 1 addition & 0 deletions impressionistUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class ImpressionistUI {
static Fl_Callback cb_open_colors_dialog;
static Fl_Callback cb_open_tracer_dialog;
static Fl_Callback cb_tracer_update;
static Fl_Callback cb_open_dissolve_dialog;
static Fl_Callback cb_dissolve;

};
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Programming project 1 of HKUST Computer Graphics course COMP4411
- [x] (1B) change color of image (change channel)
- [x] **(1B)** blur brush and sharpen brush (wait for kernel brush)
- [x] **(1B)** undo
- [ ] (1B) Dissolve one image into another
- [x] (1B) Dissolve one image into another
- [x] (1B1W) original image overlay
- [x] _(1B1W)_ mural image (load another image without resetting)
- [x] (1B1W) alpha mapping brush
Expand Down

0 comments on commit f325bec

Please sign in to comment.