Pergunta de controle de assinatura do OpenNETCF

Estou usando o controle de assinatura no OpenNETCF. Funciona muito bem para quase tudo que eu preciso.

No entanto, preciso inverter a assinatura e carregá-la novamente.

Ele possui uma chamada para obter os "bytes" da assinatura (GetSignatureEx()) Retorna umbyte[] da assinatura. Essa assinatura pode ser carregada novamente comLoadSignatureEx().

Não consigo descobrir o sistema para esses bytes. Eu pensei que eles podem ser coordenadas, mas não parece tão agora.

Se alguém lá fora souber uma maneira de inverter a assinatura e carregá-la novamente, ficaria grato em ouvi-la.

Nota para outras pessoas que possam se importar:

Esses bytes parecem ter a seguinte estrutura (em ordem):

2 bytes to show Width  
2 bytes to show Height  
  -- This next part repeats till the end of the array  
  2 bytes to show How many points are in the next line  
    -- This next part repeats as many times as the previous line indicated  
    1 byte for the x coordinate of the point  
    1 byte for the y coordinate of the point  
    2 bytes for the width of the pen (I am not 100% sure on this one)  

Vou postar meu código final assim que o fizer.

Nota posterior: Ok, depois de muito trabalho, descobri como é fácil mudar a visualização usando o material incorporado (obrigado MusiGenesis). Isso parece ser muito menos propenso a erros de um processo para mim.

Caso alguém queira, aqui está o meuinacabado código. (Eu estava perto, mas o material para avançar para a próxima "linha" não funciona muito bem.) (Edição: Decidi que gostei da maneira como isso funcionou um pouco mais. Atualizei o código abaixo. Ele funcionará enquanto a largura ou altura do controle Signature não for maior que 256. (Veja a resposta de ctacke abaixo). )

Mas primeiro, muito obrigado ao MusiGenesis, que me ajudou a descobrir tudo isso. Você é muito prestativa e agradeço muito seus esforços!

Agora o código:

private void InvertSignature(ref byte[] original)
{
    int currentIndex = 0;
    short width = BitConverter.ToInt16(original, 0);
    short height = BitConverter.ToInt16(original, 2);
    while (currentIndex < original.Length - 4)
    {
        // Move past the last iteration (or the width and hight for the first time through).
        currentIndex += 4;
        // Find the length of the next segment.
        short nextGroup = BitConverter.ToInt16(original, currentIndex);
        //Advance one so we get past the 2 byte group
        currentIndex += 2;
        // Find the actual index of the last set of coordinates for this segment.
        int nextNumberOfItems = ((nextGroup) * 4) + currentIndex;
        // Invert the coordinates
        for (int i = currentIndex; i < (nextNumberOfItems - 1); i += 4)
        {
            currentIndex = i;

            //Invert Horizontal
            int newHorzPoint = width - original[i] - 1;
            if (newHorzPoint <= 0)
                newHorzPoint = 0;
            else if (newHorzPoint >= width - 1)
                newHorzPoint = width - 1;
            original[i] = (byte)newHorzPoint;

            // Invert Vertical
            int newVertPoint = height - original[i + 1] - 1;
            if (newVertPoint <= 0)
                newVertPoint = 0;
            else if (newVertPoint >= height - 1)
                newVertPoint = height - 1;
            original[i + 1] = (byte)newVertPoint;
        }
    }
}

questionAnswers(2)

yourAnswerToTheQuestion