Lesson 3. BitParser


Lesson 2 : BitStreams | Lesson 4 : PNM Files | Contents


This lesson continues our discussion of Input/Output in Dali. It assumes you are running the same wish from lesson 2.  If not, fire up wish and execute the following commands:

cd C:/Dali/doc/tutorial
source l2.tcl

Input to, and output from, a BitStream is done through a BitParser, another part of DvmBasic package. A BitParser maintains a cursor which points to the next byte to read or write in the BitStream. We can create a BitParser by calling bitparser_new:

set bp [bitparser_new]

Once we create a BitParser we need to attach it to a BitStream bs by calling bitparser_wrap:

bitparser_wrap $bp $bs

This will make the BitParser point to the beginning of the BitStream. We can find out the position of the cursor in the BitStream by :

bitparser_tell $bp

This will return the position of the BitParser. We can move the position of cursor by calling  bitparser_seek:

bitparser_seek $bp 10

This will move the cursor to point at byte 10 in the BitStream.

Knowing the basic of ByteImage, BitStream and BitParser, we can begin to do something interesting. Next we will read in a PPM image and do some thing to it.


Lesson 2 : BitStreams | Lesson 4 : PNM Files | Contents


Last Updated : 06/05/2025 23:37:18