Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread TBlobField.SaveToStream generate exception "Abstract error"
Wed, Dec 19 2012 2:07 PMPermanent Link

Vitor Martins

Pregitzer & Ca., Lda

The following code:

Stream :TStream;

Stream := TStream.Create;
   try
     DmSyn.EDBTable_SynListImage.SaveToStream(Stream);
     Image1.Picture.Bitmap.LoadFromStream(Stream);
   finally
     Stream.Free;
   end;

Generate exception "Abstract error" when call SaveToStream?
I need load a image from a BLOB field and show using an TImage.

Thanks
Vitor Martins.
Wed, Dec 19 2012 3:11 PMPermanent Link

Raul

Team Elevate Team Elevate

You should not really use TStream but one of its descendant -
TMemoryStream (if dealing in ram) or TFileStream (for file system)

Raul



On 12/19/2012 2:07 PM, Vitor Martins wrote:
> The following code:
>
>   Stream :TStream;
>
>   Stream := TStream.Create;
>      try
>        DmSyn.EDBTable_SynListImage.SaveToStream(Stream);
>        Image1.Picture.Bitmap.LoadFromStream(Stream);
>      finally
>        Stream.Free;
>      end;
>
> Generate exception "Abstract error" when call SaveToStream?
> I need load a image from a BLOB field and show using an TImage.
>
> Thanks
> Vitor Martins.
>
Wed, Dec 19 2012 3:25 PMPermanent Link

Vitor Martins

Pregitzer & Ca., Lda

Tanks Raul

Change from TStream to TMemoryStream, no error but the image is not show on TImage.

   MemStream := TMemoryStream.Create;
   DmSyn.EDBTable_SynListImage.SaveToStream(MemStream);
   try
     Image1.Picture.Bitmap.LoadFromStream(MemStream);
   finally
     MemStream.Free;
     end;
   end;

Thanks
Vitor Martins




Raul wrote:

You should not really use TStream but one of its descendant -
TMemoryStream (if dealing in ram) or TFileStream (for file system)

Raul



On 12/19/2012 2:07 PM, Vitor Martins wrote:
> The following code:
>
>   Stream :TStream;
>
>   Stream := TStream.Create;
>      try
>        DmSyn.EDBTable_SynListImage.SaveToStream(Stream);
>        Image1.Picture.Bitmap.LoadFromStream(Stream);
>      finally
>        Stream.Free;
>      end;
>
> Generate exception "Abstract error" when call SaveToStream?
> I need load a image from a BLOB field and show using an TImage.
>
> Thanks
> Vitor Martins.
>
Wed, Dec 19 2012 3:40 PMPermanent Link

Raul

Team Elevate Team Elevate

Vitor,

Completely untested but i would suggest making couple fo small
modification and see what happens:

MemStream := TMemoryStream.Create;
try
  TBlobField(DmSyn.EDBTable_SynListImage).SaveToStream(MemStream);
  MemStream.Position := 0
  Image1.Picture.Bitmap.LoadFromStream(MemStream);
finally
  MemStream.Free;
end;


Raul

On 12/19/2012 3:25 PM, Vitor Martins wrote:
> Tanks Raul
>
> Change from TStream to TMemoryStream, no error but the image is not show on TImage.
>
>      MemStream := TMemoryStream.Create;
>      DmSyn.EDBTable_SynListImage.SaveToStream(MemStream);
>      try
>        Image1.Picture.Bitmap.LoadFromStream(MemStream);
>      finally
>        MemStream.Free;
>        end;
>      end;
>
> Thanks
> Vitor Martins
Thu, Dec 20 2012 5:00 AMPermanent Link

Vitor Martins

Pregitzer & Ca., Lda


Thanks Raul

All works fine, it's necessary put the memorystream at position 0 before load the stream.

Best regards,
Merry Christmas
Vitor Martins


Raul wrote:

Vitor,

Completely untested but i would suggest making couple fo small
modification and see what happens:

MemStream := TMemoryStream.Create;
try
  TBlobField(DmSyn.EDBTable_SynListImage).SaveToStream(MemStream);
  MemStream.Position := 0
  Image1.Picture.Bitmap.LoadFromStream(MemStream);
finally
  MemStream.Free;
end;


Raul

On 12/19/2012 3:25 PM, Vitor Martins wrote:
> Tanks Raul
>
> Change from TStream to TMemoryStream, no error but the image is not show on TImage.
>
>      MemStream := TMemoryStream.Create;
>      DmSyn.EDBTable_SynListImage.SaveToStream(MemStream);
>      try
>        Image1.Picture.Bitmap.LoadFromStream(MemStream);
>      finally
>        MemStream.Free;
>        end;
>      end;
>
> Thanks
> Vitor Martins
Image