Hi,
I'm failing to make bitmap with a transparent background. (Yes, that might be a bit of an impossibility)
I'm making a cursor from an image within a picturebox, The cursor is made but I can't make it's background transparent which makes a pretty poor cursor.
I discovered early-on that 'TransparentKey' only seems to work with a whole Form, not individual controls.
I've saved the image that I've made from the picturebox image, tried to save it as a .png but when opened in PaintShop Pro the background is not transparent.
In the following code, I've retained all my attempts so that you can see what I've tried, but the codes which don't work are just remarked-out. (Line 6 also shows the Intellisence error notification.)
Poppa
I'm failing to make bitmap with a transparent background. (Yes, that might be a bit of an impossibility)
I'm making a cursor from an image within a picturebox, The cursor is made but I can't make it's background transparent which makes a pretty poor cursor.
I discovered early-on that 'TransparentKey' only seems to work with a whole Form, not individual controls.
I've saved the image that I've made from the picturebox image, tried to save it as a .png but when opened in PaintShop Pro the background is not transparent.
In the following code, I've retained all my attempts so that you can see what I've tried, but the codes which don't work are just remarked-out. (Line 6 also shows the Intellisence error notification.)
vb.net Code:
Private Sub MakeCursor() 'PictureBox1.BackColor = Color.Transparent 'PictureBox1.Refresh() CaptureImage(PictureBox1) Cur = New Bitmap(map) 'Cur.BackColor = Color.Transparent !! BackColor is not a member of Bitmap. Dim ptrCur As IntPtr = Cur.GetHicon Csr = New Cursor(ptrCur) Me.Cursor = Csr map.Dispose() End Sub Private Sub CaptureImage(ctrl As Control) With ctrl map = New Bitmap(.Width, .Height) 'This next line doesn't fail, but doesn't seem to work either. :o( .BackColor = Color.Transparent .DrawToBitmap(map, .ClientRectangle) End With ' Temp. map.Save("C:\Temp\ImageTrial.png", ImageFormat.Png) End Sub
Poppa