Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Nov 18, 2017 10:38 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Mar 11, 2011 2:11 pm 
Offline

Joined: Mon Mar 19, 2007 8:56 am
Posts: 21
I would like to take a byte array (received via UDP) and use this to draw a graphic on a G75. The format of my data array is bit-masked, where each bit of each byte represents an on/off of a pixel. My received data does not have any color information, just on/off's.

For example ...

Bit0 Bit1 Bit2 Bit3 ...
Byte[0] Row1xCol1 Row1xCol2 Row1xCol3 Row1xCol4 ...
Byte[1] Row2xCol1 Row2xCol2 Row2xCol3 Row2xCol4 ...


Is there any way to to turn this into something useful? Unfortunately I have no control over how this data has been formatted.


Top
 Profile  
 
PostPosted: Fri Mar 11, 2011 2:33 pm 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
The only way I know to do that in Qlarity is by comparing the bits in the array and creating a pixmap. Here is some sample code. 8x8 pixmap created from 8 bytes.
Code:
func Draw (pass as boolean)
    handles MSG_DRAW
    dim b[] as byte
    dim pixmap[] as byte
    dim i, j, idx, c, n as integer

    b := "abcdefgh"
    Redim(pixmap, Len(b) * 8)

    for i = 0 to Len(b) - 1
        n := 1
        for j = 0 to 7
            if (byte(n) and b[i]) <> 0 then
                c := 0
            else
                c := 255
            endif
            idx := i * j
            pixmap[idx] := c
            n := n * 2
        next
    next

    DrawPixmap(30, 30, pixmap, 8, 8)

    return
endfunc

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
PostPosted: Sun Mar 13, 2011 8:37 pm 
Offline

Joined: Mon Mar 19, 2007 8:56 am
Posts: 21
Thanks Ron. Very helpful. The pixmap is just a byte array that "wraps" to the next line based on the mapwidth and map height, and each byte is the color of the pixel? Now how do I call this function explicitly? It seems to only run at startup. Under what conditions (or not) can I call "DrawPixmap"?


Top
 Profile  
 
PostPosted: Mon Mar 14, 2011 8:02 am 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
You can call DrawPixmap inside any function that handles the MSG_DRAW message. If you would like an object to re-draw you can use the function "Rerender".

Code:
Rerender(obj_name_here)


If you need to create an object to do customer drawing in, go to Edit->Add Edit/Tempates to create a new template.

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group