Copyright (C) 2002 HelDoRe
Web design by Nauthiz

 
Project hosted at
SourceForge.Net

Polish version of this page

Description of ZMG File Format

Apart from reading so many image file formats, MGA View can also save files in its own native format called zmg. By now it has no capability to do the opposite, i.e. convert zmg files to formats other than tga, but this function will be added in future.

The structure of zmg file depends immediately on the way MGA View processes the image data to display it on the screen. The mga_vid driver uses data stored as YUV instead of RGB. YUV is a combination of three terms: Y, U and V. Y occupies 1 byte per pixel and stores the outline of an image, whereas U and V occupy 1 byte per 4 pixels (2x2 pixels area) each and they stand for the intensity of red and blue respectively. If U and V both equal -128, the image is black and white (so we can say Y is grayscale whereas U and V store the colours of an image). More information about YUV can be found in here.

To display the image, MGA View has to convert the data from RGB to YUV. Only in this form the data can be sent into the graphics card memory. ZMG stores image data as YUV, so file in this format is read faster than others for no prior conversion is needed.

Below you can find a thorough description of a file in ZMG format:

File header: "zMG"
File version (4 possibilities available):

  • 1 - YU12 uncompressed
  • 2 - YU12 compressed
  • 3 - YU12 uncompressed grayscale
  • 4 - YU12 compressed grayscale

File width - 2 bytes
File height - 2 bytes

V 1
Term Y, than U and in the end V

Version 2
Next 3 bytes determine amount of data compressed for Y term, which is directly being followed by Y term data.
Next 3 bytes determine the length of compressed U term followed by the U term data.
And again - 3 bytes determining the length of V term and the rest of data.

Version 3
Y term only

Version 4
3 bytes determine the length of the Y term, then Y term data.

So the whole file looks like that:

description        number of bytes
 HEADER                 3
 VERSION                1
 IMAGE X                2
 IMAGE Y                2

 for version 1:
 term Y         IMAGE X * IMAGE Y
 term U        (IMAGE X * IMAGE Y)/4
 term V        (IMAGE X * IMAGE Y)/4

 Version 2:
 Y length               3
 Y term             Y length
 U length               3
 U term             U length
 V length               3
 V term             V length

 Version 3:
 Y term         IMAGE X * IMAGE Y

 Version 4:
 Y length               3
 Y term             Y length


Last update: Wed, 16 October 2002   MGA View 2002 by HelDoRe <tehace@konto.pl>
Web design by Nauthiz <nauthiz@wp.pl>