if (pressure_detection) { for (unsigned int i = 0; i < PRESSURE_DATA_ANOMALY_POS_X[0].size(); i++) { nX = 85 + move_x[picclass] * change_x[picclass] + ceil(PRESSURE_DATA_ANOMALY_POS_X[0][i] * 500 /1500 * change_x[picclass]); if (nX > (right - left) - 30)break; nY = 4 * rectPicture.Height() / 4 - 30 + move_y[picclass] - ceil((PRESSURE_DATA_ANOMALY_POS_Y[0][i] - mindata + 300) * 0.025 * change_y[picclass]); for (int by = nY - 4; by < nY + 4; by++) for (int bx = nX - 4; bx < nX + 4; bx++) memDC.SetPixel(bx, by, RGB(255, 0, 255)); } }改为GDI+
时间: 2024-04-14 11:30:20 浏览: 141
eeprom.rar_EEPROM int_Unsigned_intrins.h_site:www.pudn.com_换头文件e
使用GDI+来实现相同的功能,你可以将上述代码修改如下:
```cpp
if (pressure_detection)
{
Graphics graphics(&memDC);
Pen pen(Color(255, 0, 255)); // 使用RGB颜色创建画笔
for (unsigned int i = 0; i < PRESSURE_DATA_ANOMALY_POS_X[0].size(); i++)
{
float nX = 85 + move_x[picclass] * change_x[picclass] + ceil(PRESSURE_DATA_ANOMALY_POS_X[0][i] * 500 / 1500 * change_x[picclass]);
if (nX > (right - left) - 30) break;
float nY = 4 * rectPicture.Height() / 4 - 30 + move_y[picclass] - ceil((PRESSURE_DATA_ANOMALY_POS_Y[0][i] - mindata + 300) * 0.025 * change_y[picclass]);
graphics.DrawRectangle(&pen, nX - 4, nY - 4, 8, 8);
}
}
```
这里使用了`Graphics`对象来绘制图形,`Pen`对象用于指定画笔的颜色。`DrawRectangle`方法用于绘制一个矩形,你可以根据需要调整矩形的大小和位置。
阅读全文