[Cuis-dev] [FIX] Re: BMP Reader broken

Vanessa Freudenberg vanessa at codefrau.net
Sat Mar 16 18:39:28 PDT 2024


Attaching a fix. Not entirely sure what the right process to submit fixes
is, this is my first. Apparently you use git but not pull requests?

Anyways, the error happened because the code used
    stream nextInto: pixelLine
which calls "next:into:startingAt:" which does not read across chunk
boundaries from the file primitive.

My fix changes the code to use
     stream readInto: pixelLine startingAt: 1 count: pixelLine size
which uses "nextBytes:into:startingAt:" which reads across chunk boundaries
by fetching more contents from the file.

In Squeak, "nextInto:" calls "readInto:startingAt:count:" that's why it
keeps working there.

Vanessa

On Sat, Mar 16, 2024 at 4:30 PM Vanessa Freudenberg <vanessa at codefrau.net>
wrote:

> FWIW, dropping splash.bmp into Cuis-6.2 running on SqueakJS works just fine
> (try here: https://tinyurl.com/squeakjs-cuis62)
>
> As does Dave's expression.
>
> SqueakJS does not have BMPReadWriterPlugin so the primitive fails. The
> fallback code works fine.
>
> Vanessa
>
> On Sat, Mar 16, 2024 at 2:28 PM lewis--- via Cuis-dev <
> cuis-dev at lists.cuis.st> wrote:
>
>> Hi Hilaire,
>>
>> I compared the behavior in Squeak with both opensmalltalk-vm and with V3
>> interpreter VM.
>>
>> In Squeak:
>> ImageReadWriter formFromFileNamed: 'splash.bmp'. "==> Form(400x300x32)"
>>
>> In Cuis (with the same VM):
>> ImageReadWriter formFromFileEntry: 'splash.bmp' asFileEntry. "==> Error"
>>
>> I see two possible issues here.
>> 1) The call to #primitiveRead24BmpLine is failing in both Squeak and
>> Cuis. This may be a problem in the VM plugin (or maybe it is expected in
>> this case, I am not sure).
>>
>> 2) In the primitive fallback code in method
>> #read24BmpLine:into:startingAt:width: the error happens at the "formBits
>> at: (bitsIndex := bitsIndex+1) put: rgb". The formBits is a BitMap, so
>> maybe the some difference between Squeak and Cuis here.
>>
>> I also tried Squeak with a V3 image and interpreter VM, and the results
>> are the same as with opensmalltalk-vm. The form is created successfully,
>> and the #primitiveRead24BmpLine call fails and goes to the fallback code.
>>
>> At this point I cannot say if there primitive failure is a problem in the
>> VM plugin, or if the primitive failure is normal and expected for this
>> particular case. But I can say that the actual Error in Cuis must be
>> something related to the fallback code when it updates the formBits BitMap.
>>
>> Dave
>>
>>
>> On 2024-03-16 18:47, Hilaire Fernandes via Cuis-dev wrote:
>>
>> Hi folks,
>>
>> It looks like the BMP reader is broken.
>>
>> ImageReadWriter formFromFileEntry: 'splash.bmp'.
>>
>> Could it be a VM issue? Seem to occure in a plugin. I am not forwarding
>> to VM mailing list for now, waiting for more advices.
>>
>> See screen capture and bmp example known to load previously.
>>
>> --
>> GNU Dr. Geohttp://gnu.org/s/dr-geo/http://gnu-drgeo.blogspot.com/
>>
>>
>>
>>
>> --
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240316/5a1d9ba0/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 6279-read24BmpFile-codefrau-2024Mar16-17h33m-codefrau.001.cs.st
Type: application/octet-stream
Size: 658 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240316/5a1d9ba0/attachment.obj>


More information about the Cuis-dev mailing list