Public Shared Function GetColoredSquare(ByVal red As Integer, ByVal green As Integer, ByVal blue As Integer, ByVal size As Integer) As Bitmap
If red < 0 Or red > 255 Then Throw New Exception("Invalid red value supplied")
If green < 0 Or green > 255 Then Throw New Exception("Invalid green value supplied")
If blue < 0 Or blue > 255 Then Throw New Exception("Invalid blue value supplied")
If size <= 0 Then Throw New Exception("Invalid size supplied")
Try
Dim Bitmap As Bitmap = New Bitmap(size, size, Imaging.PixelFormat.Format24bppRgb)
Dim Graphic As Graphics = Graphics.FromImage(Bitmap)
Graphic = Graphics.FromImage(Bitmap)
Graphic.Clear(System.Drawing.Color.FromArgb(255, red, green, blue))
Return Bitmap
Catch ex As Exception
Throw New Exception("An error occured while creating colored bitmap", ex)
End Try
End Function
Χρήστος Γεωργακόπουλος