I have tried going about this a different way, and I am calling the following in my render loop:
Public Sub DrawTempWindow()
If Not InGame Then Exit Sub
Dim e As New PaintEventArgs(frmMainGame.Panel1.CreateGraphics(), frmMainGame.Panel1.Bounds)
Dim tempImage = New Bitmap(frmMainGame.GameScreen.Width, frmMainGame.GameScreen.Height, PixelFormat.Format24bppRgb)
Dim memoryGraphics As Graphics = Graphics.FromImage(tempImage)
Dim screenPos As Point = frmMainGame.GameScreen.PointToScreen(New Point(0, 0))
memoryGraphics.CopyFromScreen(screenPos.X, screenPos.Y, 0, 0, frmMainGame.GameScreen.Size)
Dim destRect As New Rectangle(0, 0, frmMainGame.Panel1.Width, frmMainGame.Panel1.Height)
Dim srcRect As New Rectangle(frmMainGame.GameScreen.Location.X, frmMainGame.GameScreen.Location.Y, frmMainGame.Panel1.Width, frmMainGame.Panel1.Height)
e.Graphics.DrawImage(tempImage, destRect, srcRect, GraphicsUnit.Pixel)
tempImage.Dispose()
memoryGraphics.Dispose()
Dim attributes As New ImageAttributes
Dim matrixElements As Single()() = { _
New Single() {1.0F, 0.0F, 0.0F, 0.0F, 0.0F}, _
New Single() {0.0F, 1.0F, 0.0F, 0.0F, 0.0F}, _
New Single() {0.0F, 0.0F, 1.0F, 0.0F, 0.0F}, _
New Single() {0.0F, 0.0F, 0.0F, CSng(0.4), 0.0F}, _
New Single() {0.0F, 0.0F, 0.0F, 0.0F, 1.0F}}
Dim matrix As ColorMatrix
matrix = New ColorMatrix(matrixElements)
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default,
ColorAdjustType.Bitmap)
Dim bitmap As Bitmap = New Bitmap(frmMainGame.Panel1.Width, frmMainGame.Panel1.Height, PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(bitmap)
Dim brush As Brush = New SolidBrush(frmMainGame.Panel1.BackColor)
g.FillRectangle(brush, New RectangleF(0, 0, frmMainGame.Panel1.Width, frmMainGame.Panel1.Height))
brush.Dispose()
e.Graphics.DrawImage(bitmap, _
New Rectangle(0, 0, frmMainGame.Panel1.Width, frmMainGame.Panel1.Height), _
0, 0, frmMainGame.Panel1.Width, frmMainGame.Panel1.Height, GraphicsUnit.Pixel, attributes)
bitmap.Dispose()
g.Dispose()
brush.Dispose()
End Sub
This shows an almost working transparent panel. The location of my picturebox (GameScreen) and panel1 are both (208, 0), and my panel1 is 200x200 size. This displays offset, so it is getting the image 208 pixels to the right of my panel1. When I set [srcRect As New Rectangle(frmMainGame.GameScreen.Location.X - 208,...] it displays what is under the form, but if I only set it halfway, it will display an offset of 104 pixels, and also show 2 sections on my panel1 where it is picking up the panel1 when it takes the initial image.
I have tried turning the visibility off, getting the image, then turning panel1 visibility back on, then drawing the image, but I get the same results.
Alternatively I have also searched on how to use panel1 as a RenderWindow, then Draw() the image the same way as I do sprites, but I can find nothing on rendering an entire image, or converting the bitmap that is drawn with e.graphics to a texture.