Seek и Oracle

Nedr2
Дата: 30.06.2009 15:37:00
Фото(bmp) загружены в Oracle через Developer на русской винде, какое смещение указывать в Seek что бы ушла ошибка Bitmap bitmap image is not valid

 iIndex:= 0;
  xmlString:= TStringList.Create;
  SOAPResponse.Position := 282;//Убираем xml тэги в начале потока (поток от asp WebService)
  xmlString.LoadFromStream(SOAPResponse);
  strBin:= xmlString.GetText;
  Delete(strBin,Pos('<',strBin),Length(strBin) - Pos('<',strBin));//Убираю xml тэги в конце строки
  strBin:=  Trim(strBin);

  Stream:= TStringStream.Create(strBin);
  Stream.Position := 0;
  Stream.Seek(82, soFromBeginning);
  Bitmap:= TBitmap.Create;

  Bitmap.LoadFromStream(Stream);//Вот лезет ошибка bitmap image is not valid 
  DBImage2.Picture.Graphic:= Bitmap;
дддддд
Дата: 30.06.2009 15:43:26
автор
Фото(bmp) загружены в Oracle через Developer


Откуда там браться смещению?
Кстати, тип поля, надеюсь БЛОБ?
Nedr2
Дата: 30.06.2009 15:45:55
В файлике то, что находится между тегами XML...
Petro123
Дата: 30.06.2009 15:46:12
Nedr2,
в xml текстовый формат, поэтому при записи кодируют в base64 и при записи на сервер раскодируй обратно
Nedr2
Дата: 30.06.2009 15:46:35
дддддд,
Да в оракле тип блоб
Nedr2
Дата: 30.06.2009 15:48:09
Petro123
Nedr2,
в xml текстовый формат, поэтому при записи кодируют в base64 и при записи на сервер раскодируй обратно


Petro, а Вф не могли бы поделиться ссылочкой или примером кода.
Nedr2
Дата: 30.06.2009 15:58:28
Кто знает где взять декодер на делфи для Base64
Petro123
Дата: 30.06.2009 16:00:26
Nedr2,

d7 - компоненты инди (поиск дай - я приводил примеры)
Nedr2
Дата: 01.07.2009 10:20:09
Всем спасибо совсем разобрался, кому нужно будет то вот рабочие функции кодирования и декодирования BASE64


function EncodeBase64(const inStr: string): string;

  function Encode_Byte(b: Byte): char;
  const
    Base64Code: string[64] =
      'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  begin
    Result := Base64Code[(b and $3F)+1];
  end;

var
  i: Integer;
begin
  i := 1;
  Result := '';
  while i < =Length(InStr) do
  begin
    Result := Result + Encode_Byte(Byte(inStr[i]) shr 2);
    Result := Result + Encode_Byte((Byte(inStr[i]) shl 4) or (Byte(inStr[i+1]) shr 4));
    if i+1 < =Length(inStr) then
      Result := Result + Encode_Byte((Byte(inStr[i+1]) shl 2) or (Byte(inStr[i+2]) shr 6))
    else
      Result := Result + '=';
    if i+2 < =Length(inStr) then
      Result := Result + Encode_Byte(Byte(inStr[i+2]))
    else
      Result := Result + '=';
    Inc(i, 3);
  end;
end;

// Base64 decoding
function DecodeBase64(const CinLine: string): string;
const
  RESULT_ERROR = -2;
var
  inLineIndex: Integer;
  c: Char;
  x: SmallInt;
  c4: Word;
  StoredC4: array[0..3] of SmallInt;
  InLineLength: Integer;
begin
  Result := '';
  inLineIndex := 1;
  c4 := 0;
  InLineLength := Length(CinLine);

  while inLineIndex < =InLineLength do
  begin
    while (inLineIndex < =InLineLength) and (c4 < 4) do
    begin
      c := CinLine[inLineIndex];
      case c of
        '+'     : x := 62;
        '/'     : x := 63;
        '0'..'9': x := Ord(c) - (Ord('0')-52);
        '='     : x := -1;
        'A'..'Z': x := Ord(c) - Ord('A');
        'a'..'z': x := Ord(c) - (Ord('a')-26);
      else
        x := RESULT_ERROR;
      end;
      if x < > RESULT_ERROR then
      begin
        StoredC4[c4] := x;
        Inc(c4);
      end;
      Inc(inLineIndex);
    end;

    if c4 = 4 then
    begin
      c4 := 0;
      Result := Result + Char((StoredC4[0] shl 2) or (StoredC4[1] shr 4));
      if StoredC4[2] = -1 then Exit;
      Result := Result + Char((StoredC4[1] shl 4) or (StoredC4[2] shr 2));
      if StoredC4[3] = -1 then Exit;
      Result := Result + Char((StoredC4[2] shl 6) or (StoredC4[3]));
    end;
  end;
end;
Petro123
Дата: 01.07.2009 10:58:36
нда, любят же у нас народ велосипеды

     // кодируем в base64
      NMUUProcessor1.InputStream := MemStreamInfoIBase;
      NMUUProcessor1.OutputStream := MemStreamOut;
      NMUUProcessor1.Encode;
      // получаем из потока строку в base64
      MemStreamOut.Position := 0 ;
      s.CopyFrom(MemStreamOut, MemStreamOut.Size);
      s.Position := 0;
______________________________________________
Вы имеете право хранить молчание! Всё что Вы скажете может быть использовано против Вас в суде!