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

📄 filterhpa.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                                if(littleEndian)                                    currPixel = (lastR<<16) + (lastG<<8) + lastB;                                else if(bigEndian)                                    currPixel = (lastR<<24) + (lastG<<16) + (lastB<<8);#if kMemWritesOptimize == 0                                put4Pixel(currPtr, -3, currPixel);                                put4Pixel(currPtr, -2, currPixel);                                put4Pixel(currPtr, -1, currPixel);                                put4Pixel(currPtr, 0, currPixel);#else                                put4Pixel(currPtr, -3, currPixel);#endif                                flagsPtr[-3] = (flagsPtr[-3] & ~eSouths) | e41si;                                flagsPtr[-2] = (flagsPtr[-2] & ~eSouths) | e41s;                                flagsPtr[-1] = (flagsPtr[-1] & ~eSouths) | e41s;                                flagsPtr[0] = (flagsPtr[0] & ~eSouths) | e41s;                            }                        }                        if (didNotBuild4by1) // Not a lower 4x1 so output lower 2x1.                        {                            ASSERT(!((flagsPtr[-1] | flagsPtr[0]) & eTheRest)); // no vertical blocks                            if(littleEndian)                                currPixel = (lastR<<16) + (lastG<<8) + lastB;                            else if(bigEndian)                                currPixel = (lastR<<24) + (lastG<<16) + (lastB<<8);#if kMemWritesOptimize == 0                            put4Pixel(currPtr, -1, currPixel);                            put4Pixel(currPtr, 0, currPixel);#else                            put4Pixel(currPtr, -1, currPixel);#endif                            flagsPtr[-1] = (flagsPtr[-1] & ~eSouths) | e21sw;                            flagsPtr[0] = (flagsPtr[0] & ~eSouths) | e21se;                        }                    }  // If DeltaE... Looking for two by one                }  // IsOdd(pixelNum)            }        }        else // no flag bits set.        {            lastPairAveraged = false; // EGW Fixes bug on business graphics. 11/24/97        }        upPtr += eBufferedPixelWidthInBytes;        currPtr += eBufferedPixelWidthInBytes;        flagsPtr++;    }  // for each pixel...}// Filter2PairsOfFilteredRows.  This routine takes 2 pairs of rows that// have been through the Filter2RawRows routine and puts blocks together// to make bigger blocks.  It prefers taking 2 high blocks and putting// them together to make four high blocks, but as a last resort it will// take try to take a 1 high blocks from the second and third rasters and// create 2 high blocks.  The possible block sizes this routine could// create are 8x4, 4x4, 2x4, and 1x4, and then with the second and third rasters// 4x2, 2x2, and 1x2.void TErnieFilter::Filter2PairsOfFilteredRows(unsigned char *row1Ptr, unsigned char *row2Ptr, unsigned char *row3Ptr, unsigned char *row4Ptr){    const unsigned int maxErrorForFourPixels = fMaxErrorForTwoPixels / 2;    const unsigned int maxErrorForEightPixels = maxErrorForFourPixels / 2;    const unsigned int maxErrorForSixteenPixels = maxErrorForEightPixels / 2;    const unsigned int maxErrorForThirtyTwoPixels = maxErrorForSixteenPixels / 2;    for (int pixelNum = 0; pixelNum < (fRowWidthInPixels-3);)  // Make sure we have four pixels to work with    {        int currPixel, upPixel;        int R0, G0, B0, R1, G1, B1;        if ((fPixelFilteredFlags[0][pixelNum] & e42i) && (fPixelFilteredFlags[1][pixelNum] & e42i))        {            /*  - - - -               |       |               |       |                - - - -     We have two 4x2s.                - - - -               |       |               |       |                - - - -            */            ASSERT(fPixelFilteredFlags[0][pixelNum] == e42i && fPixelFilteredFlags[0][pixelNum+1] == e42 && fPixelFilteredFlags[0][pixelNum+2] == e42 && fPixelFilteredFlags[0][pixelNum+3] == e42);            ASSERT(fPixelFilteredFlags[1][pixelNum] == e42i && fPixelFilteredFlags[1][pixelNum+1] == e42 && fPixelFilteredFlags[1][pixelNum+2] == e42 && fPixelFilteredFlags[1][pixelNum+3] == e42);            upPixel = get4Pixel(row1Ptr);            currPixel = get4Pixel(row3Ptr);            R1 = GetRed(currPixel);            G1 = GetGreen(currPixel);            B1 = GetBlue(currPixel);            R0 = GetRed(upPixel);            G0 = GetGreen(upPixel);            B0 = GetBlue(upPixel);            if((maxErrorForSixteenPixels >= 3) &&(NewDeltaE(R1, R0, G1, G0, B1, B0, maxErrorForSixteenPixels)))            {                /*   - - - -                    |       |                    |       | build 4x4                    |       |                    |       |                     - - - -                */#if kGatherStats == 1                blockStats[es44ni]++;#endif                AverageNRound((pixelNum & 0x04) == 0x04, R1, R1, R0, G1, G1, G0, B1, B1, B0); // 4,5,6,7,12,13,14,15,20... Alternate between rounding up down                if(littleEndian)                    currPixel = (R1<<16) + (G1<<8) + B1;                else if(bigEndian)                    currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                put4Pixel(row1Ptr, 0, currPixel);                put4Pixel(row1Ptr, 1, currPixel);                put4Pixel(row1Ptr, 2, currPixel);                put4Pixel(row1Ptr, 3, currPixel);                put4Pixel(row2Ptr, 0, currPixel);                put4Pixel(row2Ptr, 1, currPixel);                put4Pixel(row2Ptr, 2, currPixel);                put4Pixel(row2Ptr, 3, currPixel);                put4Pixel(row3Ptr, 0, currPixel);                put4Pixel(row3Ptr, 1, currPixel);                put4Pixel(row3Ptr, 2, currPixel);                put4Pixel(row3Ptr, 3, currPixel);                put4Pixel(row4Ptr, 0, currPixel);                put4Pixel(row4Ptr, 1, currPixel);                put4Pixel(row4Ptr, 2, currPixel);                put4Pixel(row4Ptr, 3, currPixel);#else                put4Pixel(row1Ptr, 0, currPixel);#endif                row1Ptr += 4*eBufferedPixelWidthInBytes;                row2Ptr += 4*eBufferedPixelWidthInBytes;                row3Ptr += 4*eBufferedPixelWidthInBytes;                row4Ptr += 4*eBufferedPixelWidthInBytes;                fPixelFilteredFlags[0][pixelNum] = e44ni;                fPixelFilteredFlags[0][pixelNum+1] = fPixelFilteredFlags[0][pixelNum+2] = fPixelFilteredFlags[0][pixelNum+3] = e44n;                fPixelFilteredFlags[1][pixelNum] = e44si;                fPixelFilteredFlags[1][pixelNum+1] = fPixelFilteredFlags[1][pixelNum+2] = fPixelFilteredFlags[1][pixelNum+3] = e44s;                if ((pixelNum >= 4) && (fPixelFilteredFlags[1][pixelNum-4] & e44si)) // 4,5,6,7,12,13,14,15,20...                {                    /*   - - - -     - - - -                        |       |   |       |                        |       |   |       | We have two 4x4s.                        |       |   |       |                        |       |   |       |                         - - - -     - - - -                    */                    ASSERT(fPixelFilteredFlags[0][pixelNum-4] == e44ni && fPixelFilteredFlags[0][pixelNum-3] == e44n && fPixelFilteredFlags[0][pixelNum-2] == e44n && fPixelFilteredFlags[0][pixelNum-1] == e44n);                    ASSERT(fPixelFilteredFlags[1][pixelNum-4] == e44si && fPixelFilteredFlags[1][pixelNum-3] == e44s && fPixelFilteredFlags[1][pixelNum-2] == e44s && fPixelFilteredFlags[1][pixelNum-1] == e44s);                    upPixel = get4Pixel(row1Ptr, -8);                    R0 = GetRed(upPixel);                    G0 = GetGreen(upPixel);                    B0 = GetBlue(upPixel);                    if( (maxErrorForThirtyTwoPixels >= 3) && (NewDeltaE(R1, R0, G1, G0, B1, B0, maxErrorForThirtyTwoPixels)))                    {                        /*   - - - - - - - -                            |               |                            |               | build 8x4                            |               |                            |               |                             - - - - - - - -                        */#if kGatherStats == 1                        blockStats[es84ni]++;#endif                        AverageNRound((pixelNum & 0x08) == 0x08, R1, R1, R0, G1, G1, G0, B1, B1, B0);                        if(littleEndian)                            currPixel = (R1<<16) + (G1<<8) + B1;                        else if(bigEndian)                            currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                        put4Pixel(row1Ptr, -8, currPixel);                        put4Pixel(row1Ptr, -7, currPixel);                        put4Pixel(row1Ptr, -6, currPixel);                        put4Pixel(row1Ptr, -5, currPixel);                        put4Pixel(row1Ptr, -4, currPixel);                        put4Pixel(row1Ptr, -3, currPixel);                        put4Pixel(row1Ptr, -2, currPixel);                        put4Pixel(row1Ptr, -1, currPixel);                        put4Pixel(row2Ptr, -8, currPixel);                        put4Pixel(row2Ptr, -7, currPixel);                        put4Pixel(row2Ptr, -6, currPixel);                        put4Pixel(row2Ptr, -5, currPixel);                        put4Pixel(row2Ptr, -4, currPixel);                        put4Pixel(row2Ptr, -3, currPixel);                        put4Pixel(row2Ptr, -2, currPixel);                        put4Pixel(row2Ptr, -1, currPixel);                        put4Pixel(row3Ptr, -8, currPixel);                        put4Pixel(row3Ptr, -7, currPixel);                        put4Pixel(row3Ptr, -6, currPixel);                        put4Pixel(row3Ptr, -5, currPixel);                        put4Pixel(row3Ptr, -4, currPixel);                        put4Pixel(row3Ptr, -3, currPixel);                        put4Pixel(row3Ptr, -2, currPixel);                        put4Pixel(row3Ptr, -1, currPixel);                        put4Pixel(row4Ptr, -8, currPixel);                        put4Pixel(row4Ptr, -7, currPixel);                        put4Pixel(row4Ptr, -6, currPixel);                        put4Pixel(row4Ptr, -5, currPixel);                        put4Pixel(row4Ptr, -4, currPixel);                        put4Pixel(row4Ptr, -3, currPixel);                        put4Pixel(row4Ptr, -2, currPixel);                        put4Pixel(row4Ptr, -1, currPixel);#else                        put4Pixel(row1Ptr, -8, currPixel);#endif                        fPixelFilteredFlags[0][pixelNum-4] = e84ni;                        fPixelFilteredFlags[0][pixelNum-3] = fPixelFilteredFlags[0][pixelNum-2] = fPixelFilteredFlags[0][pixelNum-1] = fPixelFilteredFlags[0][pixelNum] = fPixelFilteredFlags[0][pixelNum+1] = fPixelFilteredFlags[0][pixelNum+2] = fPixelFilteredFlags[0][pixelNum+3] = e84n;                        fPixelFilteredFlags[1][pixelNum-4] = e84si;                        fPixelFilteredFlags[1][pixelNum-3] = fPixelFilteredFlags[1][pixelNum-2] = fPixelFilteredFlags[1][pixelNum-1] = fPixelFilteredFlags[1][pixelNum] = fPixelFilteredFlags[1][pixelNum+1] = fPixelFilteredFlags[1][pixelNum+2] = fPixelFilteredFlags[1][pixelNum+3] = e84s;                    }                }            }            else // could not build 4x4 so move forward past the stacked 4x2s.            {                row1Ptr += 4*eBufferedPixelWidthInBytes;                row2Ptr += 4*eBufferedPixelWidthInBytes;                row3Ptr += 4*eBufferedPixelWidthInBytes;                row4Ptr += 4*eBufferedPixelWidthInBytes;            }            pixelNum += 4;        }        else if ((fPixelFilteredFlags[0][pixelNum] & e22w) && (fPixelFilteredFlags[1][pixelNum] & e22w))        {            /*   - -                |   |                |   |                 - -   we have 2 2x2s.                 - -                |   |                |   |                 - -            */            ASSERT(fPixelFilteredFlags[0][pixelNum] == e22w && fPixelFilteredFlags[0][pixelNum+1] == e22e);            ASSERT(fPixelFilteredFlags[1][pixelNum] == e22w && fPixelFilteredFlags[1][pixelNum+1] == e22e);            upPixel = get4Pixel(row1Ptr);            currPixel = get4Pixel(row3Ptr);            R1 = GetRed(currPixel);            G1 = GetGreen(currPixel);            B1 = GetBlue(currPixel);            R0 = GetRed(upPixel);            G0 = GetGreen(upPixel);            B0 = GetBlue(upPixel);            if ((maxErrorForEightPixels >= 3) && (NewDeltaE(R1, R0, G1, G0, B1, B0, maxErrorForEightPixels)))            {                /*   - -                    |   |                    |   | build 2x4                    |   |                    |   |                     - -                */#if kGatherStats == 1                blockStats[es24nw]++;#endif                AverageNRound((pixelNum & 0x02) == 0x02, R1, R1, R0, G1, G1, G0, B1, B1, B0);                if(littleEndian)                    currPixel = (R1<<16) + (G1<<8) + B1;                else if(bigEndian)                    currPixel = (R1<<24) + (G1<<16) + (B1<<8);#if kMemWritesOptimize == 0                put4Pixel(row1Ptr, 0, currPixel);                put4Pixel(row1Ptr, 1, currPixel);                put4Pixel(row2Ptr, 0, currPixel);                put4Pixel(row2Ptr, 1, currPixel);                put4Pixel(row3Ptr, 0, currPixel);                put4Pixel(row3Ptr, 1, currPixel);                put4Pixel(row4Ptr, 0, currPixel);                put4Pixel(row4Ptr, 1, currPixel);#else                put4Pixel(row1Ptr, 0, currPixel);#endif                row1Ptr += 2*eBufferedPixelWidthInBytes;                row2Ptr += 2*eBufferedPixelWidthInBytes;                row3Ptr += 2*eBufferedPixelWidthInBytes;                row4Ptr += 2*eBufferedPixelWidthInBytes;                fPixelFilteredFlags[0][pixelNum] = e24nw;                fPixelFilteredFlags[0][pixelNum+1] = e24ne;                fPixelFilteredFlags[1][pixelNum] = e24sw;                fPixelFilteredFlags[1][pixelNum+1] = e24se;            }            else            {                row1Ptr += 2*eBufferedPixelWidthInBytes;                row2Ptr += 2*eBufferedPixelWidthInBytes;                row3Ptr += 2*eBufferedPixelWidthInBytes;                row4Ptr += 2*eBufferedPixelWidthInBytes;            }            pixelNum += 2;        }        else if ((fPixelFilteredFlags[0][pixelNum] & e12) && (fPixelFilteredFlags[1][pixelNum] & e12))        {            /*   -

⌨️ 快捷键说明

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