Adapt ImageReadWriter hierarchy to need only pure binary streams
https://pharo.manuscript.com/f/cases/21611 With the new File/Stream changes in Pharo 7, ImageReadWriter and subclasses broke because these classes are not yet capable of working with simple binary streams. I created a new test case (attached) to catch the functional degradation. For each image type (class) there are 2 tests, IO in memory and IO to file. For example: testJpegWriteReadInMemory | form bytes result | form := self pharoLogoFormNonTransparent. bytes := ByteArray streamContents: [ :out | PluginBasedJPEGReadWriter putForm: form onStream: out ]. "Without format detection" result := (JPEGReadWriter on: bytes readStream) nextImage. self assert: form bits size equals: result bits size. "With format detection" result := ImageReadWriter formFromStream: bytes readStream. self assert: form bits size equals: result bits size testJpegWriteReadUsingFiles | form file result | form := self pharoLogoFormNonTransparent. file := (self class name asString , '-pharo-logo.jpeg') asFileReference. file ensureDelete. (PluginBasedJPEGReadWriter on: file binaryWriteStream) nextPutImage: form. "gets closed ?!" "Without format detection" result := file binaryReadStreamDo: [ :in | (JPEGReadWriter on: in) nextImage ]. self assert: form bits size equals: result bits size. "With format detection" result := file binaryReadStreamDo: [ :in | ImageReadWriter formFromStream: in ]. self assert: form bits size equals: result bits size. file delete I have a bunch of changes that make all tests pass. They clean up some strange coding as well. I will make a proper PR later. Sven
On 17 March 2018 at 20:28, Sven Van Caekenberghe <sven@stfx.eu> wrote:
https://pharo.manuscript.com/f/cases/21611
With the new File/Stream changes in Pharo 7, ImageReadWriter and subclasses broke because these classes are not yet capable of working with simple binary streams.
I created a new test case (attached) to catch the functional degradation. For each image type (class) there are 2 tests, IO in memory and IO to file. I have a bunch of changes that make all tests pass. They clean up some strange coding as well. I will make a proper PR later.
Thanks for everyone's efforts working on this. cheers -ben
Tx sven On Sat, Mar 17, 2018 at 2:28 PM, Ben Coman <btc@openinworld.com> wrote:
On 17 March 2018 at 20:28, Sven Van Caekenberghe <sven@stfx.eu> wrote:
https://pharo.manuscript.com/f/cases/21611
With the new File/Stream changes in Pharo 7, ImageReadWriter and subclasses broke because these classes are not yet capable of working with simple binary streams.
I created a new test case (attached) to catch the functional degradation. For each image type (class) there are 2 tests, IO in memory and IO to file. I have a bunch of changes that make all tests pass. They clean up some strange coding as well. I will make a proper PR later.
Thanks for everyone's efforts working on this.
cheers -ben
participants (3)
-
Ben Coman -
Stephane Ducasse -
Sven Van Caekenberghe