home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI08.ARJ / ictari.08 / GFA / BITPLANE.TXT < prev   
Text File  |  1994-02-13  |  6KB  |  134 lines

  1.         Subject: The Complete And Essential Guide To Bitmaps
  2.        Part One: Bitplane Basics
  3.              By: James Collett (Professor)
  4.     A Member Of: VIRTUAL INFINITY
  5.            Date: January 1994
  6.          E-mail: s6005146@brookes.ac.uk
  7.         Address: Park View Farm, Carlton, Nr Nuneaton, Warks, CV13 ODA
  8.     Mono account: bcc
  9.  
  10.  
  11.     The ST`s Screens
  12.     ================
  13.     Starting  with something that is known,   the resolutions & colours  of
  14.     the ST compatible screens:
  15.  
  16.                Screen   | Resolution| Max Colours| => bits/pixel
  17.              -----------+-----------+------------+---------------
  18.                 LOW     | 320 * 200 |     16     |       4
  19.                MEDIUM   | 640 * 200 |      4     |       2
  20.               HI (MONO) | 640 * 400 |      2     |       1
  21.  
  22.     From this the screen length in  bits  can be calculated,  and from that
  23.     the length in bytes can be calculated:
  24.  
  25.                     LOW = (320 * 200 * 4) / 8 = 32000 bytes
  26.                  MEDIUM = (640 * 200 * 2) / 8 = 32000 bytes
  27.                    MONO =   (640 * 400) / 8   = 32000 bytes
  28.  
  29.  
  30.     Introducing Bitplanes On The ST
  31.     ===============================
  32.     Starting with MEDIUM res, each pixel(P) needs two bits(B) as follows:-
  33.  
  34.            B1a  B1b             B31a   B31b
  35.              \  /                  \   /
  36.           P0, P1, P2 > P15;   P16 > P31;   P32 > P47;   and so on...
  37.          /  \         /   \
  38.        B0a  B0b    B15a   B15b
  39.  
  40.     These bits are not stored  consecutively.    Instead they are stored in
  41.     groups of 16, 16 being the ST`s WORD SIZE, as follows :-
  42.  
  43.           +-----Make up P1------+             +-Make up P16--+
  44.           |                     |             |              |
  45.     B0a,B1a,B2a > B15a;   B0b,B1b > B15b;   B16a > B31a;   B16b > B31b;
  46.     ~~~~~~~~~~~~~~~~~~    ~~~~~~~~~~~~~~    ~~~~~~~~~~~    ~~~~~~~~~~~
  47.      Bitplane 0            Plane 1         Plane 0        Plane 1
  48.       (Block 0)           (Block 0)       (Block 1)      (Block 1)
  49.  
  50.     A group of 16 pixels lower  bits  are all stored together,  followed by
  51.     that groups  higher  bits,   and  each  'group  of  bits'  is  called a
  52.     BITPLANE.  Each  group  of  pixels  (called  a  BLOCK) consists of  two
  53.     bitplanes  in  Medium res.
  54.  
  55.     Moving onto LOW res, and again starting with the pixels:
  56.  
  57.                     P0 > P15;   P16 > P31;   and so on...
  58.  
  59.     For this case each pixel needs 4  bits(B),   namely a > d,  and thus  4
  60.     bitplanes are needed as follows:
  61.  
  62.                                   All  make  up  P15
  63.                        +-------------+-------------+-------------+
  64.                        |             |             |             |
  65.     (Block 0)  B0a > B15a;   B0b > B15b;   B0c > B15c;   B0d > B15d;
  66.     (Block 1)  B16a > B31a;  B16b > B31b;  B16c > B31c;  B16d > B31d;  ...
  67.                ~~~~~~~~~~~   ~~~~~~~~~~~   ~~~~~~~~~~~   ~~~~~~~~~~~
  68.                  Plane 0       Plane 1       Plane 2       Plane 3
  69.  
  70.     Each  group of 16 pixels (called  a  BLOCK) consists of four  bitplanes
  71.     in Low res.
  72.  
  73.     In MONO,  as there is only 1  bitplane  (i.e. 1 bit/pixel), coding is a
  74.     lot less  complex  as  "P0>P15;   P16>P31"  is  simply  represented  by
  75.     "B0>B15;  B16>B31".   Each  block  consists   of only one  bitplane  in
  76.     Mono,  and  therefore a block is identical to a bitplane.
  77.  
  78.  
  79.     Bitmaps and Blocks In General
  80.     =============================
  81.     On a machine with a PLANE SIZE of  16  bits,  such as the ST, the first
  82.     16  pixels  (P0 to P15)  are  stored  in  the first  block  (block  0),
  83.     the  second  16 pixels  (16  to  32)  are  stored  in  the second block
  84.     (block  1),  and so on.   On a  machine  with  a plane size of 16 bits,
  85.     the Pth pixel is  in block P DIV  16.    On a machine with a plane size
  86.     of S bits,  the  Pth  pixel is in block P DIV S.
  87.  
  88.     The total number of blocks can  be  found by dividing the total  bitmap
  89.     length (in bits) by the size of each block (in bits):
  90.  
  91.                      Bitmap length   Total pixels * Number of planes
  92.       Total blocks = ------------- = -------------------------------
  93.                       Block size      Plane size * Number of planes
  94.  
  95.     The number of blocks for the three ST compatible screens are:
  96.  
  97.                    LOW = 256000 / (16 * 4) =  4000 blocks
  98.                 MEDIUM = 256000 / (16 * 2) =  8000 blocks
  99.                   MONO = 256000 / (16)     = 16000 blocks
  100.  
  101.  
  102.     Pixels And Planes In General
  103.     ============================
  104.     In order to write to or read  from  a pixel,  the block where the pixel
  105.     is stored must be determined.  As  already  discussed, the Pth pixel is
  106.     in  block P DIV S on a machine with a plane size of S bits.
  107.  
  108.     A pixel`s colour is determined by one  bit in every plane, where planes
  109.     count from 0 to N-1 (inclusive) on a machine with N planes:
  110.  
  111.                                All  make  up  P63
  112.                   +-------------+-------------+-------------+
  113.                   |             |             |             |
  114.           B48a > B63a;  B48b > B63b;  B48c > B63c;  B48d > B63d;
  115.           ~~~~~~~~~~~   ~~~~~~~~~~~   ~~~~~~~~~~~   ~~~~~~~~~~~
  116.             Plane 0       Plane 1       Plane 2       Plane 3
  117.  
  118.     On a machine with a plane size of  S  bits, the POSITION (of the bit in
  119.     each  plane) for the Pth pixel  would  be  the  (P MOD S-1)th  bit,  if
  120.     the  machine started counting  from  the  least  significant bit (right
  121.     end).  As  the  machine  starts  from the most  significant  bit  (left
  122.     end),  the  POSITION  for the Pth pixel is actually the (S-P MOD S-1)th
  123.     bit in  each  plane, on a machine with a plane size of S bits.
  124.  
  125.  
  126.     And Finally: Feedback
  127.     =====================
  128.     All comments,  queries,  suggestions,   ideas,  error / incompatibility
  129.     reports,  etc are welcome  -  both  positive  and negative.   My E-mail
  130.     and  postal addresses are previously listed.
  131.  
  132.  
  133.                                    ---END---
  134.