Skip to content

Commit

Permalink
Image Editor: fixed bug in color picker tool
Browse files Browse the repository at this point in the history
  • Loading branch information
zenden2k committed Dec 14, 2024
1 parent 147e3e9 commit 6912f70
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion COMPILING.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Building Image Uploader on Windows
# Building Image Uploader on Windows


To build Image Uploader from source files you will need:
Expand Down
10 changes: 5 additions & 5 deletions Source/Image Uploader.rc
Original file line number Diff line number Diff line change
Expand Up @@ -777,28 +777,28 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFR
CAPTION "History"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
LTEXT "#",IDC_ANIMATIONSTATIC,379,3,23,17
CONTROL "Check1",IDC_DOWNLOADTHUMBS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,9,151,10
LTEXT "#",IDC_ANIMATIONSTATIC,379,3,23,17
LISTBOX IDC_HISTORYTREE,4,26,398,224,LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT | LBS_WANTKEYBOARDINPUT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "#Filters",IDC_FILTERSGROUPBOX,4,253,398,63,0,WS_EX_TRANSPARENT
CONTROL "#Date from:",IDC_DATEFROMCHECKBOX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,264,81,10
CONTROL "",IDC_DATEFROMPICKER,"SysDateTimePick32",DTS_RIGHTALIGN | WS_TABSTOP,97,261,100,15
CTEXT "#to:",IDC_DATETOLABEL,201,264,36,8
CONTROL "",IDC_DATETOPICKER,"SysDateTimePick32",DTS_RIGHTALIGN | WS_TABSTOP,240,261,100,15
LTEXT "#Filename:",IDC_FILENAMELABEL,11,282,57,8
CTEXT "#to:",IDC_DATETOLABEL,201,264,36,8
EDITTEXT IDC_FILENAMEEDIT,70,280,128,14,ES_AUTOHSCROLL
CTEXT "#URL:",IDC_URLLABEL,200,282,38,8
EDITTEXT IDC_URLEDIT,240,280,144,14,ES_AUTOHSCROLL
PUSHBUTTON "#Apply",IDOK,8,297,93,14
PUSHBUTTON "Clear filters",IDC_CLEARFILTERS,106,297,92,14
LTEXT "Total sessions:",IDC_SESSIONSCOUNTDESCR,12,326,75,8
LTEXT "Total files:",IDC_FILESCOUNTDESCR,12,340,68,8
LTEXT "0",IDC_SESSIONSCOUNTLABEL,89,327,55,8
LTEXT "0",IDC_FILESCOUNTLABEL,89,340,56,8
LTEXT "Traffic:",IDC_UPLOADTRAFFICDESCR,151,327,75,8
LTEXT "0",IDC_UPLOADTRAFFICLABEL,229,327,83,8
LTEXT "Total files:",IDC_FILESCOUNTDESCR,12,340,68,8
LTEXT "0",IDC_FILESCOUNTLABEL,89,340,56,8
PUSHBUTTON "#Clear History",IDC_CLEARHISTORYBTN,150,345,112,14
PUSHBUTTON "Close",IDCANCEL,342,345,60,15
PUSHBUTTON "#Apply",IDOK,8,297,93,14
END

IDD_THUMBEDITOR DIALOGEX 0, 0, 261, 174
Expand Down
4 changes: 4 additions & 0 deletions Source/ImageEditor/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,10 @@ void Canvas::setCropOnExport(bool crop) {
cropOnExport_ = crop;
}

bool Canvas::getCropOnExport() const {
return cropOnExport_;
}

void Canvas::setDpi(float dpiX, float dpiY) {
dpiX_ = dpiX;
dpiY_ = dpiY;
Expand Down
1 change: 1 addition & 0 deletions Source/ImageEditor/Canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class Canvas {
bool hasElementOfType(ElementType type) const;

void setCropOnExport(bool crop);
bool getCropOnExport() const;

void setDpi(float dpiX, float dpiY);
std::pair<float, float> getDpi() const;
Expand Down
10 changes: 9 additions & 1 deletion Source/ImageEditor/DrawingTools/ColorPickerTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ void ColorPickerTool::continueDraw(int x, int y, DWORD flags)

void ColorPickerTool::endDraw(int x, int y)
{
bool oldValue = canvas_->getCropOnExport();
canvas_->setCropOnExport(false);
auto bmp = canvas_->getBitmapForExport();
canvas_->setCropOnExport(oldValue);
if (bmp) {
Gdiplus::Color color;
if (bmp->GetPixel(x, y, &color) == Gdiplus::Ok) {
canvas_->setForegroundColor(color);
canvas_->onForegroundColorChanged(color);
canvas_->setPreviousDrawingTool();
// On this line "this" object has been already destroyed
}
}
}
Expand All @@ -65,16 +69,20 @@ ImageEditor::CursorType ColorPickerTool::getCursor(int x, int y)

void ColorPickerTool::rightButtonClick(int x, int y)
{
bool oldValue = canvas_->getCropOnExport();
canvas_->setCropOnExport(false);
auto bmp = canvas_->getBitmapForExport();
canvas_->setCropOnExport(oldValue);
if (bmp) {
Gdiplus::Color color;
if (bmp->GetPixel(x, y, &color) == Gdiplus::Ok) {
canvas_->setBackgroundColor(color);

canvas_->onBackgroundColorChanged(color);
canvas_->setPreviousDrawingTool();
// On this line "this" object has been already destroyed
}
}
}

}
}

0 comments on commit 6912f70

Please sign in to comment.