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

📄 filterhpa.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                                    /*   - -   - -                                        |   | |   | We have two 2x2s.                                        |   | |   |                                         - -   - -                                    */                                    lastPixel = get4Pixel(upPtr, -3); // Go back to previous 2x2 block and get the pixel                                    lastR = GetRed(lastPixel);                                    lastG = GetGreen(lastPixel);                                    lastB = GetBlue(lastPixel);                                    if ((maxErrorForEightPixels >= 3) && (NewDeltaE(lastR, R1, lastG, G1,lastB, B1, maxErrorForEightPixels)))                                    {                                        /* - - - -                                          |       | build 4x2.                                          |       |                                           - - - -                                        */#if kGatherStats == 1                                        blockStats[es42i]++;#endif                                        didNotBuild4by2 = false;                                        flagsPtr[-3] = e42i;                                        flagsPtr[-2] = flagsPtr[-1] = flagsPtr[0] = e42;                                        AverageNRound((pixelNum & 0x04) == 0x04, R1, R1, lastR, G1, G1, lastG, B1, B1, lastB); // 4,5,6,7,12,13,14,15,20... Alternate between rounding up down for these 4x2 blocks                                        if(littleEndian)                                            currPixel = (R1<<16) + (G1<<8) + B1;                                        else if(bigEndian)                                            currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                                        put4Pixel(upPtr, -3, currPixel);                                        put4Pixel(upPtr, -2, currPixel);                                        put4Pixel(upPtr, -1, currPixel);                                        put4Pixel(upPtr,  0, currPixel);                                        put4Pixel(currPtr, -3, currPixel);                                        put4Pixel(currPtr, -2, currPixel);                                        put4Pixel(currPtr, -1, currPixel);                                        put4Pixel(currPtr, 0, currPixel);#else                                        put4Pixel(upPtr, -3, currPixel);#endif                                    }                                }                                if (didNotBuild4by2)                                {   // The first 2x2 block of this pair of 2x2 blocks wasn't averaged.                                    /*    - -    - -                                         |X X|  |   | not averaged block and averaged 2x2.                                         |X X|  |   |                                          - -    - -                                    */                                    last2by2Averaged = true;                                    if(littleEndian)                                        currPixel = (R1<<16) + (G1<<8) + B1;                                    else if(bigEndian)                                        currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                                    put4Pixel(upPtr, -1, currPixel);                                    put4Pixel(upPtr, 0, currPixel);                                    put4Pixel(currPtr, -1, currPixel);                                    put4Pixel(currPtr, 0, currPixel);#else                                    put4Pixel(upPtr, -1, currPixel);#endif                                }                            }                            else  // Not looking for a 4x2 block yet so just output this 2x2 block for now.                            {                                /*    - -    - -                                     |   |  |? ?| 1st 2x2 and maybe another later.                                     |   |  |? ?|                                      - -    - -                                */                                last2by2Averaged = true;                                if(littleEndian)                                    currPixel = (R1<<16) + (G1<<8) + B1;                                else if(bigEndian)                                    currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                                put4Pixel(upPtr, -1, currPixel);                                put4Pixel(upPtr, 0, currPixel);                                put4Pixel(currPtr, -1, currPixel);                                put4Pixel(currPtr, 0, currPixel);#else                                put4Pixel(upPtr, -1, currPixel);#endif                            }                        }                        else  // The two averaged columns are not close enough in Delta E                        {                            /*  -    _                               | |  | | 2 1x2 blocks                               | |  | |                                -    -                            */                            last2by2Averaged = false;                            if(littleEndian)                                currPixel = (R1<<16) + (G1<<8) + B1;                            else if(bigEndian)                                currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                            put4Pixel(upPtr, 0, currPixel);                            put4Pixel(currPtr, 0, currPixel);#else                            put4Pixel(upPtr,0, currPixel);#endif                        }                        lastR = R1;                        lastG = G1;                        lastB = B1;                        lastPairAveraged = true;                    }                    else  // This is the right place for 2x2 averaging but the previous column wasn't averaged                    {                        /*     -                            X | | Two non averaged pixels and a 1x2.                            X | |                               -                        */                        last2by2Averaged = false;                        lastPairAveraged = true;                        lastR = R1;                        lastG = G1;                        lastB = B1;                        if(littleEndian)                            currPixel = (R1<<16) + (G1<<8) + B1;                        else if(bigEndian)                            currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                        put4Pixel(upPtr, 0, currPixel);                        put4Pixel(currPtr, 0, currPixel);#else                        put4Pixel(upPtr, 0, currPixel);#endif                    }                }                else  // Not on the boundary for a 2x2 block, so just output current averaged 1x2 column                {                    /*    -                         | | ?  1x2                         | | ?                          -                    */                    lastPairAveraged = true;                    lastR = R1;                    lastG = G1;                    lastB = B1;                    if(littleEndian)                        currPixel = (R1<<16) + (G1<<8) + B1;                    else if(bigEndian)                        currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                    put4Pixel(upPtr, 0, currPixel);                    put4Pixel(currPtr, 0, currPixel);#else                    put4Pixel(upPtr, 0, currPixel);#endif                }            }            else if (lastPairAveraged)            {   // This is the case where we can't average current column and the last column was averaged.                // Don't do anything if last pair was averaged and this one can't be                /*    -                     | | X 1x2 averaged block and two non averaged pixels.                     | | X                      -                */                lastPairAveraged = false;            }            else             // can't vertically average current column so look for some horizontal averaging as a fallback             // Only do it if the last pair wasn't averaged either because we don't want to mess up a vertical averaging             // just to create a possible horizontal averaging.            {                // Can only horizontally average every other pixel, much like the 2x2 blocks.                if (isOdd(pixelNum))                {                    // do horizontal averaging on previous raster                    lastPixel = get4Pixel(upPtr,-1);                    lastR = GetRed(lastPixel);                    lastG = GetGreen(lastPixel);                    lastB = GetBlue(lastPixel);                    if (((fMaxErrorForTwoPixels >= 3)) && (NewDeltaE(lastR, R0, lastG, G0,lastB, B0, fMaxErrorForTwoPixels)))                    {                        /*   - -                            |   | build upper 2x1                             - -                        */#if kGatherStats == 1                        blockStats[es21nw]++;#endif                        int didNotBuild4by1 = true;                        AverageNRound(isOdd(pixelNum), lastR, lastR, R0, lastG, lastG, G0, lastB, lastB, B0);                        if ((pixelNum >= 3) && (flagsPtr[-3] & e21nw)) // 4,5,6,7,12,13,14,15,20...                        {                            ASSERT(!((flagsPtr[-3] | flagsPtr[-2] | flagsPtr[-1] | flagsPtr[0]) & eTheRest)); // no vertical blocks                            // Attempt an upper 4x1                            lastPixel = get4Pixel(upPtr,-3);                            R0 = GetRed(lastPixel);                            G0 = GetGreen(lastPixel);                            B0 = GetBlue(lastPixel);                            if ( (maxErrorForFourPixels >= 3) && (NewDeltaE(lastR, R0, lastG, G0,lastB, B0, maxErrorForFourPixels)))                            {                                /*   - - - -                                    |       | build upper 4x1                                     - - - -                                */#if kGatherStats == 1                                blockStats[es41ni]++;#endif                                didNotBuild4by1 = false;                                AverageNRound((pixelNum & 0x04)== 0x04, lastR, lastR, R0, lastG, lastG, G0, lastB, lastB, B0); // 4,5,6,7,12,13,14,15,20...                                if(littleEndian)                                    currPixel = (lastR<<16) + (lastG<<8) + lastB;                                else if(bigEndian)                                    currPixel = (lastR<<24) + (lastG<<16) + (lastB<<8);#if kMemWritesOptimize == 0                                put4Pixel(upPtr, -3, currPixel);                                put4Pixel(upPtr, -2, currPixel);                                put4Pixel(upPtr, -1, currPixel);                                put4Pixel(upPtr, 0, currPixel);#else                                put4Pixel(upPtr, -3, currPixel);#endif                                ASSERT(!((flagsPtr[-3] | flagsPtr[-2] | flagsPtr[-1] | flagsPtr[0]) & eTheRest)); // no vertical blocks                                flagsPtr[-3] = (flagsPtr[-3] & ~eNorths) | e41ni;                                flagsPtr[-2] = (flagsPtr[-2] & ~eNorths) | e41n;                                flagsPtr[-1] = (flagsPtr[-1] & ~eNorths) | e41n;                                flagsPtr[0] = (flagsPtr[0] & ~eNorths) | e41n;                            }                        }                        if (didNotBuild4by1) // Not an upper 4x1 so output upper 2x1.                        {                            if(littleEndian)                                currPixel = (lastR<<16) + (lastG<<8) + lastB;                            else if(bigEndian)                                currPixel = (lastR<<24) + (lastG<<16) + (lastB<<8);#if kMemWritesOptimize == 0                            put4Pixel(upPtr, -1, currPixel);                            put4Pixel(upPtr, 0, currPixel);#else                            put4Pixel(upPtr, -1, currPixel);#endif                            ASSERT(!((flagsPtr[-1] | flagsPtr[0]) & eTheRest)); // no vertical blocks                            flagsPtr[-1] = (flagsPtr[-1] & ~eNorths) | e21nw;                            flagsPtr[0] = (flagsPtr[0] & ~eNorths) | e21ne;                        }                    }                    // do horizontal on current raster                    lastPixel = get4Pixel(currPtr,-1);                    lastR = GetRed(lastPixel);                    lastG = GetGreen(lastPixel);                    lastB = GetBlue(lastPixel);                    if ((fMaxErrorForTwoPixels >= 3) && (NewDeltaE(lastR, R1, lastG, G1, lastB, B1, fMaxErrorForTwoPixels)))                    {                        /*   - -                            |   | build lower 2x1                             - -                        */                        int didNotBuild4by1 = true;#if kGatherStats == 1                        blockStats[es21sw]++;#endif                        AverageNRound(isOdd(pixelNum), lastR, lastR, R1, lastG, lastG, G1, lastB, lastB, B1);                        if ((pixelNum >= 3) && (flagsPtr[-3] & e21sw)) // 4,5,6,7,12,13,14,15,20...                        {                            // Look for a lower 4x1                            ASSERT(!((flagsPtr[-3] | flagsPtr[-2] | flagsPtr[-1] | flagsPtr[0]) & eTheRest)); // no vertical blocks                            lastPixel = get4Pixel(currPtr,-3);                            R0 = GetRed(lastPixel);                            G0 = GetGreen(lastPixel);                            B0 = GetBlue(lastPixel);                            if ((maxErrorForFourPixels >= 3) && (NewDeltaE(lastR, R0, lastG, G0, lastB, B0, maxErrorForFourPixels)))                            {                                /*   - - - -                                    |       | build lower 4x1                                     - - - -                                */#if kGatherStats == 1                                blockStats[es41si]++;#endif                                didNotBuild4by1 = false;                                AverageNRound((pixelNum & 0x04)== 0x04, lastR, lastR, R0, lastG, lastG, G0, lastB, lastB, B0); // 4,5,6,7,12,13,14,15,20...

⌨️ 快捷键说明

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