OpenNETCF で Signature コントロールを使用しています。それは私が必要とするほとんどすべてにうまく機能します。
ただし、署名を反転してロードし直す方法が必要です。
署名の「バイト」を取得するための呼び出しがあります ( GetSignatureEx()
)。byte[]
署名の を返します。この署名は、 で再度読み込むことができますLoadSignatureEx()
。
これらのバイトのシステムを理解できないようです。コーディネートかなと思ったのですが、今は違うようです。
誰かが署名を反転して元に戻す方法を知っている場合は、それを聞いて感謝します.
気にするかもしれない他の人への注意:
これらのバイトは、次の構造を持っているようです (順番に):
幅を示す 2 バイト 高さを表示する 2 バイト -- この次の部分は配列の最後まで繰り返されます 表示する 2 バイト 次の行にいくつのポイントがあるか -- この次の部分は、前の行で示された回数だけ繰り返されます ポイントの x 座標の 1 バイト ポイントの y 座標の 1 バイト ペンの幅は 2 バイト (これについては 100% 確信が持てません)
完了したら、最終的なコードを投稿します。
後でメモ: たくさんの作業を行った後、組み込みのものを使用してビューを簡単に反転できることがわかりました (MusiGenesis に感謝)。それは私にとってプロセスのエラーが発生しにくいようです。
他の誰かがそれを望んでいる場合に備えて、ここに私の未完成のコードがあります。(私は近くにいましたが、次の「行」に進むためのものがうまく機能しません。) (編集:これがもう少しうまくいく方法が好きだと判断しました。以下のコードを更新しました。署名コントロールの幅または高さが256を超えない限り機能します。(以下のctackeの回答を参照)。 )
しかし、最初に、これらすべてを理解するのを手伝ってくれた MusiGenesis に大いに感謝します。あなたはとても役に立ち、私はあなたの努力にとても感謝しています!
今コード:
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;
}
}
}