PDA

View Full Version : Tstream.seek not implemented...



azrael11
16-03-2015, 02:12 PM
Hi again

i met this problem
when i run it i get the above error..
i use TMemoryStream instead of Tstream but in the saveimage to stream do data is saved...
How can i solve the Tstream.seek error...?

i use the Vampire Image Library..




var
strm1: Tstream;
myImg: TimageData;
imgExt: string;

InitImage(myImg);
LoadImageFromFile(SnapImg,myImg);

strm1:= TStream.Create;
// strm1.Seek(myImg.Size,soBeginning);

imgExt:= ExtractFileExt(SnapImg);

SaveImageToStream(imgExt,strm1,myImg);


Thank you...

SilverWarior
16-03-2015, 02:51 PM
That is strange. How can Stream.Seek not be implemented? Is this the exact error you are retuned?

phibermon
16-03-2015, 03:15 PM
Because you are using the TStream 'abstract' class - it's not meant to be used directly, It doesn't have .seek() etc implemented.

Check out TMemoryStream which will give you what you're after.

azrael11
17-03-2015, 05:20 AM
That is strange. How can Stream.Seek not be implemented? Is this the exact error you are retuned?

Yes my friend...

Thank you...

SilverWarior
17-03-2015, 07:32 AM
Just looked at the TStream code and it seems that Seek method is intended to be abstract (athleast based on the in-code commentary.
But instead of it being marked as abstract where you have no method implementation it already has some code to do its job but it also has some rather strange code to check if you are calling this from base TStream or not.

Also looking at the code it is clear that TStream as such can't be used to store any data as it doesen't have any mechanizm for this.
So I'm guessing that TStream class is more like a template upon which all other streaming classes should be made.

EDIT: Documentation is confirming my guess.
The TStream class is a base stream class that all other stream classes should be derived from. So it can't be used as such as it doesen't even implement any data storing mechanizm on its own. You need to use one of the decendant stream classes.

SilverWarior
17-03-2015, 07:48 AM
Because you are using the TStream 'abstract' class - it's not meant to be used directly, It doesn't have .seek() etc implemented.

Check out TMemoryStream which will give you what you're after.

I have unDeleted your post (hope you don't mind) as you are partially correct.

The TStream is indeed intended to be an abstract class but it does have Seek method implemented. Infact they are two versions of Seek method implementations (Delphi XE3). One to work with 32 bit offsets and another to work with 64 bit offsets.
Now these are implemented in such way that one of tem is always called and it contains special code to check if the method was called from base class (raises an exception) or if it was overriden in one of its decendant classes.
This specific code seems pretty wierdly implemented but I sugest you take a look at it as I belive that perhaps such approach might cme usefull when designing classes.
Well not verry likely but still.:D It doesen't hurt to know ;)

azrael11
17-03-2015, 04:12 PM
Because you are using the TStream 'abstract' class - it's not meant to be used directly, It doesn't have .seek() etc implemented.

Check out TMemoryStream which will give you what you're after.

Thanks phibermon

I use TMemoryStream but it does't work so i try this and it works just fine...

instead load image from file with



LoadImageFromFile(SnapImg,myImg);


i loaded directly to TMemoryStream



strm1.LoadFromFile(SnapImg);


the rest i left just the same and it works... ;)

Thank you...

[/code]

azrael11
17-03-2015, 04:15 PM
The TStream class is a base stream class that all other stream classes should be derived from.

Yes, so TStreamMemory do my work ... ;)

Thank you...

SilverWarior
17-03-2015, 07:45 PM
Yes, so TStreamMemory do my work ... ;)

You probably mean TMemoryStream and not TStreamMemory right? ;)

azrael11
18-03-2015, 09:26 AM
You probably mean TMemoryStream and not TStreamMemory right? ;)

Ooopsss...

;)