I have this format 66,35^66,41^66,51^66,63^66,75^65,88^65,101^64,114^63,127^63,136^63,140^0,65535^85,101^88,97^93,91^97,85^99,80^102,77^103,75^105,73^106,71^107,69^109,67^110,64^112,61^114,57^116,54^118,50^121,45^123,41^125,38^0,65535^93,93^96,96^101,101^104,104^108,107^111,111^116,116^125,124^134,132^0,65535^184,67^184,72^184,77^184,82^185,85^186,88^188,91^190,92^193,92^196,92^201,90^205,87^209,82^213,76^216,69^218,62^220,55^220,49^220,45^218,43^216,42^214,42^211,43^209,45^206,47^204,49^0,65535^264,37^263,42^260,51^257,61^253,70^250,77^248,81^247,84^248,86^251,88^256,89^261,89^267,89^278,91^289,93^0,65535^64,213^64,220^64,231^64,244^63,257^61,271^60,282^58,291^57,298^56,304^56,306^55,306^55,302^54,294^54,282^54,269^55,255^56,242^58,230^61,219^65,209^69,202^75,198^82,195^89,193^95,192^100,193^102,194^104,197^104,202^104,208^102,215^99,221^97,225^94,227^93,229^0,65535^146,200^145,207^141,219^137,232^133,245^131,255^128,263^126,271^124,277^123,280^0,65535^166,182^166,189^168,202^170,218^170,230^171,241^171,251^170,259^170,266^0,65535^145,233^150,233^158,234^177,237^191,239^0,65535^261,183^260,192^258,206^256,222^253,238^250,253^243,273^0,65535^220,193^226,201^236,211^260,238^281,261^0,65535^~
its an image I want that string to be converted to this format
&E ( ( ! ( _' _& _' _& _' _& _&__^ _&__^ _&__^ _& _'__^ _' _& _' _&___ _& _&___ _' _' _' _' __^ _' _' _' 0 ( ( _/ 0 0 0 ( 0 0 ( 0 0 0 ( 1 ( ( 0 ( ( ( ( ( _/ ( _/ p)% _/ _' _' _' _' _&__^ _% _&__] _%__^__] _&___ & _&__
' _'__
' _' _& ! ) ! + * * + + * 4 + + 3 * + 2 * + 1 " ) ) ) ) ) ) ) ( ) 0 _/ _/ _' _/ _/ _/ _. _. _. _. _. _/ _& _/ _& _/ _' _/ _' _/ _& _/ _' _'p`)#@ P _ Y ! 0 0 1 1 0 9 0 9 9 9 9 0 9 1 0 ) 0 0 p`2&) ' _& _& _& _& _&__^ _&__^ _& _& _& _& _& _' _& _' _' _' _' _' ( ) ! " ) # , " , " + * # ) " * " ) ! ) ! ) ! ( _/ _/ _' _. _. _& _- _& _. _& _. _& _' _& _' _/ _' _& _/ _' _/ ( ( 1 * ; 4 3 + + 3 , + + + " + ! p`<&9 _' _'__^__^_____^__^__V_____^_____^________
' X '__
' _' _' _' ( _/ ( _/ 0 _/ 8 8 0 8 0 0 0 9 8 9 0 1 0 1 0 ) ( ( p`=% 0 ( ( _7 0 8 0 _7 0 0 0 ( 0 0 p`<'! ( ( ! ( ) 1 2 ) 1 1 1p
its an image
There is some code that I use to convert format #2 to image:
procedure SendDebug(msg : string);
begin
Form1.memResult.Lines.Add(msg);
end;
function ConvertSignatureData(rbasigdata : String) : String;
type
TSigPoint = record
X : Integer;
Y : Integer;
Down : Boolean;
end;
var
newx : Word;
newy : Word; // offset X,Y from start coordinate
i : Integer;
maxpoint : TPoint;
minpoint : TPoint;
range : TPoint;
point : TSigPoint; // point current pen position(place holder),
point2 : TSigPoint; // point 2 cordinate that get written to converted format
lastpoint : TSigPoint; // point current pen position(place holder),
osig : String;
isbadsig : Boolean;
// maxpointx : Integer;
// maxpointy : Integer;
// temp : String;
procedure appendResult(str : String);
begin
Result := Result + str;
// SendDebug(Result);
end;
begin
osig := rbasigdata;
// temp := '`),#_ 6_!8_!8_!0_ 6p` $ !B !: !> !; !F! $ _A ^E ^; _Y! S!!#_!B ^2!_? G !A !@_^D ^9!!: !0 & _!^_!X_!Vp`+0W ^, ]7 ^ _+ ]& _+ ]" ^* ^K!!( "9 !( !- ^- ^4 ^0!_/ ": !+ !7 !( "( !*_"Y_!O ], ^( ]$ _) ^ _(';
// temp := temp + ' '' ^/p`.*]!_^!_''!_W!_''! R! Up`./Np`6"V !7 !W !? "8 !3 !. !- !''p`90G ^9 _1 ^> ^= ^= ^= ^3 ^I ^Np`6*H! <" #! "! Z ^G Y"_]___Zp`= $ !+ !/ !$ !)_"[_![_!]"_.!_% _[!_ _@__P__1^^N__,^_C ^! ''!! W !X ! Y';
// temp := temp + '#_^Y_^^p`B Q &'' / "&! -!_< _ _[!^# ^,_^&^_*_ $p`I0% [!__Y [% ]. ^* _2p`J*Q ^+ ^1 ]/p`J/Hp`N(L_!3^ 7_^3 ]'' ^C _R! Wp`R)0_! ^ *__8__Q ^"!_5 W !0 "& ^- _0 ^5 ^^p`Q11 ^- ^, ^3 ]. V p`L,_! 6! <! N S! <';
// temp := temp + '! $! #! +p`R), ^. ^4 ^3 ^4_^Wp`S,:p`V(X^ W_ 4^_=_]W ^5 ^J _S V !D #"p`W)* ^9 ^0 [#__p`V S " _ #! !- 7 !6 !H M! O" !_= ^ ^E ^R ^? ^C ^J ^7 ^Wp';
// osig := temp;
point.x := 0;
point.y := 0;
lastpoint.x := -1;
lastpoint.y := -1;
point.Down := False;
maxpoint.x := 0;
maxpoint.y := 0;
minpoint.y := $7fffffff;
minpoint.x := $7fffffff;
isbadsig := False;
// maxpointx := FSignMaxXCoord;
// maxpointy := FSignMaxYCoord;
i := 1;
// get range
while i < Length(osig) do begin
if Ord(osig[i]) = $070 then begin
Inc(i);
continue;
end;
//Generate Start Cordinates
if (Ord(osig[i]) >= $060) and (Ord(osig[i]) <= $06F) then begin
point.x := (((Ord(osig[i])-$060) and $0C) shl 7);
point.y := (((Ord(osig[i])-$060) and $03) shl 9);
Inc(i);
point.x := point.x or ((Ord(osig[i])-$020) shl 3);
Inc(i);
point.y := point.y or ((Ord(osig[i])-$020) shl 3);
Inc(i);
point.x := (point.x or (((Ord(osig[i])-$020) and $038) shr 3));
point.y := (point.y or ((Ord(osig[i])-$020) and $07));
Inc(i);
end else begin
newx := ((Ord(osig[i])-$020) shl 3);
newx := (newx or (((Ord(osig[i + 2])-$020) and $38) shr 3));
newx := ((newx shl 7) shr 7);
Inc(i);
newy := ((Ord(osig[i])-$020) shl 3);
newy := (newy or ((Ord(osig[i + 1])-$020) and $07));
newy := ((newy shl 7) shr 7);
Inc(i);
if WordBool(newx and $0100) then
point.x := point.x - Byte((newx or $0600) xor $01FF) - 1
else
point.x := point.x + Byte(newx);
if WordBool(newy and $0100) then
point.y := point.y - Byte((newy or $0600) xor $01FF) - 1
else
point.y := point.y + Byte(newy);
if (point.x < minpoint.x) or (i = 4) then
minpoint.x := point.x;
if (point.x > maxpoint.x) or (i = 4) then
maxpoint.x := point.x;
if (point.y < minpoint.y) or (i = 4) then
minpoint.y := point.y;
if (point.y > maxpoint.y) or (i = 4) then
maxpoint.y := point.y;
Inc(i);
end;
end;
SendDebug(Format('ConvertSignatureData MINX = %d',[minpoint.x]));
SendDebug(Format('ConvertSignatureData MAXX = %d',[maxpoint.x]));
SendDebug(Format('ConvertSignatureData MINY = %d',[minpoint.y]));
SendDebug(Format('ConvertSignatureData MAXY = %d',[maxpoint.y]));
range.X := maxpoint.X - minpoint.X;
range.Y := maxpoint.Y - minpoint.Y;
SendDebug(Format('ConvertSignatureData Calc Ranges X:%4.4d Y:%4.4d @5614',[range.X,range.Y]));
if isbadsig then begin
// I let the routine continue to this point (even though we know this sig is bad) in order to log the max x/y points to trace.
Result := 'BADSIG';
SendDebug('ConvertSignatureData Bad Sig - appears to have extended off screen. Reprompt for signature @5619');
Exit;
end;
Result := '';
appendResult('%');
i := 1;
while i < Length(osig) do begin
if Ord(osig[i]) = $070 then begin
point.Down := False;
appendResult('%');
Inc(i);
continue;
end;
//Generate Start Cordinates
if (Ord(osig[i]) >= $060) and (Ord(osig[i]) <= $06F) then begin
point.x := (((Ord(osig[i])-$060) and $0C) shl 7);
point.y := (((Ord(osig[i])-$060) and $03) shl 9);
Inc(i);
point.x := point.x or ((Ord(osig[i])-$020) shl 3);
Inc(i);
point.y := point.y or ((Ord(osig[i])-$020) shl 3);
Inc(i);
point.x := (point.x or (((Ord(osig[i])-$020) and $038) shr 3));
point.y := (point.y or ((Ord(osig[i])-$020) and $07));
point2.x := point.x - minpoint.x;
point2.y := range.y - Abs(point.y - minpoint.y);
point2.Down := point.Down;
appendResult(Format('%4.4d%4.4d',[Abs(point2.X),Abs(point2.Y)]));
if not point.Down then
point.Down := True;
Inc(i);
end else begin
newx := ((Ord(osig[i])-$020) shl 3);
newx := (newx or (((Ord(osig[i + 2])-$020) and $38) shr 3));
newx := ((newx shl 7) shr 7);
Inc(i);
newy := ((Ord(osig[i])-$020) shl 3);
newy := (newy or ((Ord(osig[i + 1])-$020) and $07));
newy := ((newy shl 7) shr 7);
Inc(i);
if WordBool(newx and $0100) then
point.x := point.x - Byte((newx or $0600) xor $01FF) - 1
else
point.x := point.x + Byte(newx);
if WordBool(newy and $0100) then
point.y := point.y - Byte((newy or $0600) xor $01FF) - 1
else
point.y := point.y + Byte(newy);
Inc(i);
end;
lastpoint.y := point.y; // between the point the pen loses contact and the point contact is re-initiated
point2.x := point.x - minpoint.x;
point2.y := range.y - Abs(point.y - minpoint.y);
point2.Down := point.Down;
appendResult(Format('%4.4d%4.4d',[Abs(point2.X),Abs(point2.Y)])); //FTransRec.Signature.WriteBuffer(point2,SizeOf(point2));
end;
end;
How do I convert format #1 into format #2?