Problem passing a Bitmap parameter to a sub

  • Thread starter Thread starter Les2011
  • Start date Start date
L

Les2011

Guest
CalculateEquationCoordinates(equationBuffer)


Sub CalculateEquationCoordinates(Buffer As Bitmap)
Using g As Graphics = Graphics.FromImage(Buffer),
fmt As StringFormat = CType(StringFormat.GenericTypographic.Clone, StringFormat)
fmt.FormatFlags = fmt.FormatFlags Or StringFormatFlags.MeasureTrailingSpaces

THE ABOVE CALL WORKS FINE, I PASS EQUATIONBUFFER TO THE SUB


HOWEVER THE FOLLOWING SENDS EQUATIONBUFFER TO THE SUB BUT PRODUCES THE FOLLOWING ERROR

+++++++System.Argument Exception: Parameter is not valid+++++++++++++

(How is it ok for the above call to be able to send the argument to the sub into the FromImage but in the following produces the above error once it sees buffer in the FromImage)


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 'Next Step
If TotalEquationSteps < MaxEquationSteps Then
TotalEquationSteps = TotalEquationSteps + 1
paintEquation(equationBuffer, TotalEquationSteps)
Else
Beep()
End If
End Sub

Sub paintEquation(buffer As Bitmap, TES As Integer)







Ifbuffer IsequationBuffer Then


ResizeEquationBuffer(5000, 5000)


Else


ResizeHelpBuffer(5000, 5000)


EndIf

Using g As Graphics = Graphics.FromImage(buffer),
fmt As StringFormat = CType(StringFormat.GenericTypographic.Clone, StringFormat)
fmt.FormatFlags = fmt.FormatFlags Or StringFormatFlags.MeasureTrailingSpaces



What I do see if I leave out the IF -THEN -ELSE statement the code works fine????I just cant see what the problem is

Thanks in advance for your help

Les

Continue reading...
 
Back
Top