(no subject)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

siddharth-2

 
Hi, 
    I am R.Vivek working on SQUEAK... I am currently now facing a problem...I have a the pixels of a bitmap image which i need to display in SQUEAK...how do i do it??Pl.reply...





Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Tom Phoenix
On 7 Jun 2006 12:45:50 -0000, Noname Myname
<[hidden email]> wrote:

> I have a the pixels of a bitmap image which i need to display

Have you tried making a Morph? Many objects respond to #asMorph,
giving a Morph which may be displayed in a morphic project. You could
first create a Form from your data, if necessary.

Hope this helps!

--Tom Phoenix

Reply | Threaded
Open this post in threaded view
|

Re: Re: (no subject)

siddharth-2
In reply to this post by siddharth-2

 
On Wed, 07 Jun 2006 Tom Phoenix wrote :
>On 7 Jun 2006 12:45:50 -0000, Noname Myname
><[hidden email]> wrote:
>
>>I have a the pixels of a bitmap image which i need to display
>
>Have you tried making a Morph? Many objects respond to #asMorph,
>giving a Morph which may be displayed in a morphic project. You could
>first create a Form from your data, if necessary.
>
>Hope this helps!
>
>--Tom Phoenix

I have the pixels , ( each pixel corresponds to a byte ) ,as a ByteArray.
I cud not create a Form the Pixels , becuz i think the form expects some kind of initial header structure . Although creating a form does not pop any error messages , however when i try to display them , it says an error message in BitBlt 's copybits.
Is there ne work around possible , like directly give the byte values than go by creating a Form etc etc..








Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: (no subject)

Boris.Gaertner

Noname Myname <[hidden email]> wrote:

> >
> >>I have a the pixels of a bitmap image which i need to display
> >
This is not a very clear problem description. What kind of a bitmap
image do you have? a black-and-white image? A grayscaled image? A
colored image? You can create Fomrs with different color depths and
also forms with a color map, but to choose a proper form you have to
know the properties of the image.

> >Have you tried making a Morph? Many objects respond to #asMorph,
> >giving a Morph which may be displayed in a morphic project. You could
> >first create a Form from your data, if necessary.
> >
> >Hope this helps!
> >
> >--Tom Phoenix
>
> I have the pixels , ( each pixel corresponds to a byte ),
> as a ByteArray.
Is such a byte used to represent two color values (black or white)
or up to 256 different colors?

> I cud not create a Form the Pixels , becuz i think the form expects some
> kind of initial header structure . Although creating a form does not pop
> any error messages , however when i try to display them , it says an error
> message in BitBlt 's copybits.
> Is there ne work around possible , like directly give the byte values than
> go by creating a Form etc etc..
>

To display an image, you need a form.

Here is the code to create a black-and-white form from a ByteArray:


 | byteArray extent form cnt |
 byteArray := ByteArray new: 16*16.
 33 to: 64 do: [:idx | byteArray at: idx put: 1].

    " the byteArray stores the pixels of the black-and-white image
      line-by-line. The following code creates a suitable Form and
      copies the bits into the form. "

 form := Form extent: (extent := 16@16).
  cnt := 1.
  0 to: extent y -1 do:
    [:py |
       0 to: extent x -1 do:
          [:px | | isBlack |
             isBlack := (byteArray at: cnt) ~= 0.
             form colorAt: px @py put: (isBlack ifTrue: [Color black] ifFalse: [Color white]).
             cnt := cnt + 1
          ].
    ].

form displayAt: 10 @ 10.



For a gray-scaled image or an image with a color palette you would use a ColorForm that you can convert into a Form if such a conversion is needed.

Hope this helps,
if it does not help, please post a more detailed problem description!

Greetings,
Boris