[help] How can I get from an array of byte sized integers to a bitmap.

Jerome Peace peace_the_dreamer at yahoo.com
Thu Jan 31 07:24:33 UTC 2008

[help] How can I get from an array of byte sized
integers to a bitmap.

Hi Yoshiki,

>Yoshiki Ohshima yoshiki at vpri.org 
>Tue Jan 29 22:20:23 UTC 2008 
>> I have an array of integers (all less than 255 ).
>> I have a color form and a pallette for 255 colors.
>> I have the number of columns and rows that the
>> represents.
>> I want to create a bitmap to map the array onto its
>> pallette. I'm not quite sure what the intervening
>> steps are.
>  This description is very vague, I have to say.

Ah, and here I was thinking I was being precise
without going into unnecessary detail.
>  - Is the array of integers actually an Array
>  - The "palette" is Bitmap, yes?
The pallette is an array of colors which one can give
to the color form.
The colorform will generate the bitmap for the colors.
What I wished to do was set the bitmap for the pixels
that indexed the colors.

>  - What are the number of columns and rows?  What
are inside?
The columns and rows are settable by the user. Once
set they are knowable.
As for the inside on one end it is data about time and
on the other just a colorful way of displaying the
contrast amoung the data.

The form is used to dramatize the results.
>> Has anyone solved this problem before?
>  For example, in the OLPC image,
>SugarLibrary>>imageFor:color:grayOutColor: has some
obscure logic to
>recolor a form.  This may be different but I have a
hunch that this
>may be somewhat similar.  Especially #hackBits: will
be your weapon.
>(Also, see Bitmap>>asByteArray, etc.)
>> The application I have will essentially update the
>> array over time and I wish to display it visually.
>> would like to do it in a time efficient way rather
>> than pixel by pixel.
>> I've looked at the options in the image and I am
>> sure which ones are right.
>> Ideally once the color form is set up I should be
>> to update it just by updating the bitmap from the
>> array periodically.
>  BitBlt can do a lot of stuff.  I'm almost sure that
you can find the
>right operations on right data array type.

I eventually realized I did not have to set the bits
all once and what worked was building a pixel poker to
my form.

By holding on to the poker I can update the form fast
enough. The appllication is scanning the display for
slow spots and will generate one datum per several
I collect the data as integers into an array and it
was ok to store a pixel each time the data came in.

This was simple and it worked (after I found a bug or
two in my typing.) And this lets BitBlt continue to
hide the difficulties with endianness and so forth.

Still a fast way to go from array to bitmap would be
Its not to hard to insist the columns be a multiple of
4 so the data keeps word boundrys intact.

preliminary samples at: 
0006876: Why is my UI slow?

Yours in curiosity and service, --Jerome Peace


Never miss a thing.  Make Yahoo your home page. 

More information about the Squeak-dev mailing list