ImageReadWriter class>>formFromStream:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

ImageReadWriter class>>formFromStream:

Schwab,Wilhelm K
Hello all,

I have a crude example of something I want to do with gnuplot, and started looking at reading images from binary streams.  Looking at ImageReadWriter class>>formFromStream:, I see things I do not like, but I am not sure how to fix them.

First, on a failure to find a matching reader, it sends #close to the stream.  I don't think that is its job, or if nothing else, there should be a #formFromStream:onError: block that would allow overrides of that behavior.

Second, it uses #reset to go back up to allow the selected reader to have a fresh start after it assumes responsibility for reading the format.  #position: would be a better choice, to return to the position at the start of the method (not necessarily the beginning of the stream).  If a positionable stream is too much to ask, then the code should be changed to allow the read to pick up where the format test left off.  Another option would be to use something that I built in Dolphin a while back: it puts a wrapper around a stream to absorb a #reset (I had the same problem) and then delegates to the "real" stream from the point it left off.

In my current situation, I should be able to get away with hard-coding the reader class.

Bill


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project