I can't seem to figure out how to draw a gradient to a bitmap I created in code. I have the background fading with a crazy bouncing sort of gradient with this code (paste it into a project if U wanna see it )
VB Code:
Dim m_intAntiBlueC1 As Integer = 255
Dim m_intAntiBlueC2 As Integer = 0
Dim m_blnC1GoUp As Boolean
Dim graphics As Graphics
graphics = Me.CreateGraphics()
Dim c1 As Color = Color.FromArgb(m_intAntiBlueC1, m_intAntiBlueC1, 200)
Dim c2 As Color = Color.FromArgb(m_intAntiBlueC2, m_intAntiBlueC2, 200)
Dim brush As New Drawing2D.LinearGradientBrush(Me.DisplayRectangle, c1, c2, Drawing2D.LinearGradientMode.ForwardDiagonal)
I can't seem to create a graphics area from the bitmap itself so I don't know any other way to draw graphics data onto the bitmap. Anyone know how to do it?
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature
I just added some code through the wonderful logic of creating a new object every time it asked for one without fully knowing what the object is :P
VB Code:
Dim TheBit As New Bitmap(295, 80)
Dim graphics2 As Graphics
Dim IntPtr As IntPtr
IntPtr = TheBit.GetHbitmap()
graphics2 = Drawing.Graphics.FromHwnd(IntPtr)
Dim rect As New RectangleF()
rect = graphics2.VisibleClipBounds
graphics2.FillRectangle(brush, rect)
but it stops at the graphics2 = Drawing.Graphics.FromHwnd(IntPtr) line and gives me an error that simply says "out of memory" and that's it. I'm gonna ask my teacher tonight to teach us about handles and pointers and all that crap for like the millionth time grrrrrrrrrr
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature
yeah I know doing it with a picturebox would be super simple but I eventually want to assign the bitmap to the background image on a label control, effectively making a really cool moving background. I think I'll just stick a picturebox under the label and make it transparent
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature
well, that didn't work. I set the backcolor to transparent and it still shows up as control gray or whatever. That's never happened before, what's up with that?
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature
uh oh, post delay :P that one above my last one worked w00t. Why did they have to hide FromImage so well? geeeeeeeeeeze. But for some odd reason when I do TheLabel.Image = TheBitmap, it renders correctly on the left but not on the right. It's like it's overflowing even though I double checked and the label and bitmap and graphics area are all drawing to the correct size. I'll post a video or gif of it when I get home :P
Okay nm here's screenshots :P here's the important parts of code having to do with size:
VB Code:
Dim TheBit As New Bitmap(295, 80)
graphics2 = Drawing.Graphics.FromImage(TheBit)
graphics2.FillRectangle(brush, 0, 0, 295, 80)
and yet, here's one "peak" and the other "peak" of the gradient cycle from 0-255. According to Pixie, it only reaches about 33 on one peak and 86 on the other, suggesting the gradient bitmap doesn't fit in the area, except the label really is 295x80. Like on the 2nd peak here, it should be 100% purple on the right and on the first one it should be close to 100% yellow on the left but they're WAY off
Here's the actual, complete code if U wanna try it:
VB Code:
'module lvl:
Dim m_intAntiBlueC1 As Integer = 255
'timer tick sub:
If m_intAntiBlueC1 >= 255 Then
m_blnC1GoUp = False
ElseIf m_intAntiBlueC1 <= 0 Then
m_blnC1GoUp = True
End If
If m_blnC1GoUp Then
m_intAntiBlueC1 += 3
Else
m_intAntiBlueC1 -= 3
End If
Dim graphics As Graphics
graphics = Me.CreateGraphics()
Dim c1 As Color = Color.FromArgb(m_intAntiBlueC1, m_intAntiBlueC1, 200)
Dim c2 As Color = Color.FromArgb(255 - m_intAntiBlueC1, 255 - m_intAntiBlueC1, 200)
Dim brush As New Drawing2D.LinearGradientBrush(Me.DisplayRectangle, c1, c2, Drawing2D.LinearGradientMode.ForwardDiagonal)
OMG
I just realized I was using the form's display rectangle in the redeclaration of the brush! AHHHHHHHHHHHH!!!!!!!!!!!!!!!
Here's the real real real real real REAL code if U wanna see the absolute beautiful awesome!
VB Code:
If m_intAntiBlueC1 >= 255 Then
m_blnC1GoUp = False
ElseIf m_intAntiBlueC1 <= 0 Then
m_blnC1GoUp = True
End If
If m_blnC1GoUp Then
m_intAntiBlueC1 += 3
Else
m_intAntiBlueC1 -= 3
End If
Dim graphics As Graphics
graphics = Me.CreateGraphics()
Dim c1 As Color = Color.FromArgb(m_intAntiBlueC1, m_intAntiBlueC1, 200)
Dim c2 As Color = Color.FromArgb(255 - m_intAntiBlueC1, 255 - m_intAntiBlueC1, 200)
Dim brush As New Drawing2D.LinearGradientBrush(Me.DisplayRectangle, c1, c2, Drawing2D.LinearGradientMode.ForwardDiagonal)