gpt4 book ai didi

c++ - 删除GDI+中某行的某一部分

转载 作者:太空宇宙 更新时间:2023-11-04 11:28:11 26 4
gpt4 key购买 nike

我有一条类似于箭头的线。我在那条线的顶部画了一个文本。现在我想删除与文本重叠的那部分线

我目前的代码是这样的:

SolidBrush *brush1=new SolidBrush(Color::Color(0,167,255));
StringFormat format;
format.SetAlignment(StringAlignmentCenter);
format.SetLineAlignment(StringAlignmentCenter);
graph->DrawLine(myPen,point2,point1);
graph->DrawString(strdata,wcslen(strdata),&font,point2,&format,brush1);

我也试过

AdjustableArrowCap *cap1 = new AdjustableArrowCap(5, 5, true);
Pen *myPen1 = new Pen(Color::Color(0,255,255), width);

myPen->SetCustomEndCap(cap1);
GraphicsPath path;
path.AddLine(point1,point2);
Font font(&FontFamily(L"arial"), 21);
Brush *brush=new SolidBrush(Color::Color(0,255,255,255));

SolidBrush solidBrush(Color(255, 255, 0, 0));

StringFormat format;
format.SetAlignment(StringAlignmentCenter);
format.SetLineAlignment(StringAlignmentCenter);
RectF rectbo;
graph->MeasureString(strdata,wcslen(strdata),&font,PointF::PointF(point2),&rectbo);


graph->DrawLine(myPen,point2,point1);
Region pathRegion(&path);
sta=pathRegion.Intersect(rectbo);
graph->fillRegion(pathRegion,&brush);
graph->DrawString(strdata,wcslen(strdata),&font,point2,&format,brush1);

最佳答案

先画线再画文字

  • 还要确保启用画笔纯色/清晰样式
  • 所以文本覆盖文本下方的空间
  • 并且纸张被清除/或保持原样

我帮你找到了

  • Brush Winapi refference
  • 因此设置 LOGBRUSH::lbStyle=BS_NULL; 等效于 bsClear
  • LOGBRUSH::lbStyle=BS_SOLID; 等效于 bsSolid

关于c++ - 删除GDI+中某行的某一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25861431/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com