J
Jay Dee
I have an application that stores colour text to file currently as 4
bytes for each character (Char, Red, Green, Blue). As you can imagine,
this creates rather large files and is not ideal.
The required selection of colours is minimal and the base 16 colours
available as standard in something like MS Paint would be sufficient.
Is there a simple way to store a colour as 1 byte rather than 3?
I understand that a rounding factor would have to be applied so the
colour out may not be exactly the same as the colour in and would end
up the nearest match and don’t see this as a problem.
Finally I then intend to store a number of consecutive matching bytes,
e.g. if all text is black for the first 100 characters store the
colour black once along with the number 100 as integer or something.
I don’t se this being a problem eather.
What I am asking is for some help with the rounding formula required
for storing a colour as a single byte if possible.
public byte ColorToByte(Color color)
{
// TODO
// alpha value douse not need to be considered
}
public Color ByteToColor (byte byteIn)
{
// TODO
// alpha value douse not need to be considered
}
Many thanks to anyone with some input.
Jay Dee
bytes for each character (Char, Red, Green, Blue). As you can imagine,
this creates rather large files and is not ideal.
The required selection of colours is minimal and the base 16 colours
available as standard in something like MS Paint would be sufficient.
Is there a simple way to store a colour as 1 byte rather than 3?
I understand that a rounding factor would have to be applied so the
colour out may not be exactly the same as the colour in and would end
up the nearest match and don’t see this as a problem.
Finally I then intend to store a number of consecutive matching bytes,
e.g. if all text is black for the first 100 characters store the
colour black once along with the number 100 as integer or something.
I don’t se this being a problem eather.
What I am asking is for some help with the rounding formula required
for storing a colour as a single byte if possible.
public byte ColorToByte(Color color)
{
// TODO
// alpha value douse not need to be considered
}
public Color ByteToColor (byte byteIn)
{
// TODO
// alpha value douse not need to be considered
}
Many thanks to anyone with some input.
Jay Dee