Thanks you for your answer, however there is something I missed here. I've tried following code
| w h bytes form | w := 200. h := 200. bytes := ((1 to: w*h) collect: [:i | 255 ]) asByteArray. (1 to: w) do: [ :x | (1 to: h) do: [ :y | x = y ifTrue: [ bytes at: (w*(y - 1) + x) put: 0 ] ] ]. form := ColorForm extent: w@h depth: 8 bits: bytes. form colors: ((0 to: 255) collect: [:i | Color gray: i / 255]). form display What I expected is diagonal line but the result is not. What's wrong with my code? Thank you in advance. On Wed, Jun 11, 2014 at 7:41 PM, Bert Freudenberg <b...@freudenbergs.de> wrote: > On 11.06.2014, at 00:36, Sungjin Chun <chu...@castlesoft.co.kr> wrote: > > > Hi, > > > > I want to draw gray scale bitmap using byte array which has pixel by > pixel gray > > scale value as byte like this; > > > > [0 0 0 0 0 0 0 0 > > 16 23 255 78 12 12 12 12 > > ... > > ...] (8x4 for example) > > > > I can draw this using Pen class pixel by pixel manner but this is very > slow and > > I think there should be faster way of creating a Form using above byte > array. > > If the width is a multiple of 4, you can use the byte array directly as > form bits: > > | w h bytes form | > w := 100. > h := 60. > bytes := ((1 to: w*h) collect: [:i | 256 atRandom - 1]) asByteArray. > form := ColorForm extent: w@h depth: 8 bits: bytes. > form colors: ((0 to: 255) collect: [:i | Color gray: i / 255]). > form display > > 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. > > But even creating a byte array with the right padding just using at:put: > would be a lot faster than using a Pen. > > - Bert - > > > > _______________________________________________ > Beginners mailing list > Beginners@lists.squeakfoundation.org > http://lists.squeakfoundation.org/mailman/listinfo/beginners > >
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners