除了代码本身可以直接访问内存的事实.使用"/ unsafe"编译器标志和"fixed"关键字的其他含义是什么?是否存在与我的.exe的代码签名和部署相关的影响(我的应用程序仅限桌面)?
(这不是关于我是否应该这样做,为什么我的问题在这里讨论)
我正在制作一个小型油漆程序.我在位图上使用SetPixel来绘制线条.当画笔大小变大时,如同25个像素一样,会有明显的性能下降.我想知道是否有更快的方法来绘制位图.以下是该项目的背景:
我将包括我的绘图代码,以防万一这是缓慢而不是Set-Pixel位.
这是在绘画发生的窗口:
private void canvas_MouseMove(object sender, MouseEventArgs e)
{
m_lastPosition = m_currentPosition;
m_currentPosition = e.Location;
if(m_penDown && m_pointInWindow)
m_currentTool.MouseMove(m_lastPosition, m_currentPosition, m_layer);
canvas.Invalidate();
}
Run Code Online (Sandbox Code Playgroud)
MouseMove的实现:
public override void MouseMove(Point lastPos, Point currentPos, Layer currentLayer)
{
DrawLine(lastPos, currentPos, currentLayer);
}
Run Code Online (Sandbox Code Playgroud)
DrawLine的实现:
// The primary drawing code for most tools. A line is drawn from the last position to the current position
public override void DrawLine(Point lastPos, Point currentPos, Layer currentLayer)
{
// Creat a line vector
Vector2D vector …Run Code Online (Sandbox Code Playgroud)