///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Library                                //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header
  
  + name    := Expanded PIXEL_16;


  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";
  
  - comment := "Pixel on 16 bits.";
    
Section Insert
  
  + parent_pixel:Expanded PIXEL;
  
Section Mapping  
  
  + real_color:UINTEGER_16;
  
Section Private  
    
  - convert_5_to_8:FAST_ARRAY[UINTEGER_8] :=
  ( + result:FAST_ARRAY[UINTEGER_8];
    + value:UINTEGER_8;
    
    result:=FAST_ARRAY[UINTEGER_8].create 32;    
    0.to 31 do { j:INTEGER;
      result.put value to j;
      value := value + 8;
    };
    result
  );
  
  - convert_6_to_8:FAST_ARRAY[UINTEGER_8] :=
  ( + result:FAST_ARRAY[UINTEGER_8];
    + value:UINTEGER_8;
    
    result:=FAST_ARRAY[UINTEGER_8].create 64;    
    0.to 63 do { j:INTEGER;
      result.put value to j;
      value := value + 4;
    };
    result
  );
      
Section Public
    
  - red:UINTEGER_8 <- 
  (
    (((real_color >> 11) & 1Fh)  << 3).to_uinteger_8
    //convert_5_to_8.item (real_color >> 11)
  );
  
  - green:UINTEGER_8 <- 
  (
    (((real_color >> 5) & 3Fh) << 2).to_uinteger_8
    //convert_6_to_8.item ((real_color >> 5) & 03Fh)
  );

  - blue:UINTEGER_8 <- 
  (
    ((real_color & 1Fh) << 3).to_uinteger_8
//    convert_5_to_8.item (real_color & 01Fh)
  );
  
  - get_raw col:UINTEGER_32 :UINTEGER_32 <-
  (
    ((col & 0F80000h) >> 8) |
    ((col & 000FC00h) >> 5) |
    ((col & 00000F8h) >> 3)
  );
  
  - make col:UINTEGER_32 <-
  (     
    real_color := (
      ((col & 0F80000h) >> 8) |
      ((col & 000FC00h) >> 5) |
      ((col & 00000F8h) >> 3)
    ).to_uinteger_16;
  );
  
  - color_rgb (r,g,b:UINTEGER_8) <-
  ( 
    real_color := (
      ((r & 0F8h).to_uinteger_16 << 8) |
      ((g & 0FCh).to_uinteger_16 << 3) |
      ((b & 0F8h).to_uinteger_16 >> 3)
    );
  );
  
  - size:UINTEGER_8       := 16; 
  - red_size:UINTEGER_8   := 5;
  - red_pos:UINTEGER_8    := 11;
  - green_size:UINTEGER_8 := 6;
  - green_pos:UINTEGER_8  := 5;
  - blue_size:UINTEGER_8  := 5;
  - blue_pos:UINTEGER_8   := 0;
  - reserved_size:UINTEGER_8 :=0;
  - reserved_pos:UINTEGER_8  :=0;
    
  - to_pixel_16:PIXEL_16 <- Self;




