Hi Rob,

--- In [email protected], "Rob Kennedy" <[EMAIL PROTECTED]> wrote:
>
> Dave Murray wrote:
> > With your pointer and some serious thinking I finally managed to 
> > get it figured out. I've now got the IStream copied to a 
> > TOLEStream which enables me to work with it in Delphi. :)
> 
> You shouldn't have to copy it anywhere. Delphi has a TStream 
> descendant that will wrap an IStream, so calls to TStream's methods 
> are simply forwarded to the IStream's methods instead. Then you 
> don't need to make another copy of the data.

Copied is probably the wrong word. To paraphrase the help for 
TOLEStream... I've converted a stream interface into a TOleStream 
object.

> > For some reason copying that to a TMemoryStream and then loading 
> > it into a TJPEGImage produces an empty image even though I can 
> > see the streams contain the correct number of bytes in the 
> > debugger. But copying it to a TFileStream instead and then 
> 
> If you already have a TOleStream (or whatever the IStream wrapper 
> is), then you shouldn't need to copy it again into a TMemoryStream. 
> TJpegImage merely wants a TStream -- any will do. But if you _have_ 
> made a copy of the stream, make sure that you set its Position 
> property back to zero before you try reading from it. Otherwise, 
> the TJpegImage will try to read from the _end_ of the stream, where 
> the position was left after the last write operation of the copy.

I think I was seeking back to the start of the stream, certainly I 
initially wrote an ICS version of the function and that's what it 
did, but I may have forgotten to do that. I can't really remember now 
and don't have a copy of that version of the code. Copying it to a 
file stream works and I want to save a cached copy anyway so I'm 
happy with that solution. The pictures I'm dealing with are all small 
(3k or less) so having an extra copy of the stream in memory isn't 
really going to impact performance.

Thanks,
Dave.

Dave Murray
Glasgow, UK


Reply via email to