private void Start() { renderThread = new System.Threading.Thread(new System.Threading.ThreadStart(RenderDX)); renderThread.Name = "Render Thread"; renderThread.Priority = System.Threading.ThreadPriority.Lowest; DoRender = true; isRendering = false; isSuspended = false; renderThread.Start(); ledBlinkTimer = PrecisionTimer.TimeInSeconds(); }
void PaintMap() { while (run) { double currentTime = PrecisionTimer.TimeInSeconds(); if (currentTime - lastTime < 1.0f) { continue; } lastTime = currentTime; //panel1.Invalidate(); //continue; Rectangle rect = new Rectangle(0, 0, bmpOut.Width, bmpOut.Height); System.Drawing.Imaging.BitmapData bmpData = bmpOut.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmpOut.PixelFormat); IntPtr ptr = bmpData.Scan0; unsafe { int *p = (int *)ptr.ToPointer(); for (int f = 0; f < 65536; f++) { int colorIndex = (int)(heatMap[f] % 7); if (colorIndex > 7) { colorIndex = 7; } *(p) = heatColors[colorIndex].ToArgb(); *(p + 1) = heatColors[colorIndex].ToArgb(); *(p + MAP_WIDTH) = heatColors[colorIndex].ToArgb(); *(p + MAP_WIDTH + 1) = heatColors[colorIndex].ToArgb(); p++; p++; //*(p++) = heatColors[colorIndex].ToArgb(); if ((f + 1) % 256 == 0) { p = p + MAP_WIDTH; } heatMap[f] = 0; } } bmpOut.UnlockBits(bmpData); pictureBox1.Image = bmpOut; //pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } }
public CodeProfiler(Form1 zw) { InitializeComponent(); ziggyWin = zw; panel1.Size = new Size(MAP_WIDTH, MAP_HEIGHT); lastTime = PrecisionTimer.TimeInSeconds(); ziggyWin.zx.MemoryWriteEvent += MemoryWriteEventHandler; ziggyWin.zx.FrameEndEvent += FrameEndEventHandler; this.Invalidate(); paintThread = new Thread(new ThreadStart(PaintMap)); paintThread.Name = "Heatmap Thread"; paintThread.Priority = System.Threading.ThreadPriority.Normal; paintThread.Start(); }
void PaintMap() { while (run) { double currentTime = PrecisionTimer.TimeInSeconds(); if (currentTime - lastTime < 1.0f) { continue; } lastTime = currentTime; Rectangle rect = new Rectangle(0, 0, bmpOut.Width, bmpOut.Height); System.Drawing.Imaging.BitmapData bmpData = bmpOut.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bmpOut.PixelFormat); IntPtr ptr = bmpData.Scan0; unsafe { int *p = (int *)ptr.ToPointer(); for (int f = 0; f < 65536; f++) { int colorIndex = (int)(heatMap[f] % 7); if (colorIndex > 7) { colorIndex = 7; } *(p++) = heatColors[colorIndex].ToArgb(); } } bmpOut.UnlockBits(bmpData); pictureBox1.Image = bmpOut; } }