Hi John,
I’ve noticed that calling dispose on the Graphics object also seems to dispose the underlying image. Is this the correct behaviour?
Example:
var displayController = DisplayController.GetDefault();
displayController.ApplySettings(new ParallelDisplayControllerSettings
{
Width = 480,
Height = 272,
DataFormat = DisplayDataFormat.Rgb565,
PixelClockRate = 20000000,
PixelPolarity = false,
OutputEnablePolarity = true,
OutputEnableIsFixed = false,
HorizontalFrontPorch = 2,
HorizontalBackPorch = 2,
HorizontalSyncPulseWidth = 41,
HorizontalSyncPolarity = false,
VerticalFrontPorch = 2,
VerticalBackPorch = 2,
VerticalSyncPulseWidth = 10,
VerticalSyncPolarity = false,
});
var screen = Graphics.FromHdc(displayController.Hdc);
var image = new Bitmap(100, 100);
using (var graphics = Graphics.FromImage(image))
{
graphics.FillRectangle(new SolidBrush(Color.Green), 0,0,100,100);
}
screen.DrawImage(image,0,0); // Throws null reference exception
screen.Flush();