Results 1 to 10 of 10

Thread: Tstream.seek not implemented...

  1. #1

    Tstream.seek not implemented...

    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..


    Code:
    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...

  2. #2
    That is strange. How can Stream.Seek not be implemented? Is this the exact error you are retuned?

  3. #3
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    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.
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  4. #4
    Quote Originally Posted by SilverWarior View Post
    That is strange. How can Stream.Seek not be implemented? Is this the exact error you are retuned?
    Yes my friend...

    Thank you...

  5. #5
    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.

  6. #6
    Quote Originally Posted by phibermon View Post
    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. It doesen't hurt to know

  7. #7
    Quote Originally Posted by phibermon View Post
    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

    Code:
     
      LoadImageFromFile(SnapImg,myImg);
    i loaded directly to TMemoryStream

    Code:
      strm1.LoadFromFile(SnapImg);
    the rest i left just the same and it works...

    Thank you...

    [/code]

  8. #8
    Quote Originally Posted by SilverWarior View Post
    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...

  9. #9
    Quote Originally Posted by azrael11 View Post
    Yes, so TStreamMemory do my work ...
    You probably mean TMemoryStream and not TStreamMemory right?

  10. #10
    Quote Originally Posted by SilverWarior View Post
    You probably mean TMemoryStream and not TStreamMemory right?
    Ooopsss...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL