Ver Mensaje Individual
  #4  
Antiguo 02-08-2005
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - Espańa
Posts: 18.318
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Utiliza TAG´s en el código Delphi, verás como se vuelve más legible.
http://www.clubdelphi.com/foros/misc.php?do=bbcode

Mira la diferencia (Delphi -entre corchetes- al empezar y /Delphi -entre corchetes- al acabar):

Código Delphi [-]
     const
    JPEGstarts = 'FFD8';
    BMPstarts = '424D';  //BM
   
   var
     Form1: TForm1;
   implementation
   uses jpeg;
   {$R *.dfm}
   procedure TForm1.btnShowImageClick(Sender: TObject);
   var
     bS  : TADOBlobStream;
     Pic : TJpegImage;
   begin
     bS := TADOBlobStream.Create(AdoTable1Picture, bmRead);
     try
       bS.Seek(JpegStartsInBlob(AdoTable1Picture),soFromBeginning);
       Pic:=TJpegImage.Create;
       try
        Pic.LoadFromStream(bS);
        ADOImage.Picture.Graphic:=Pic;
       finally
        Pic.Free;
       end;
     finally
       bS.Free
     end;
   end;
    
   procedure TForm1.FormCreate(Sender: TObject);
   begin
     ADOTable1Picture.SaveToFile('BlobImage.dat');
   end;
   function TForm1.JpegStartsInBlob(PicField: TBlobField): integer;
   var
    bS     : TADOBlobStream;
    buffer : Word;
    hx     : string;
   begin
    Result := -1;
    bS := TADOBlobStream.Create(PicField, bmRead);
    try
     while (Result = -1) and
           (bS.Position + 1 < bS.Size) do
     begin
      bS.ReadBuffer(buffer, 1);
      hx:=IntToHex(buffer, 2);
      if hx = 'FF' then begin
        bS.ReadBuffer(buffer, 1);
        hx:=IntToHex(buffer, 2);
        if hx = 'D8' then Result := bS.Position - 2
        else if hx = 'FF' then
          bS.Position := bS.Position-1;
      end; //if
     end; //while
    finally
     bS.Free
    end;  //try
   end;
   
   end.
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita