Vobsub (.sub & .idx) file structure



Hi i was thinking about writing a little program or maybe just a php script to convert subrip subtitles to sub + idx.
The idx file is not very hard to understand and maybe not the sub files either but anyhow i dont quite understand the sub, i know it’s some sort of bitmap images all merged into one big file and the idx tells us where each bitmap is placed!.
But to the problem… how do i create such a bitmap? I mean exactly what format is used, and is it compressed in some way?
I used a hex editor to extract one sub image and it works well with vobsub but what format is the bitmap? is it maybe a native vobsub format or could i use some other program to open and view the bitmap as an ordinary image file?
If anybody knows, please give me a hint!