Here's the relevant class:
public class GDI
public static extern IntPtr MoveToEx(IntPtr HDC,int X,int Y,IntPtr Point);
public static extern IntPtr LineTo(IntPtr HDC,int X,int Y);
public static extern int SetROP2(IntPtr HDC,int Mode);
public static int R2_NOT=6;
public static int R2_COPYPEN=13;
Here's the code in the pictureBox_paint:
private void pictureBox_Paint(object sender,PaintEventArgs e)
// top secret tile drawing code snipped
And the result:
If you look really closely, in the top left corner of the map is a diagonal line that has been drawn with a inverse raster operation.
Happy happy happy.
I'm wondering, if I figured out how to access BitBlt in C#, if it would be any faster than Graphics.DrawImage() in C#? Thoughts?
[LATER] Interestingly, no it doesn't. I've just been comparing the .NET and C++ versions of my Map application, stress testing by scrolling a big screen being filled with 8x8 rectangles and a CreateHatchBrush() brush.
Even when the C# version imports all the Win32 API GDI calls and basically uses exactly the same functions as the C++ version, the C++ version is still substantially quicker.
Shame but never mind. The C# version is prettier and easier to develop. Swings and roundabouts, I guess. I just don't understand the reason for the difference since I thought that the .NET code was JIT compiled into native machine language when it was run and so would be basically as efficient as the C++ code.