<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Dave,<br>
<br>
On 3/16/2024 6:22 PM, lewis--- via Cuis-dev wrote:
<blockquote
cite="mid:a4102b96bbc4661f784f8587b08437f0@mail.msen.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<p>Hi Hilaire,</p>
<p>I compared the behavior in Squeak with both opensmalltalk-vm
and with V3 interpreter VM.</p>
<p>In Squeak:<br>
ImageReadWriter formFromFileNamed: 'splash.bmp'. "==>
Form(400x300x32)"</p>
<p>In Cuis (with the same VM):<br>
ImageReadWriter formFromFileEntry: 'splash.bmp' asFileEntry.
"==> Error"</p>
<p>I see two possible issues here.<br>
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).</p>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>Dave</p>
</blockquote>
<br>
As I said in a separate email, Vanessa found the origin of the
problem, and the fix is now at GitHub.<br>
<br>
Still, as you say, the primitive fails, both in Cuis and Squeak, but
only the first time it is called. The lines are read in reverse
order, so the line that is first copied is actually the last one.<br>
<br>
In #read24BmpLine:into:startingAt:width:, at the start of the
fallback code, I added this line: `{formBitsIndex+width. formBits
size} print.`. Then tried to load Hilaire's BMP. In the Transcript I
got #(63601 63600). So, in BMPReadWriterPlugin.c, the lines that
read:<br>
<br>
if (!(((formBitsIndex + width) <= formBitsSize)<br>
&& ((width * 3) <= pixelLineSize))) {<br>
return primitiveFail();<br>
<br>
should actually read<br>
<br>
if (!(((formBitsIndex + width - 1) <= formBitsSize)<br>
&& ((width * 3) <= pixelLineSize))) {<br>
return primitiveFail();<br>
<br>
and the primitive will not fail.<br>
<br>
It is a minor bug, with no practical consequences, so this is not
really important. But I found this while investigating the BMP read
failure, and I thought it was worth commenting.<br>
<br>
Thanks,<br>
<pre class="moz-signature" cols="72">--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich</pre>
</body>
</html>