Skip to content

Commit

Permalink
ImageDisplayResizable: add param resizable
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed May 11, 2024
1 parent 2f12bb6 commit acc20a8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/immvision/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ namespace ImmVision
const cv::Mat& mat,
ImVec2* size,
bool refreshImage = false,
bool resizable = true,
bool showOptionsButton = false,
bool isBgrOrBgra = true
);
Expand Down
6 changes: 3 additions & 3 deletions src/immvision/internal/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,12 @@ namespace ImmVision
const cv::Mat& mat,
ImVec2* size,
bool refreshImage,
bool resizable,
bool showOptionsButton,
bool isBgrOrBgra
)
{
IM_ASSERT(size != nullptr && "ImageDisplayResizable: size must not be null");
ImGuiID id = ImGui::GetID(label_id.c_str());
static std::map<ImGuiID, ImageParams> s_Params;
if (s_Params.find(id) == s_Params.end())
Expand All @@ -699,7 +701,7 @@ namespace ImmVision
{
params.ShowOptionsButton = showOptionsButton;
params.ImageDisplaySize = imageDisplaySize;
params.CanResize = true;
params.CanResize = resizable;
params.RefreshImage = refreshImage;
params.IsColorOrderBGR = isBgrOrBgra;

Expand All @@ -709,8 +711,6 @@ namespace ImmVision
std::string hiddenLabel = std::string("##") + label_id;
Image(hiddenLabel, mat, &params);



*size = ImVec2((float)params.ImageDisplaySize.width, (float)params.ImageDisplaySize.height);
return params.MouseInfo.MousePosition;
}
Expand Down
8 changes: 4 additions & 4 deletions src_all_in_one/immvision/immvision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ namespace ImmVision
const cv::Mat& mat,
ImVec2* size,
bool refreshImage = false,
bool resizable = true,
bool showOptionsButton = false,
bool isBgrOrBgra = true
);
Expand Down Expand Up @@ -10116,7 +10117,6 @@ namespace ImmVision
s_Params[id] = params;
}


ImageParams& params = s_Params.at(id);
{
params.ShowOptionsButton = showOptionsButton;
Expand All @@ -10137,10 +10137,12 @@ namespace ImmVision
const cv::Mat& mat,
ImVec2* size,
bool refreshImage,
bool resizable,
bool showOptionsButton,
bool isBgrOrBgra
)
{
IM_ASSERT(size != nullptr && "ImageDisplayResizable: size must not be null");
ImGuiID id = ImGui::GetID(label_id.c_str());
static std::map<ImGuiID, ImageParams> s_Params;
if (s_Params.find(id) == s_Params.end())
Expand All @@ -10154,7 +10156,7 @@ namespace ImmVision
{
params.ShowOptionsButton = showOptionsButton;
params.ImageDisplaySize = imageDisplaySize;
params.CanResize = true;
params.CanResize = resizable;
params.RefreshImage = refreshImage;
params.IsColorOrderBGR = isBgrOrBgra;

Expand All @@ -10164,8 +10166,6 @@ namespace ImmVision
std::string hiddenLabel = std::string("##") + label_id;
Image(hiddenLabel, mat, &params);



*size = ImVec2((float)params.ImageDisplaySize.width, (float)params.ImageDisplaySize.height);
return params.MouseInfo.MousePosition;
}
Expand Down
1 change: 1 addition & 0 deletions src_all_in_one/immvision/immvision.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ namespace ImmVision
const cv::Mat& mat,
ImVec2* size,
bool refreshImage = false,
bool resizable = true,
bool showOptionsButton = false,
bool isBgrOrBgra = true
);
Expand Down

0 comments on commit acc20a8

Please sign in to comment.