Pregunta de control de firma OpenNETCF

Estoy usando el control Signature en OpenNETCF. Funciona muy bien para casi todo lo que necesito.

Sin embargo, necesito una forma de invertir la firma y volver a cargarla.

Tiene una llamada para obtener los "bytes" para la firma (GetSignatureEx()) Devuelve unbyte[] de la firma. Esta firma se puede volver a cargar conLoadSignatureEx().

Parece que no puedo entender el sistema para estos bytes. Pensé que podrían ser coordenadas, pero ahora no lo parece.

Si alguien conoce una forma de invertir la firma y volver a cargarla, agradecería escucharla.

Nota para otras personas que pueden interesarse:

Estos bytes parecen tener la siguiente estructura (en orden):

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)  

Publicaré mi código final una vez que lo haya hecho.

Nota posterior: Ok, después de toneladas de trabajo, descubrí lo fácil que es voltear la vista usando las cosas integradas (gracias MusiGenesis). Eso parece ser un proceso menos propenso a errores para mí.

Por si alguien más lo quiere, aquí está miinconcluso código. (Estaba cerca pero las cosas para avanzar a la siguiente "línea" no funcionan del todo bien). (EDITAR: decidí que me gustó la forma en que esto funcionó un poco más. He actualizado el código a continuación. Funcionará siempre que el ancho o la altura del control Signature no sea mayor que 256. (Consulte la respuesta de ctacke a continuación). )

Pero primero, muchas gracias a MusiGenesis que me ayudó a resolver todo esto. ¡Eres muy útil y aprecio mucho tus esfuerzos!

Ahora el 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;
        }
    }
}

Respuestas a la pregunta(2)

Su respuesta a la pregunta