< prev index next >

src/java.desktop/share/native/liblcms/cmsplugin.c

Print this page

 376     return TRUE;
 377 }
 378 
 379 cmsBool CMSEXPORT  _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ)
 380 {
 381     cmsEncodedXYZNumber xyz;
 382 
 383     _cmsAssert(io != NULL);
 384     _cmsAssert(XYZ != NULL);
 385 
 386     xyz.X = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->X));
 387     xyz.Y = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->Y));
 388     xyz.Z = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->Z));
 389 
 390     return io -> Write(io,  sizeof(cmsEncodedXYZNumber), &xyz);
 391 }
 392 
 393 // from Fixed point 8.8 to double
 394 cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8)
 395 {
 396        cmsUInt8Number  msb, lsb;
 397 
 398        lsb = (cmsUInt8Number) (fixed8 & 0xff);
 399        msb = (cmsUInt8Number) (((cmsUInt16Number) fixed8 >> 8) & 0xff);
 400 
 401        return (cmsFloat64Number) ((cmsFloat64Number) msb + ((cmsFloat64Number) lsb / 256.0));
 402 }
 403 
 404 cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val)
 405 {
 406     cmsS15Fixed16Number GammaFixed32 = _cmsDoubleTo15Fixed16(val);
 407     return  (cmsUInt16Number) ((GammaFixed32 >> 8) & 0xFFFF);
 408 }
 409 
 410 // from Fixed point 15.16 to double
 411 cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32)
 412 {
 413     cmsFloat64Number floater, sign, mid;
 414     int Whole, FracPart;
 415 
 416     sign  = (fix32 < 0 ? -1 : 1);
 417     fix32 = abs(fix32);
 418 
 419     Whole     = (cmsUInt16Number)(fix32 >> 16) & 0xffff;
 420     FracPart  = (cmsUInt16Number)(fix32 & 0xffff);
 421 
 422     mid     = (cmsFloat64Number) FracPart / 65536.0;
 423     floater = (cmsFloat64Number) Whole + mid;
 424 
 425     return sign * floater;
 426 }
 427 
 428 // from double to Fixed point 15.16
 429 cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v)
 430 {
 431     return ((cmsS15Fixed16Number) floor((v)*65536.0 + 0.5));
 432 }
 433 
 434 // Date/Time functions
 435 
 436 void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest)
 437 {
 438 
 439     _cmsAssert(Dest != NULL);
 440     _cmsAssert(Source != NULL);
 441 
 442     Dest->tm_sec   = _cmsAdjustEndianess16(Source->seconds);
 443     Dest->tm_min   = _cmsAdjustEndianess16(Source->minutes);
 444     Dest->tm_hour  = _cmsAdjustEndianess16(Source->hours);
 445     Dest->tm_mday  = _cmsAdjustEndianess16(Source->day);

 376     return TRUE;
 377 }
 378 
 379 cmsBool CMSEXPORT  _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ)
 380 {
 381     cmsEncodedXYZNumber xyz;
 382 
 383     _cmsAssert(io != NULL);
 384     _cmsAssert(XYZ != NULL);
 385 
 386     xyz.X = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->X));
 387     xyz.Y = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->Y));
 388     xyz.Z = (cmsS15Fixed16Number) _cmsAdjustEndianess32((cmsUInt32Number) _cmsDoubleTo15Fixed16(XYZ->Z));
 389 
 390     return io -> Write(io,  sizeof(cmsEncodedXYZNumber), &xyz);
 391 }
 392 
 393 // from Fixed point 8.8 to double
 394 cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8)
 395 {
 396     return fixed8 / 256.0;





 397 }
 398 
 399 cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val)
 400 {
 401     cmsS15Fixed16Number GammaFixed32 = _cmsDoubleTo15Fixed16(val);
 402     return  (cmsUInt16Number) ((GammaFixed32 >> 8) & 0xFFFF);
 403 }
 404 
 405 // from Fixed point 15.16 to double
 406 cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32)
 407 {
 408     return fix32 / 65536.0;












 409 }
 410 
 411 // from double to Fixed point 15.16
 412 cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v)
 413 {
 414     return ((cmsS15Fixed16Number) floor((v)*65536.0 + 0.5));
 415 }
 416 
 417 // Date/Time functions
 418 
 419 void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest)
 420 {
 421 
 422     _cmsAssert(Dest != NULL);
 423     _cmsAssert(Source != NULL);
 424 
 425     Dest->tm_sec   = _cmsAdjustEndianess16(Source->seconds);
 426     Dest->tm_min   = _cmsAdjustEndianess16(Source->minutes);
 427     Dest->tm_hour  = _cmsAdjustEndianess16(Source->hours);
 428     Dest->tm_mday  = _cmsAdjustEndianess16(Source->day);
< prev index next >