⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsps2.c

📁 Linux下的无线网卡通用驱动程序
💻 C
📖 第 1 页 / 共 4 页
字号:
                    Writef(m, "[ /CIEBasedA\n");        Writef(m, "  <<\n");        Writef(m, "/DecodeA ");        Emit1Gamma(m,Tab, nEntries);        Writef(m, " \n");        Writef(m, "/MatrixA [ 0.9642 1.0000 0.8249 ]\n");        Writef(m, "/RangeLMN [ 0.0 0.9642 0.0 1.0000 0.0 0.8249 ]\n");                EmitWhiteBlackD50(m, BlackPoint);        EmitIntent(m, INTENT_PERCEPTUAL);        Writef(m, ">>\n");                Writef(m, "]\n");                return 1;}// Dumps CIEBasedABC Color Space Arraystaticint EmitCIEBasedABC(LPMEMSTREAM m, LPWORD L[], int nEntries, LPWMAT3 Matrix, LPcmsCIEXYZ BlackPoint){    int i;        Writef(m, "[ /CIEBasedABC\n");        Writef(m, "<<\n");        Writef(m, "/DecodeABC [ ");         EmitNGamma(m, 3, L, nEntries);        Writef(m, "]\n");                Writef(m, "/MatrixABC [ " );        for( i=0; i < 3; i++ ) {                        Writef(m, "%.6f %.6f %.6f ",                         FIXED_TO_DOUBLE(Matrix->v[0].n[i]),                        FIXED_TO_DOUBLE(Matrix->v[1].n[i]),                        FIXED_TO_DOUBLE(Matrix->v[2].n[i]));                    }            Writef(m, "]\n");        Writef(m, "/RangeLMN [ 0.0 0.9642 0.0 1.0000 0.0 0.8249 ]\n");                EmitWhiteBlackD50(m, BlackPoint);        EmitIntent(m, INTENT_PERCEPTUAL);        Writef(m, ">>\n");        Writef(m, "]\n");                return 1;}staticint EmitCIEBasedDEF(LPMEMSTREAM m, LPLUT Lut, int Intent, LPcmsCIEXYZ BlackPoint){    const char* PreMaj;    const char* PostMaj;    const char* PreMin, *PostMin;    switch (Lut ->InputChan) {    case 3:            Writef(m, "[ /CIEBasedDEF\n");            PreMaj ="<";             PostMaj= ">\n";            PreMin = PostMin = "";            break;    case 4:            Writef(m, "[ /CIEBasedDEFG\n");            PreMaj = "[";            PostMaj = "]\n";            PreMin = "<";            PostMin = ">\n";            break;    default:            return 0;    }    Writef(m, "<<\n");    if (Lut ->wFlags & LUT_HASTL1) {            Writef(m, "/DecodeDEF [ ");        EmitNGamma(m, Lut ->InputChan, Lut ->L1, Lut ->CLut16params.nSamples);        Writef(m, "]\n");    }    if (Lut ->wFlags & LUT_HAS3DGRID) {            Writef(m, "/Table ");                WriteCLUT(m, Lut, 8, PreMaj, PostMaj, PreMin, PostMin, TRUE, FALSE, (icColorSpaceSignature) 0);            Writef(m, "]\n");    }           EmitLab2XYZ(m);    EmitWhiteBlackD50(m, BlackPoint);    EmitIntent(m, Intent);    Writef(m, "   >>\n");           Writef(m, "]\n");        return 1;}// Because PostScrip has only 8 bits in /Table, we should use// a more perceptually uniform space... I do choose Lab.staticint WriteInputLUT(LPMEMSTREAM m, cmsHPROFILE hProfile, int Intent){    cmsHPROFILE hLab;    cmsHTRANSFORM xform;    icColorSpaceSignature ColorSpace;    int nChannels;    DWORD InputFormat;    int rc;    cmsHPROFILE Profiles[2];    cmsCIEXYZ BlackPointAdaptedToD50;    // Does create a device-link based transform.     // The DeviceLink is next dumped as working CSA.        hLab        = cmsCreateLabProfile(NULL);    ColorSpace  =  cmsGetColorSpace(hProfile);    nChannels   = _cmsChannelsOf(ColorSpace);    InputFormat = CHANNELS_SH(nChannels) | BYTES_SH(2);    cmsDetectBlackPoint(&BlackPointAdaptedToD50, hProfile, Intent,LCMS_BPFLAGS_D50_ADAPTED);    // Is a devicelink profile?    if (cmsGetDeviceClass(hProfile) == icSigLinkClass) {        // if devicelink output already Lab, use it directly        if (cmsGetPCS(hProfile) == icSigLabData) {                        xform = cmsCreateTransform(hProfile, InputFormat, NULL,                             TYPE_Lab_DBL, Intent, 0);        }        else {            // Nope, adjust output to Lab if possible            Profiles[0] = hProfile;            Profiles[1] = hLab;            xform = cmsCreateMultiprofileTransform(Profiles, 2,  InputFormat,                                     TYPE_Lab_DBL, Intent, 0);        }    }    else {        // This is a normal profile        xform = cmsCreateTransform(hProfile, InputFormat, hLab,                             TYPE_Lab_DBL, Intent, 0);    }        if (xform == NULL) {                                    cmsSignalError(LCMS_ERRC_ABORTED, "Cannot create transform Profile -> Lab");            return 0;    }    // Only 1, 3 and 4 channels are allowed    switch (nChannels) {    case 1: {            // LPGAMMATABLE Gray2Y = ExtractGray2Y(xform);            // rc = EmitCIEBasedA(m, Gray2Y->GammaTable, Gray2Y ->nEntries, hProfile);            // cmsFreeGamma(Gray2Y);            cmsSignalError(LCMS_ERRC_ABORTED, "Monochrome LUT-based currently unsupported for CSA generation");            }            break;    case 3:     case 4: {            LPLUT DeviceLink;            _LPcmsTRANSFORM v = (_LPcmsTRANSFORM) xform;            if (v ->DeviceLink)                 rc = EmitCIEBasedDEF(m, v->DeviceLink, Intent, &BlackPointAdaptedToD50);            else {                DeviceLink = _cmsPrecalculateDeviceLink(xform, 0);                rc = EmitCIEBasedDEF(m, DeviceLink, Intent, &BlackPointAdaptedToD50);                cmsFreeLUT(DeviceLink);            }            }            break;    default:            cmsSignalError(LCMS_ERRC_ABORTED, "Only 3, 4 channels supported for CSA. This profile has %d channels.", nChannels);            return 0;    }        cmsDeleteTransform(xform);    cmsCloseProfile(hLab);    return 1;}// Does create CSA based on matrix-shaper. Allowed types are gray and RGB basedstaticint WriteInputMatrixShaper(LPMEMSTREAM m, cmsHPROFILE hProfile){    icColorSpaceSignature ColorSpace;    LPMATSHAPER MatShaper;    int rc;    cmsCIEXYZ BlackPointAdaptedToD50;    ColorSpace = cmsGetColorSpace(hProfile);    MatShaper  = cmsBuildInputMatrixShaper(hProfile);    cmsDetectBlackPoint(&BlackPointAdaptedToD50, hProfile, INTENT_RELATIVE_COLORIMETRIC, LCMS_BPFLAGS_D50_ADAPTED);    if (MatShaper == NULL) {                cmsSignalError(LCMS_ERRC_ABORTED, "This profile is not suitable for input");                return 0;    }    if (ColorSpace == icSigGrayData) {                        rc = EmitCIEBasedA(m, MatShaper ->L[0],                                   MatShaper ->p16.nSamples,                                  &BlackPointAdaptedToD50);            }    else        if (ColorSpace == icSigRgbData) {                    rc = EmitCIEBasedABC(m, MatShaper->L,                                         MatShaper ->p16.nSamples,                                         &MatShaper ->Matrix,                                        &BlackPointAdaptedToD50);              }        else  {            cmsSignalError(LCMS_ERRC_ABORTED, "Profile is not suitable for CSA. Unsupported colorspace.");            return 0;        }    cmsFreeMatShaper(MatShaper);    return rc;}// Creates a PostScript color list from a named profile data. // This is a HP extension, and it works in Lab instead of XYZstaticint WriteNamedColorCSA(LPMEMSTREAM m, cmsHPROFILE hNamedColor, int Intent){    cmsHTRANSFORM xform;    cmsHPROFILE   hLab;    int i, nColors;    char ColorName[32];    hLab  = cmsCreateLabProfile(NULL);    xform = cmsCreateTransform(hNamedColor, TYPE_NAMED_COLOR_INDEX,                         hLab, TYPE_Lab_DBL, Intent, cmsFLAGS_NOTPRECALC);    if (xform == NULL) return 0;    Writef(m, "<<\n");    Writef(m, "(colorlistcomment) (%s)\n", "Named color CSA");    Writef(m, "(Prefix) [ (Pantone ) (PANTONE ) ]\n");    Writef(m, "(Suffix) [ ( CV) ( CVC) ( C) ]\n");    nColors   = cmsNamedColorCount(xform);    for (i=0; i < nColors; i++) {                WORD In[1];        cmsCIELab Lab;        In[0] = (WORD) i;        if (!cmsNamedColorInfo(xform, i, ColorName, NULL, NULL))                continue;        cmsDoTransform(xform, In, &Lab, 1);             Writef(m, "  (%s) [ %.3f %.3f %.3f ]\n", ColorName, Lab.L, Lab.a, Lab.b);    }            Writef(m, ">>\n");    cmsDeleteTransform(xform);    cmsCloseProfile(hLab);    return 1;}// Does create a Color Space Array on XYZ colorspace for PostScript usageDWORD LCMSEXPORT cmsGetPostScriptCSA(cmsHPROFILE hProfile,                               int Intent,                               LPVOID Buffer, DWORD dwBufferLen){        LPMEMSTREAM mem;    DWORD dwBytesUsed;        // Set up the serialization engine    mem = CreateMemStream((LPBYTE) Buffer, dwBufferLen, MAXPSCOLS);    if (!mem) return 0;        // Is a named color profile?    if (cmsGetDeviceClass(hProfile) == icSigNamedColorClass) {        if (!WriteNamedColorCSA(mem, hProfile, Intent)) {                    free((void*) mem);                    return 0;        }    }    else {    // Any profile class are allowed (including devicelink), but    // output (PCS) colorspace must be XYZ or Lab    icColorSpaceSignature ColorSpace = cmsGetPCS(hProfile);    if (ColorSpace != icSigXYZData &&        ColorSpace != icSigLabData) {            cmsSignalError(LCMS_ERRC_ABORTED, "Invalid output color space");            free((void*) mem);            return 0;    }        // Is there any CLUT?    if (IsLUTbased(hProfile, Intent)) {        // Yes, so handle as LUT-based        if (!WriteInputLUT(mem, hProfile, Intent)) {                    free((void*) mem);                    return 0;        }    }    else {                // No, try Matrix-shaper (this only works on XYZ)        if (!WriteInputMatrixShaper(mem, hProfile)) {                    free((void*) mem);  // Something went wrong                    return 0;        }    }    }        // Done, keep memory usage    dwBytesUsed = mem ->dwUsed;    // Get rid of memory stream    free((void*) mem);    // Finally, return used byte count    return dwBytesUsed;}// ------------------------------------------------------ Color Rendering Dictionary (CRD)/*  Black point compensation plus chromatic adaptation:  Step 1 - Chromatic adaptation  =============================          WPout    X = ------- PQR          Wpin  Step 2 - Black point compensation  =================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -