Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to load a Jpeg image from a memorystream?

2,317 views
Skip to first unread message

Simon Wang

unread,
Sep 17, 2000, 3:00:00 AM9/17/00
to
On Tue, 19 Sep 2000 08:21:16 -0500, "MrBaseball34"
<mrbase...@hotmail.com> wrote:
thx , I will try it
>Load it into a Blobstream and then stream it to the TImage
>
><SNIP>
>>
>> var
>> tmpfilename:string;
>> begin
>> tmpfilename :='this_is_temp_file';
>> MySybasetable.MyBLOBImageColume.SavetoFile(tmpfilename);
>> MyImage.picture.LoadFromFile(tmpfilename);
>> ...
>
>
>


Simon Wang

unread,
Sep 19, 2000, 3:00:00 AM9/19/00
to
Hi
In my application , I need to load a jpg image from a sybase table
to a TImage.

if I execute following code, everything is ok

var
tmpfilename:string;
begin
tmpfilename :='this_is_temp_file';
MySybasetable.MyBLOBImageColume.SavetoFile(tmpfilename);
MyImage.picture.LoadFromFile(tmpfilename);
...

but I'd like to access the data via stream, so I change the code, it
look like this:

var
Mystream :TMemoryStream;
begin
Mystream:=TMemoryStream.Create;
MySybasetable.MyImageColume.SavetoStream(MyStream);
MyImage.picture.graphic.LoadFromstream(Mystream); <-----------
....


When the application execute to the <-----, system generate a
Access violation error, I don't know why, can anyone help me ?
is there any other method to load a jpeg image from a stream to
a TImage component?


thx in advance

Simon

MrBaseball34

unread,
Sep 19, 2000, 3:00:00 AM9/19/00
to
Load it into a Blobstream and then stream it to the TImage

<SNIP>
>

Jayh

unread,
Sep 19, 2000, 3:00:00 AM9/19/00
to
Hi Simon,
I believe the only thing you are missing is a statement to reset the
position back to zero.

Jay,

> var
> Mystream :TMemoryStream;
> begin
> Mystream:=TMemoryStream.Create;
> MySybasetable.MyImageColume.SavetoStream(MyStream);

Mystream.Position:=0;
> MyImage.picture.graphic.LoadFromstream(Mystream); <-----------

"Simon Wang" <sim...@online.sh.cn> wrote in message
news:6oudss495jasd5vgi...@4ax.com...


> Hi
> In my application , I need to load a jpg image from a sybase table
> to a TImage.
>
> if I execute following code, everything is ok
>

> var
> tmpfilename:string;
> begin
> tmpfilename :='this_is_temp_file';
> MySybasetable.MyBLOBImageColume.SavetoFile(tmpfilename);
> MyImage.picture.LoadFromFile(tmpfilename);
> ...
>

Earl F. Glynn

unread,
Sep 19, 2000, 3:00:00 AM9/19/00
to
"Simon Wang" <sim...@online.sh.cn> wrote in message
news:3g2gssc0a5i6dbglq...@4ax.com...
> Hi
> Now I know why it don't work.
> TGraphic is an abstract classthat can't
> be instantialed, so the code:
> MyImage.Picture.Graphic.LoadFromStream(MyStream);
>
> is invalid. but ..... How can I load a picture to TImage
> From a Stream? the TImage.Picture only have LoadFromFile
> method and do not support LoadFromStream method.

Perhaps Steve Schafer's post from Oct 1999 will help:
http://www.deja.com/getdoc.xp?AN=531776048


--
efg

Earl F. Glynn E-mail: ef...@efg2.com
Overland Park, KS USA

efg's Computer Lab: http://www.efg2.com/Lab

Simon Wang

unread,
Sep 20, 2000, 3:00:00 AM9/20/00
to
Hi
Now I know why it don't work.
TGraphic is an abstract classthat can't
be instantialed, so the code:
MyImage.Picture.Graphic.LoadFromStream(MyStream);

is invalid. but ..... How can I load a picture to TImage
From a Stream? the TImage.Picture only have LoadFromFile
method and do not support LoadFromStream method.


thx

Simon

sdfgsdfg

unread,
Sep 20, 2000, 3:00:00 AM9/20/00
to
Try This...
.
.
var
Mystream :TMemoryStream;
begin

Mystream:=TMemoryStream.Create;
MySybasetable.MyImageColume.SavetoStream(MyStream);

MyStream.Position := 0;
MyImage.picture.Bitmap.LoadFromStream( MyStream );

Simon Wang <sim...@online.sh.cn> wrote in message
news:3g2gssc0a5i6dbglq...@4ax.com...

Simon Wang

unread,
Sep 21, 2000, 3:00:00 AM9/21/00
to
thank u Earl

I read the doc in deja, that do can help me .

regards
Simon

0 new messages