Please help - another problem on Windows

I have this code which I copied from the LR (just changed the colour values):

[code] Dim startColor As Color = &cf8f7b9
Dim endColor As Color = &cc9c707

Dim p as New Picture(g.Width, g.Height)

Dim samt, eamt As Double

For i As Integer = 0 To p.Height
samt = 1 - (i / p.Height)
eamt = i / p.Height
p.Graphics.ForeColor = RGB((startColor.Red * samt) + (endColor.Red * eamt), _
(startColor.Green *samt) + (endColor.Green * eamt), _
(startColor.Blue * samt) + (endColor.Blue * eamt))
p.Graphics.DrawLine(-1, i, p.Width+1, i)

g.DrawPicture(p, 0, 0)[/code]

This runs fin on my Macintosh. I shifted the Project to Windows and when I Ran it with the debugger I got an error “PlatformNotSupportedException” on the line “Dim p as New Picture(g.Width, g.Height)”. This code is in the Paint Event of the Canvas.

I know that Windows and Macs are different, but what code should I put in here to allow it to work. And if there is different code, I suppose I would have to use the #Pragma controls?

Go to your Windows build settings and enable GDI+.

Or, do it in code.

App.UseGDIPlus = True

Thank you very much Gavin. Do you mind if I ask where you find this information? I have zero experience with Windows.

From the Language Reference for Picture:

[quote]Pictures with alpha channels are supported on Cocoa, Windows (with GDI+ enabled), Linux, console applications, and Web Edition. On platforms without support for alpha channels, a PlatformNotSupported exception is raised when trying to create the Picture.
That should tell you that GDI+ needs to be enabled. A little searching should turn up UseGDIPlus. Or just ask in the forums. :slight_smile:

Thanks Tim. I must look more carefully at the Language Reference. I found the section which enabled me to create a vignette and, as I am on a Mac, it worked. When it didn’t work on Windows I just didn’t think to revisit the LR.

Thanks for all the help I get on this forum. I am looking forward to the day when perhaps I may be able to supply an answer, instead of another question.