我正在尝试使用GDI +绘制图像.当我在里面做WM_PAINT
它的工作原理:
case WM_PAINT: {
hdc = BeginPaint(hWnd, &ps);
Gdiplus::Graphics graphics(hdc);
Gdiplus::Image gdiImage(L"unt.png");
graphics.DrawImage(&gdiImage, 40, 40);
EndPaint(hWnd, &ps);
break;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我按下按钮或在内部时,WM_CREATE
它不会绘制图像:
HDC hdc2 = GetDC(hWnd);
Gdiplus::Graphics graphics(hdc2);
Gdiplus::Image gdiImage(L"unt.png");
graphics.DrawImage(&gdiImage, 40, 40);
Run Code Online (Sandbox Code Playgroud)
即使我使用BeginPaint()
和EndPaint()
它仍然失败.那么,有没有办法在外面画出图像WM_PAINT
?
在我的程序中,我加载一些图像,从中提取一些功能并使用a cv::Mat
来存储这些功能.根据我知道的图像数量cv::Mat
将是700.000 x 256(行x列),大约是720Mb.但是当我运行我的程序时它大约400.000 x 256(400Mb)并尝试添加更多它只是崩溃与致命错误.任何人都可以确认400Mb确实是cv::Mat
存储容量的极限吗?我应该检查更多问题吗?克服这个问题的可能方法?
我使用以下代码来计算标准差:
std::vector<float> k = {4,6,2};
float mean = 4;
float sum = std::accumulate(k.begin(), k.end(), 0, [&mean](float x, float y) {
return (y - mean) * (y - mean);
});
float variance = sum / k.size();
float stdev = sqrt(variance);
Run Code Online (Sandbox Code Playgroud)
std::accumulate
4
应该返回时返回:
(4-4)^2 + (6-4)^2 + (2-4)^2 = 8
Run Code Online (Sandbox Code Playgroud)
此外,印刷(y - mean) * (y - mean)
给出:
0
4
4
Run Code Online (Sandbox Code Playgroud)
那么,它为什么不回归0 + 4 + 4
呢?
当列表仅包含长度相同的行时,转置有效:
numpy.array([[1, 2], [3, 4]]).T.tolist();
>>> [[1, 3], [2, 4]]
Run Code Online (Sandbox Code Playgroud)
但是,在我的情况下,列表包含不同长度的行:
numpy.array([[1, 2, 3], [4, 5]]).T.tolist();
Run Code Online (Sandbox Code Playgroud)
哪个失败了.任何可能的解决方
我malloc()
出于某种原因包装.我希望有一些(系统特定的,运行时)信息,而不仅仅是调用它.例如:
malloc()
用于分配的最小对齐是什么?realloc()
将使用相同的原始地址成功或需要移动.注意:我希望尽可能的方便,但特定于平台的答案仍然相关:Linux,Windows,MacOs,Un*x.
我试图使用std::string
ID(结构的成员)对结构数组进行排序.这是代码:
struct Row {
std::string ID;
std::array<float, 5> scores;
float avgScore;
};
std::array<Row, 50> records{};
// ...
// Open a file, read some data and store them into records
// ...
// Sort the data
std::sort(records.begin(), records.end(), [](const Row& r1, const Row& r2) {
return r1.ID > r2.ID;
});
Run Code Online (Sandbox Code Playgroud)
到目前为止一切都按预期工作.例如,以下数据:
liu 90 80 90 100 85
ols 95 95 90 93 85
kum 90 85 85 95 92
将分类到:
ols 95 95 90 93 85
liu 90 80 …
我想里面匹配的文本%[
,并]%
在单个或多个行。我尝试的第一件事是:
\%\[(.*?)\]\% return MULTILINE_TEXT;
Run Code Online (Sandbox Code Playgroud)
但这仅适用于单行情况,不适用于多行。所以,我想我可以使用/s
:
/\%\[(.*?)\]\%/s return MULTILINE_TEXT;
Run Code Online (Sandbox Code Playgroud)
但 flex 将此视为无效规则。我尝试的最后一件事是:
\%\[((.*?|\n)*?)\]\% return MULTILINE_TEXT;
Run Code Online (Sandbox Code Playgroud)
这似乎有效,但它并没有停止在第一个]%
。在以下示例中:
%[ Some text ...
Some text ... ]%
... other stuff ...
%[ Some more text ...
Some more text ... ]%
Run Code Online (Sandbox Code Playgroud)
flex 会将整个事物作为单个标记返回。我能做什么?
c++ ×4
c ×2
accumulate ×1
flex-lexer ×1
gdi+ ×1
malloc ×1
mat ×1
numpy ×1
opencv ×1
python ×1
regex ×1
sorting ×1
statistics ×1
transpose ×1