The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bitsy/gamma.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include <u.h>
    2 #include <libc.h>
    3 #include <stdio.h>
    4 
    5 double  gamma = 1.6;
    6 
    7 int
    8 remap5(int i)
    9 {
   10         double v;
   11 
   12         v = (double)i/31.0;
   13         return 31.0*pow(v, gamma);
   14 }
   15 
   16 int
   17 remap6(int i)
   18 {
   19         double v;
   20 
   21         v = (double)i/63.0;
   22         return 63.0*pow(v, gamma);
   23 }
   24 
   25 int
   26 remap(int i)
   27 {
   28         int r, g, b;
   29 
   30         b = i & 0x1F;
   31         g = (i>>5) & 0x3F;
   32         r = (i>>11) & 0x1F;
   33         return (remap5(r)<<11) | (remap6(g)<<5) | (remap5(b)<<0);
   34 }
   35 
   36 void
   37 main(void)
   38 {
   39         int i;
   40 
   41         printf("/* gamma = %.2f */\n", gamma);
   42         printf("ushort gamma[65536] = {\n");
   43         for(i=0; i<65536; i++){
   44                 if((i%8) == 0)
   45                         printf("\t");
   46                 printf("0x%.4x, ", remap(i));
   47                 if((i%8) == 7)
   48                         printf("\n");
   49         }
   50         printf("};\n");
   51 }

Cache object: 513c9c9f9ab3d363dd7e69569960e8ff


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.