QDataStream

Don’t ask me why but try this code:

// background color
outputStream.WriteUInt8 (1) // RGB is Type 1
outputStream.WriteUInt8 (255) // Alpha channel = fully opaque
outputStream.WriteUInt8 (255)
outputStream.WriteUInt8 (255) // Red
outputStream.WriteUInt8 (255) 
outputStream.WriteUInt8 (255) // Green
outputStream.WriteUInt8 (255)
outputStream.WriteUInt8 (255) // Blue
outputStream.WriteUInt8 (255)
outputStream.WriteUInt16 (0) // Pad

// foreground color
outputStream.WriteUInt8 (1) // RGB is Type 1
outputStream.WriteUInt8 (255) // Alpha channel = fully opaque
outputStream.WriteUInt8 (255)
outputStream.WriteUInt8 (255) // Red
outputStream.WriteUInt8 (255)
outputStream.WriteUInt8 (0) // Green
outputStream.WriteUInt8 (0)
outputStream.WriteUInt8 (0) // Blue
outputStream.WriteUInt8 (0)
outputStream.WriteUInt16 (0) // Pad

Here’s my latest try with some help from the WSJT-X team, but instead of creating foreground and background colors it simply erases the intended text, leaving a blank white on white space.

I’m trying to get more info from them but I seem to be a complete idiot in dealing with the source forge mailing list, so I don’t know if my query is getting posted or not.

Public Sub ChangeColors(callSign As String)
Dim mb As New MemoryBlock (0)
Dim outputStream As New BinaryStream (mb)
Dim utf8 As String

outputStream.LittleEndian = False

outputStream.WriteUInt32 (magicNumber)
outputStream.WriteUInt32 (2)
outputStream.WriteUInt32 (13) ’ Clear

// Id (unique key)
utf8 = id.ConvertEncoding (Encodings.UTF8)
outputStream.WriteUInt32 (LenB (utf8))
outputStream.Write (utf8)

// callSign
utf8 = callSign.ConvertEncoding (Encodings.UTF8)
outputStream.WriteUInt32 (LenB (utf8))
outputStream.Write (utf8)

// background color
Dim c As Color = &cff0000 ’ Defaults to Alpha value 0
outputStream.WriteUInt8 (1) ’ RGB spec
outputStream.WriteUInt16 (c.Alpha)
outputStream.WriteUInt16 (c.Red)
outputStream.WriteUint16 (c.Green)
outputStream.WriteUInt16 (c.Blue)
outputStream.WriteUInt16 (0) ’ padding

// foreground color
c = &c0000ff ’ Defaults to Alpha value 0
outputStream.WriteUInt8 (1) ’ RGB spec
outputStream.WriteUInt16 (c.Alpha)
outputStream.WriteUInt16 (c.Red)
outputStream.WriteUint16 (c.Green)
outputStream.WriteUInt16 (c.Blue)
outputStream.WriteUInt16 (0) ’ padding

// Highlight last
outputStream.WriteBoolean (False)

// close the BinaryStream
outputStream.Close

Dim msg As new Datagram

msg.Address = WSJTX_IP
msg.Port = WSJTX_Port
msg.Data = mb
WSJTX_Socket.Write (msg)

End Sub

Ed, Qt serialize colors as I posted in my previous message.
Alpha, Red, Green and Blue are 16 bits values not 8 bit values emitted as a 16 bits values.
For example a full red color has the red part emitted as &hffff not &h00ff.

YES!!!

Mille grazie, Maurizio!