<div dir="ltr"><div>Form has some class side methods to create Forms from arrays, too.</div><div> </div><div>Cheers,</div><div>Karl</div><div> </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 11, 2014 at 12:41 PM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 11.06.2014, at 00:36, Sungjin Chun &lt;<a href="mailto:chunsj@castlesoft.co.kr">chunsj@castlesoft.co.kr</a>&gt; wrote:<br>

<br>
&gt; Hi,<br>
&gt;<br>
&gt; I want to draw gray scale bitmap using byte array which has pixel by pixel gray<br>
&gt; scale value as byte like this;<br>
&gt;<br>
&gt; [0 0 0 0 0 0 0 0<br>
&gt;  16 23 255 78 12 12 12 12<br>
&gt; ...<br>
&gt; ...] (8x4 for example)<br>
&gt;<br>
&gt; I can draw this using Pen class pixel by pixel manner but this is very slow and<br>
&gt; I think there should be faster way of creating a Form using above byte array.<br>
<br>
</div>If the width is a multiple of 4, you can use the byte array directly as form bits:<br>
<br>
| w h bytes form |<br>
w := 100.<br>
h := 60.<br>
bytes := ((1 to: w*h) collect: [:i | 256 atRandom - 1]) asByteArray.<br>
form := ColorForm extent: w@h depth: 8 bits: bytes.<br>
form colors: ((0 to: 255) collect: [:i | Color gray: i / 255]).<br>
form display<br>
<br>
This would be the best and fastest way. If the width is not a multiple of 4 then perhaps you can add the necessary padding when creating the byte array. Otherwise, a very fast way is to use BitBlt to copy whole lines from the byte array to the form.<br>

<br>
But even creating a byte array with the right padding just using at:put: would be a lot faster than using a Pen.<br>
<span class="HOEnZb"><font color="#888888"><br>
- Bert -<br>
<br>
<br>
</font></span><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>