E
elziko
I'm using BltBit to create an image from a control:
Private Function Getimage(ByVal ctlSource As Control) As Image
Dim gSource As Graphics = ctlSource.CreateGraphics
Dim imgSource As Image = New Bitmap(Me.ClientRectangle.Width,
Me.ClientRectangle.Height, gSource)
Dim gDest As Graphics = Graphics.FromImage(imgSource)
Dim dcSource As IntPtr = gSource.GetHdc
Dim dcDest As IntPtr = gDest.GetHdc
BitBlt(dcDest, 0, 0, ctlSource.ClientRectangle.Width,
ctlSource.ClientRectangle.Height, dcSource, 0, 0, 13369376)
gSource.ReleaseHdc(dcSource)
gDest.ReleaseHdc(dcDest)
Return imgSource
End Function
However, when I'm running my desktop in 16Bit colour mode the image created
does not match the colours of the control. The grey control backgorund gets
copied as a slightly pinky grey. Switching to 32Bit colour mode solves this
problem.
Is there any way I can get round this colour problem and is their any
quicker way to create an image from a control?
Private Function Getimage(ByVal ctlSource As Control) As Image
Dim gSource As Graphics = ctlSource.CreateGraphics
Dim imgSource As Image = New Bitmap(Me.ClientRectangle.Width,
Me.ClientRectangle.Height, gSource)
Dim gDest As Graphics = Graphics.FromImage(imgSource)
Dim dcSource As IntPtr = gSource.GetHdc
Dim dcDest As IntPtr = gDest.GetHdc
BitBlt(dcDest, 0, 0, ctlSource.ClientRectangle.Width,
ctlSource.ClientRectangle.Height, dcSource, 0, 0, 13369376)
gSource.ReleaseHdc(dcSource)
gDest.ReleaseHdc(dcDest)
Return imgSource
End Function
However, when I'm running my desktop in 16Bit colour mode the image created
does not match the colours of the control. The grey control backgorund gets
copied as a slightly pinky grey. Switching to 32Bit colour mode solves this
problem.
Is there any way I can get round this colour problem and is their any
quicker way to create an image from a control?