Adapt ImageReadWriter hierarchy to need only pure binary streams

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

Adapt ImageReadWriter hierarchy to need only pure binary streams

Sven Van Caekenberghe-2
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
Reply | Threaded
Open this post in threaded view
|

Re: Adapt ImageReadWriter hierarchy to need only pure binary streams

Ben Coman


On 17 March 2018 at 20:28, Sven Van Caekenberghe <[hidden email]> 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Ā 
Reply | Threaded
Open this post in threaded view
|

Re: Adapt ImageReadWriter hierarchy to need only pure binary streams

Stephane Ducasse-3
Tx sven

On Sat, Mar 17, 2018 at 2:28 PM, Ben Coman <[hidden email]> wrote:

>
>
> On 17 March 2018 at 20:28, Sven Van Caekenberghe <[hidden email]> 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