'Sets the color of the specified point.
Public Sub SetARGB(x As Int, y As Int, ARGB As ARGBColor)
SetPremultipliedColor(x, y, ARGBToPremultipliedColor(ARGB, tempPM))
End Sub
'Sets the color of the specified point.
Public Sub SetPremultipliedColor (x As Int, y As Int, Premultiplied As PremultipliedColor)
Dim cp As Int = x * 4 + y * mWidth * 4
#if B4i
Bit.FastArraySetByte(mBuffer, cp + ri, Premultiplied.r)
Bit.FastArraySetByte(mBuffer, cp + gi, Premultiplied.g)
Bit.FastArraySetByte(mBuffer, cp + bi, Premultiplied.b)
Bit.FastArraySetByte(mBuffer, cp + ai, Premultiplied.a)
#else
mBuffer(cp + ri) = Premultiplied.r
mBuffer(cp + gi) = Premultiplied.g
mBuffer(cp + bi) = Premultiplied.b
mBuffer(cp + ai) = Premultiplied.a
#End If
End Sub
'Converts an ARGB color to PremultipliedColor.
'The Result parameter will hold the output.
Public Sub ARGBToPremultipliedColor (ARGB As ARGBColor, PM As PremultipliedColor) As PremultipliedColor
Dim a As Float = ARGB.a / 255
PM.a = ARGB.a
PM.r = ARGB.r * a
PM.g = ARGB.g * a
PM.b = ARGB.b * a
Return PM
End Sub
'Gets the color of the given point as an ARGB color.
'The Result parameter stores the output.
Public Sub GetARGB (x As Int, y As Int, Result As ARGBColor) As ARGBColor
Dim cp As Int = x * 4 + y * mWidth * 4
#if B4i
Result.a = Bit.FastArrayGetByte(mBuffer, cp + ai)
Dim af As Float = Result.a / 255
Result.r = Bit.FastArrayGetByte(mBuffer, cp + ri) / af
Result.g = Bit.FastArrayGetByte(mBuffer, cp + gi) / af
Result.b = Bit.FastArrayGetByte(mBuffer, cp + bi) / af
#Else
Result.a = Bit.And(0xff, mBuffer(cp + ai))
Dim af As Float = Result.a / 255
Result.r = Bit.And(0xff, mBuffer(cp + ri)) / af
Result.g = Bit.And(0xff, mBuffer(cp + gi)) / af
Result.b = Bit.And(0xff, mBuffer(cp + bi)) / af
#End If
Return Result
End Sub