Ejemplo n.º 1
0
// Precomputes tables for 8-bit on input devicelink. 
// 
LPLUT _cmsBlessLUT8(LPLUT Lut)
{
   int i, j;
   WORD StageABC[3];
   Fixed32 v1, v2, v3;
   LPL8PARAMS p8; 
   LPL16PARAMS p = &Lut ->CLut16params;

  
   p8 = (LPL8PARAMS) malloc(sizeof(L8PARAMS));
   if (p8 == NULL) return NULL;

  // values comes * 257, so we can safely take first byte (x << 8 + x)
  // if there are prelinearization, is already smelted in tables

   for (i=0; i < 256; i++) {

           StageABC[0] = StageABC[1] = StageABC[2] = RGB_8_TO_16(i);

           if (Lut ->wFlags & LUT_HASTL1) {

              for (j=0; j < 3; j++)
                     StageABC[i] = cmsLinearInterpLUT16(StageABC[i],
                                                        Lut -> L1[i],
                                                       &Lut -> In16params);
              Lut ->wFlags &= ~LUT_HASTL1;
           }
    
               
           v1 = ToFixedDomain(StageABC[0] * p -> Domain);
           v2 = ToFixedDomain(StageABC[1] * p -> Domain);
           v3 = ToFixedDomain(StageABC[2] * p -> Domain);

           p8 ->X0[i] = p->opta3 * FIXED_TO_INT(v1);
           p8 ->Y0[i] = p->opta2 * FIXED_TO_INT(v2);
           p8 ->Z0[i] = p->opta1 * FIXED_TO_INT(v3);

           p8 ->rx[i] = (WORD) FIXED_REST_TO_INT(v1);
           p8 ->ry[i] = (WORD) FIXED_REST_TO_INT(v2);
           p8 ->rz[i] = (WORD) FIXED_REST_TO_INT(v3);
  
  }

   Lut -> CLut16params.p8 = p8;
   Lut -> CLut16params.Interp3D = cmsTetrahedralInterp8;

   return Lut;

}
Ejemplo n.º 2
0
static
void CreateLabPrelinearization(LPGAMMATABLE LabTable[])
{
    int i;

    LabTable[0] = cmsAllocGamma(257);
    LabTable[1] = cmsBuildGamma(257, 1.0);
    LabTable[2] = cmsBuildGamma(257, 1.0);

    // L* uses 257 entries. Entry 256 holds 0xFFFF, so, the effective range
    // is 0..0xFF00. Last entry (257) is also collapsed to 0xFFFF

    // From 0 to 0xFF00
    for (i=0; i < 256; i++) 
        LabTable[0]->GammaTable[i] = RGB_8_TO_16(i);

    // Repeat last for 0xFFFF
    LabTable[0] ->GammaTable[256] = 0xFFFF;        
}
Ejemplo n.º 3
0
static      vmResult
X_video_restart(void)
{
	/*  Allocate colors every time we enable, 
	   in case some color-hogging apps have left. */

	int         tries = 0;
	int         x, alloced;

	//  Allocate our colors.  For using_palette, allocate read/write
	//  colorcells for 17 colors (bg and text fg change).  Else,
	//  allocate 15 colors.
	//  Either way, cmap[] maps each color to the pixel used to
	//  display it.

	x11_cmap = DefaultColormap(x11_dpy, x11_screen);

	//  Go through twice:  first time, try to allocate colors
	//  from default colormap.  If this fails sufficiently,
	//  allocate a virtual colormap.
	do {

		//  This tells us if colors 0 and 16 (for video reg 7)
		//  can change at will, or if we need to redraw the screen for them
		using_palette = x11_class != TrueColor
			&& x11_class != StaticColor && x11_class != StaticGray;

		//  Get 15 immutable cells
		alloced = 0;
		for (x = 1; x < 16; x++) {
			XColor      color;
			XcmsColor   cmClrScrn, cmClrExact;
			XcmsColorFormat cmFmt;

			color.red = RGB_8_TO_16(vdp_palette[x][0]);
			color.green = RGB_8_TO_16(vdp_palette[x][1]);
			color.blue = RGB_8_TO_16(vdp_palette[x][2]);
			color.flags = DoRed | DoGreen | DoBlue;

			if (!XAllocColor(x11_dpy, x11_cmap, &color)) {
				if (!XAllocNamedColor(x11_dpy, x11_cmap, Xcolornames[x],
									  &color, &color)) {
					module_logger(&X_Video, _L|L_1, _("could not allocate color %d\n"), x);
					//return vmInternalError;
				} else {
					module_logger(&X_Video, _L|L_1, _("color #%d:  got named color '%s'\n"), x,
						 Xcolornames[x]);
					alloced++;
				}
			} else {
				module_logger(&X_Video, _L|L_1, _("color #%d:  got RGB color\n"), x);
				alloced += 2;
			}

			colormap[x] = color.pixel;

		}

		//  Get fg/bg colors
		if (using_palette) {
			if (!XAllocColorCells(x11_dpy, x11_cmap, False /* contiguous */ ,
								  x11_planes, 0, colormap, 1)) {
				using_palette = false;
			} else
				if (!XAllocColorCells
					(x11_dpy, x11_cmap, False /* contiguous */ ,
					 x11_planes, 0, colormap + 16, 1)) {
				using_palette = false;
				// free the one color we got
				XFreeColors(x11_dpy, x11_cmap, colormap, 1, x11_planes[0]);
			}
			if (!using_palette)
				module_logger(&X_Video, _L|LOG_ERROR |L_1,
					 _("Could not allocate 2 read/write colorcells\n"));
		}
//		if (!using_palette) {
//			cmap[0] = cmap[1];
//			cmap[16] = cmap[15];
//		}

		//  If we got an insufficient number of colors,
		//  try for virtual colormap.
		module_logger(&X_Video, _L|L_1, _("alloced = %d\n"), alloced);
		if (!tries && alloced < 16 &&
			(x11_class == GrayScale || x11_class == PseudoColor)) {
			x11_cmap = XCreateColormap(x11_dpy, vwin, x11_visual, AllocNone);
			XSetWindowColormap(x11_dpy, vwin, x11_cmap);
			module_logger(&X_Video, _L|LOG_USER, _("allocated custom colormap for window\n"));
		} else {
			tries = 1;
		}

	} while (++tries < 2);

	XSetWindowColormap(x11_dpy, vwin, x11_cmap);

	XSetWMNormalHints(x11_dpy, vwin, vwin_size_hints);
	XMapWindow(x11_dpy, vwin);

//	x_dirty_screen(0, 0, 32, 24);
	return vmOk;
}