The Trunk: Graphics-mt.300.mcz

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

The Trunk: Graphics-mt.300.mcz

commits-2
Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.300.mcz

==================== Summary ====================

Name: Graphics-mt.300
Author: mt
Time: 12 August 2014, 10:04:47.352 am
UUID: 6462eee8-e43a-4840-954c-edc02dfcd8ee
Ancestors: Graphics-nice.299

fixed image reading: stream was not correctly reset for each reader/writer test

=============== Diff against Graphics-nice.299 ===============

Item was changed:
  ----- Method: ImageReadWriter class>>formFromStream: (in category 'image reading/writing') -----
  formFromStream: aBinaryStream
  "Answer a ColorForm stored on the given stream.  closes the stream"
  | reader readerClass form  |
 
  readerClass := self withAllSubclasses
+ detect: [:subclass |
+ aBinaryStream reset.
+ subclass understandsImageFormat: aBinaryStream]
- detect: [:subclass | subclass understandsImageFormat: aBinaryStream]
  ifNone: [
  aBinaryStream close.
  ^self error: 'image format not recognized'].
  aBinaryStream reset.
  reader := readerClass new on: aBinaryStream.
  Cursor read showWhile: [
  form := reader nextImage.
  reader close].
  ^ form
  !


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Graphics-mt.300.mcz

Levente Uzonyi-2
On Tue, 12 Aug 2014, [hidden email] wrote:

> Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
> http://source.squeak.org/trunk/Graphics-mt.300.mcz
>
> ==================== Summary ====================
>
> Name: Graphics-mt.300
> Author: mt
> Time: 12 August 2014, 10:04:47.352 am
> UUID: 6462eee8-e43a-4840-954c-edc02dfcd8ee
> Ancestors: Graphics-nice.299
>
> fixed image reading: stream was not correctly reset for each reader/writer test

IIRC this is what Nicolas was trying to get rid of. Actually restoring the
stream is a must, but #reset will set its position to 0, while the
original position could have been anything. I kinda think that restoring
the stream's position belongs to where it's changed (#understandsImageFormat:).


Levente

>
> =============== Diff against Graphics-nice.299 ===============
>
> Item was changed:
>  ----- Method: ImageReadWriter class>>formFromStream: (in category 'image reading/writing') -----
>  formFromStream: aBinaryStream
>   "Answer a ColorForm stored on the given stream.  closes the stream"
>   | reader readerClass form  |
>
>   readerClass := self withAllSubclasses
> + detect: [:subclass |
> + aBinaryStream reset.
> + subclass understandsImageFormat: aBinaryStream]
> - detect: [:subclass | subclass understandsImageFormat: aBinaryStream]
>   ifNone: [
>   aBinaryStream close.
>   ^self error: 'image format not recognized'].
>   aBinaryStream reset.
>   reader := readerClass new on: aBinaryStream.
>   Cursor read showWhile: [
>   form := reader nextImage.
>   reader close].
>   ^ form
>  !
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Graphics-mt.300.mcz

marcel.taeumel (old)
Yeah, you're right. I just completed the existing workaround. We still need to fix that. :) At least, now we can load PNG images again. ;)

Stream-based magic-byte-detection sounds difficult to me anyway... How much to read to give it to the "decider"?

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Graphics-mt.300.mcz

Chris Muller-3
On Sun, Aug 17, 2014 at 3:09 AM, Marcel Taeumel <[hidden email]> wrote:
Yeah, you're right. I just completed the existing workaround. We still need
to fix that. :) At least, now we can load PNG images again. ;)

I've been able to load PNG images just fine..

 

Stream-based magic-byte-detection sounds difficult to me anyway... How much
to read to give it to the "decider"?

Best,
Marcel



--
View this message in context: http://forum.world.st/The-Trunk-Graphics-mt-300-mcz-tp4772954p4773569.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Graphics-mt.300.mcz

marcel.taeumel (old)
I dropped a PNG into the image and got a debugger. :) I realized that the ReaderWriter classes consume bytes from the given stream to perform the check. Obviously, this does only work for the first class. Thus, I decided to reset the stream just as it was already done before using the correct class for the complete loading routine in the same method.

Best,
Marcel