Форум: "Начинающим";
Текущий архив: 2007.04.01;
Скачать: [xml.tar.bz2];
ВнизКак сохранить TBitmap в XML? Найти похожие ветки
← →
Ш-К (2007-03-13 01:34) [0]У меня есть структура, одно из полей которой TBitmap. Все другие поля в XML я сохраняю и читаю.
Как быть с произвольным набором байт?
← →
Kolan © (2007-03-13 09:17) [1]> Как быть с произвольным набором байт?
Превратить в символы. Например с помошью кодировки base64 или ASCII символов 0..9, A..F
← →
tesseract © (2007-03-13 10:29) [2]
> Как быть с произвольным набором байт?
сохрани как поток байтов в поле, я так делал но с ini.
← →
Ш-К (2007-03-13 14:01) [3]Какими функциями сохранить / прочитать битмап в стринг типа:
BMP="AQAAAfY+AABCTfY+AAAAAAAAdgAAACgAAADIAAAAoAAAAAEABAAAA...."
Пример стринга взят из файла:
C:\Program Files\Common Files\Borland Shared\Data\animals.xml
Или в другой формат стринга.
Kolan © (13.03.07 09:17) [1]
tesseract © (13.03.07 10:29) [2]
Это мне ни о чем не говорит ((
← →
Zeqfreed © (2007-03-13 14:04) [4]http://en.wikipedia.org/wiki/Base64
Или вам сразу на тарелочке с каемочкой?
← →
Ш-К (2007-03-13 14:11) [5]Неужели на всю Delphi токой функции нет.
Как-то ж они сами читают?
← →
Kolan © (2007-03-13 16:12) [6]> Это мне ни о чем не говорит ((
Тогда забудь про сохранения картинок в xml :)
← →
Ш-К (2007-03-13 17:12) [7]Я пришел на форум для начинающих спросить, как записать произвольный набор байт в стринг.
А мне говорят: это делается путем записи произвольного набора байт в стринг.
А не умеешь этого делать - лаймер.
Если это вопрос не для начинающих, скажите, чему я должен научиться сначала, чтобы сделать САБЖ.
Я научусь и тоже буду гнуть пальцы перед лаймерами.
← →
Ш-К (2007-03-13 17:44) [8]Всего-то надо было:
const
B64Table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
function B64Encode;
var
I: Integer;
InBuf: array [0..2] of Byte;
OutBuf: array [0..3] of Char;
begin
SetLength(Result, ((Length(S) + 2) div 3) * 4);
for I := 1 to ((Length(S) + 2) div 3) do
begin
if Length(S) < (I * 3) then
Move(S[(I - 1) * 3 + 1], InBuf, Length(S) - (I - 1) * 3)
else
Move(S[(I - 1) * 3 + 1], InBuf, 3);
OutBuf[0] := B64Table[((InBuf[0] and $FC) shr 2) + 1];
OutBuf[1] := B64Table[(((InBuf[0] and $03) shl 4) or ((InBuf[1] and $F0) shr 4)) + 1];
OutBuf[2] := B64Table[(((InBuf[1] and $0F) shl 2) or ((InBuf[2] and $C0) shr 6)) + 1];
OutBuf[3] := B64Table[(InBuf[2] and $3F) + 1];
Move(OutBuf, Result[(I - 1) * 4 + 1], 4);
end;
if (Length(S) mod 3) = 1 then
begin
Result[Length(Result) - 1] := "=";
Result[Length(Result)] := "=";
end
else
if (Length(S) mod 3) = 2 then
Result[Length(Result)] := "=";
end;
function B64Decode(const S: string): string;
var
I: Integer;
InBuf: array [0..3] of Byte;
OutBuf: array [0..2] of Byte;
RetValue: string;
begin
if ((Length(S) mod 4) <> 0) or (S = "") then
raise Exception.Create("IncorrectStringFormat");
SetLength(RetValue, ((Length(S) div 4) - 1) * 3);
for I := 1 to ((Length(S) div 4) - 1) do
begin
Move(S[(I - 1) * 4 + 1], InBuf, 4);
if (InBuf[0] > 64) and (InBuf[0] < 91) then
Dec(InBuf[0], 65)
else
if (InBuf[0] > 96) and (InBuf[0] < 123) then
Dec(InBuf[0], 71)
else
if (InBuf[0] > 47) and (InBuf[0] < 58) then
Inc(InBuf[0], 4)
else
if InBuf[0] = 43 then
InBuf[0] := 62
else
InBuf[0] := 63;
if (InBuf[1] > 64) and (InBuf[1] < 91) then
Dec(InBuf[1], 65)
else
if (InBuf[1] > 96) and (InBuf[1] < 123) then
Dec(InBuf[1], 71)
else
if (InBuf[1] > 47) and (InBuf[1] < 58) then
Inc(InBuf[1], 4)
else
if InBuf[1] = 43 then
InBuf[1] := 62
else
InBuf[1] := 63;
if (InBuf[2] > 64) and (InBuf[2] < 91) then
Dec(InBuf[2], 65)
else
if (InBuf[2] > 96) and (InBuf[2] < 123) then
Dec(InBuf[2], 71)
else
if (InBuf[2] > 47) and (InBuf[2] < 58) then
Inc(InBuf[2], 4)
else
if InBuf[2] = 43 then
InBuf[2] := 62
else
InBuf[2] := 63;
if (InBuf[3] > 64) and (InBuf[3] < 91) then
Dec(InBuf[3], 65)
else
if (InBuf[3] > 96) and (InBuf[3] < 123) then
Dec(InBuf[3], 71)
else
if (InBuf[3] > 47) and (InBuf[3] < 58) then
Inc(InBuf[3], 4)
else
if InBuf[3] = 43 then
InBuf[3] := 62
else
InBuf[3] := 63;
OutBuf[0] := (InBuf[0] shl 2) or ((InBuf[1] shr 4) and $03);
OutBuf[1] := (InBuf[1] shl 4) or ((InBuf[2] shr 2) and $0F);
OutBuf[2] := (InBuf[2] shl 6) or (InBuf[3] and $3F);
Move(OutBuf, RetValue[(I - 1) * 3 + 1], 3);
end;
if S <> "" then
begin
Move(S[Length(S) - 3], InBuf, 4);
if InBuf[2] = 61 then
begin
if (InBuf[0] > 64) and (InBuf[0] < 91) then
Dec(InBuf[0], 65)
else
if (InBuf[0] > 96) and (InBuf[0] < 123) then
Dec(InBuf[0], 71)
else
if (InBuf[0] > 47) and (InBuf[0] < 58) then
Inc(InBuf[0], 4)
else
if InBuf[0] = 43 then
InBuf[0] := 62
else
InBuf[0] := 63;
if (InBuf[1] > 64) and (InBuf[1] < 91) then
Dec(InBuf[1], 65)
else
if (InBuf[1] > 96) and (InBuf[1] < 123) then
Dec(InBuf[1], 71)
else
if (InBuf[1] > 47) and (InBuf[1] < 58) then
Inc(InBuf[1], 4)
else
if InBuf[1] = 43 then
InBuf[1] := 62
else
InBuf[1] := 63;
OutBuf[0] := (InBuf[0] shl 2) or ((InBuf[1] shr 4) and $03);
RetValue := RetValue + Char(OutBuf[0]);
end
else
if InBuf[3] = 61 then
begin
if (InBuf[0] > 64) and (InBuf[0] < 91) then
Dec(InBuf[0], 65)
else
if (InBuf[0] > 96) and (InBuf[0] < 123) then
Dec(InBuf[0], 71)
else
if (InBuf[0] > 47) and (InBuf[0] < 58) then
Inc(InBuf[0], 4)
else
if InBuf[0] = 43 then
InBuf[0] := 62
else
InBuf[0] := 63;
if (InBuf[1] > 64) and (InBuf[1] < 91) then
Dec(InBuf[1], 65)
else
if (InBuf[1] > 96) and (InBuf[1] < 123) then
Dec(InBuf[1], 71)
else
if (InBuf[1] > 47) and (InBuf[1] < 58) then
Inc(InBuf[1], 4)
else
if InBuf[1] = 43 then
InBuf[1] := 62
else
InBuf[1] := 63;
if (InBuf[2] > 64) and (InBuf[2] < 91) then
Dec(InBuf[2], 65)
else
if (InBuf[2] > 96) and (InBuf[2] < 123) then
Dec(InBuf[2], 71)
else
if (InBuf[2] > 47) and (InBuf[2] < 58) then
Inc(InBuf[2], 4)
else
if InBuf[2] = 43 then
InBuf[2] := 62
else
InBuf[2] := 63;
OutBuf[0] := (InBuf[0] shl 2) or ((InBuf[1] shr 4) and $03);
OutBuf[1] := (InBuf[1] shl 4) or ((InBuf[2] shr 2) and $0F);
RetValue := RetValue + Char(OutBuf[0]) + Char(OutBuf[1]);
end
else
begin
if (InBuf[0] > 64) and (InBuf[0] < 91) then
Dec(InBuf[0], 65)
else
if (InBuf[0] > 96) and (InBuf[0] < 123) then
Dec(InBuf[0], 71)
else
if (InBuf[0] > 47) and (InBuf[0] < 58) then
Inc(InBuf[0], 4)
else
if InBuf[0] = 43 then
InBuf[0] := 62
else
InBuf[0] := 63;
if (InBuf[1] > 64) and (InBuf[1] < 91) then
Dec(InBuf[1], 65)
else
if (InBuf[1] > 96) and (InBuf[1] < 123) then
Dec(InBuf[1], 71)
else
if (InBuf[1] > 47) and (InBuf[1] < 58) then
Inc(InBuf[1], 4)
else
if InBuf[1] = 43 then
InBuf[1] := 62
else
InBuf[1] := 63;
if (InBuf[2] > 64) and (InBuf[2] < 91) then
Dec(InBuf[2], 65)
else
if (InBuf[2] > 96) and (InBuf[2] < 123) then
Dec(InBuf[2], 71)
else
if (InBuf[2] > 47) and (InBuf[2] < 58) then
Inc(InBuf[2], 4)
else
if InBuf[2] = 43 then
InBuf[2] := 62
else
InBuf[2] := 63;
if (InBuf[3] > 64) and (InBuf[3] < 91) then
Dec(InBuf[3], 65)
else
if (InBuf[3] > 96) and (InBuf[3] < 123) then
Dec(InBuf[3], 71)
else
if (InBuf[3] > 47) and (InBuf[3] < 58) then
Inc(InBuf[3], 4)
else
if InBuf[3] = 43 then
InBuf[3] := 62
else
InBuf[3] := 63;
OutBuf[0] := (InBuf[0] shl 2) or ((InBuf[1] shr 4) and $03);
OutBuf[1] := (InBuf[1] shl 4) or ((InBuf[2] shr 2) and $0F);
OutBuf[2] := (InBuf[2] shl 6) or (InBuf[3] and $3F);
RetValue := RetValue + Char(OutBuf[0]) + Char(OutBuf[1]) + Char(OutBuf[2]);
end;
end;
Result := RetValue;
end;
← →
Аноним (2007-03-13 17:59) [9]Не надо так программировать
← →
Джо © (2007-03-13 19:24) [10]> [7] Ш-К (13.03.07 17:12)
> Я пришел на форум для начинающих спросить, как записать
> произвольный набор байт в стринг.
BinToHex.
← →
Johnmen © (2007-03-13 22:43) [11]>Ш-К (13.03.07 17:12) [7]
>Я научусь и тоже буду гнуть пальцы перед лаймерами.
> Ш-К (13.03.07 17:44) [8]
> Всего-то надо было: ...
Это ты уже начал пальцы гнуть?
Рановато....
← →
Kolan © (2007-03-14 13:10) [12]> if (InBuf[0] > 64) and (InBuf[0] < 91) then
> Dec(InBuf[0], 65)
Ха ха ха ... :)
Страницы: 1 вся ветка
Форум: "Начинающим";
Текущий архив: 2007.04.01;
Скачать: [xml.tar.bz2];
Память: 0.5 MB
Время: 0.041 c