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

📄 dj9xxvip.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            {                CMDByte = eLiteral;                pixelSource = eeNewPixel;                replacementCount = 1;                curPixel++;            }        }        else // prior to last pixel of row        {            ASSERT(curPixel < lastPixel);            replacementCount = curPixel;            uint32_t RLERun = getPixel(curRowPtr, curPixel);            curPixel++; // Adjust for next pixel.            while (RLERun == getPixel(curRowPtr, curPixel)) // RLE            {                curPixel++;            }            curPixel--; // snap back to current.            replacementCount = curPixel - replacementCount;            ASSERT(replacementCount >= 0);            if (replacementCount > 0) // Adjust for total occurance and move to next pixel to do.            {                curPixel++;                replacementCount++;                if (cachedColor == RLERun)                {                    pixelSource = eeCachedColor;                }                else if (getPixel(seedRowPtr, curPixel-replacementCount+1) == RLERun)                {                    pixelSource = eeNEPixel;                }                else if ((curPixel-replacementCount > 0) &&  (getPixel(curRowPtr, curPixel-replacementCount-1) == RLERun))                {                    pixelSource = eeWPixel;                }                else                {                    pixelSource = eeNewPixel;                    cachedColor = RLERun;                }                CMDByte = eRLE; // Set default for later.            }            if (curPixel == lastPixel)            {                ASSERT(replacementCount > 0); // Already found some RLE pixels                if (realLastPixel == RLERun) // Add to current RLE. Otherwise it'll be part of the literal from the seedrow section above on the next iteration.                {                    putPixel(curRowPtr, lastPixel, realLastPixel);                    replacementCount++;                    curPixel++;                }            }            if (0 == replacementCount) // no RLE so it's a literal by default.            {                uint32_t tempPixel = getPixel(curRowPtr, curPixel);                ASSERT(tempPixel != getPixel(curRowPtr, curPixel+1)); // not RLE                ASSERT(tempPixel != getPixel(seedRowPtr, curPixel)); // not seedrow copy                CMDByte = eLiteral;                if (cachedColor == tempPixel)                {                    pixelSource = eeCachedColor;                }                else if (getPixel(seedRowPtr, curPixel+1) == tempPixel)                {                    pixelSource = eeNEPixel;                }                else if ((curPixel > 0) &&  (getPixel(curRowPtr, curPixel-1) == tempPixel))                {                    pixelSource = eeWPixel;                }                else                {                    pixelSource = eeNewPixel;                    cachedColor = tempPixel;                }                replacementCount = curPixel;                uint32_t cachePixel;                uint32_t nextPixel = getPixel(curRowPtr, curPixel+1);                do                {                    if (++curPixel == lastPixel)                    {                        putPixel(curRowPtr, lastPixel, realLastPixel);                        curPixel++;                        break;                    }                    cachePixel = nextPixel;                }                while ((cachePixel != (nextPixel = getPixel(curRowPtr, curPixel+1))) &&                        (cachePixel != getPixel(seedRowPtr, curPixel)));                replacementCount = curPixel - replacementCount;                ASSERT(replacementCount > 0);            }        }        ASSERT(seedRowPixelCopyCount >= 0);        // Write out compressed data next.        if (eLiteral == CMDByte)        {            ASSERT(replacementCount >= 1);            replacementCount -= 1; // normalize it            CMDByte |= pixelSource; // Could put this directly into CMDByte above.            CMDByte |= MIN(3, seedRowPixelCopyCount) << 3;            CMDByte |= MIN(7, replacementCount);            *compressedDataPtr++ = CMDByte;            if (seedRowPixelCopyCount >= 3)            {                outputVLIBytesConsecutively(seedRowPixelCopyCount - 3, compressedDataPtr);            }            replacementCount += 1; // denormalize it            int totalReplacementCount = replacementCount;            int upwardPixelCount = 1;            if (eeNewPixel != pixelSource)            {                replacementCount -= 1; // Do not encode 1st pixel of run since it comes from an alternate location.                upwardPixelCount = 2;            }            for ( ; upwardPixelCount <= totalReplacementCount; upwardPixelCount++)            {                ASSERT(totalReplacementCount >= upwardPixelCount);                unsigned short compressedPixel = ShortDelta(    getPixel(curRowPtr, curPixel-replacementCount),                                                                getPixel(seedRowPtr, curPixel-replacementCount));                if (compressedPixel)                {                    *compressedDataPtr++ = compressedPixel >> 8;                    *compressedDataPtr++ = (unsigned char)compressedPixel;                }                else                {                    uint32_t uncompressedPixel = getPixel(curRowPtr, curPixel-replacementCount);                    uncompressedPixel >>= 1; // Lose the lsb of blue and zero out the msb of the 3 bytes.                    *compressedDataPtr++ = (BYTE)(uncompressedPixel >> 16);                    *compressedDataPtr++ = (BYTE)(uncompressedPixel >> 8);                    *compressedDataPtr++ = (BYTE)(uncompressedPixel);                }                if (((upwardPixelCount-8) % 255) == 0)  // See if it's time to spill a single VLI byte.                {                    *compressedDataPtr++ = MIN(255, totalReplacementCount - upwardPixelCount);                }                replacementCount--;            }        }        else // RLE        {            ASSERT(eRLE == CMDByte);            ASSERT(replacementCount >= 2);            replacementCount -= 2; // normalize it            CMDByte |= pixelSource; // Could put this directly into CMDByte above.            CMDByte |= MIN(3, seedRowPixelCopyCount) << 3;            CMDByte |= MIN(7, replacementCount);            *compressedDataPtr++ = CMDByte;            if (seedRowPixelCopyCount >= 3)            {                outputVLIBytesConsecutively(seedRowPixelCopyCount - 3, compressedDataPtr);            }            replacementCount += 2; // denormalize it            if (eeNewPixel == pixelSource)            {                unsigned short compressedPixel = ShortDelta(getPixel(curRowPtr, curPixel - replacementCount),                                                            getPixel(seedRowPtr, curPixel - replacementCount));                if (compressedPixel)                {                    *compressedDataPtr++ = compressedPixel >> 8;                    *compressedDataPtr++ = (unsigned char)compressedPixel;                }                else                {                    uint32_t uncompressedPixel = getPixel(curRowPtr, curPixel - replacementCount);                    uncompressedPixel >>= 1;                    *compressedDataPtr++ = (BYTE)(uncompressedPixel >> 16);                    *compressedDataPtr++ = (BYTE)(uncompressedPixel >> 8);                    *compressedDataPtr++ = (BYTE)(uncompressedPixel);                }            }            if (replacementCount-2 >= 7) outputVLIBytesConsecutively(replacementCount - (7+2), compressedDataPtr);        }    } while (curPixel <= lastPixel);mode10rtn:    size = compressedDataPtr - compressedDataStart; // return # of compressed bytes.    compressedsize = size;    memcpy(SeedRow, input->rasterdata[myplane], originalsize);    seeded = TRUE;    iRastersReady = 1;    return TRUE;} //ProcessBYTE* Mode10::NextOutputRaster(COLORTYPE color)// since we return 1-for-1, just return result first call{	if (iRastersReady==0)		return (BYTE*)NULL;	if (color == COLORTYPE_BLACK)	{		return raster.rasterdata[color];	}	else	{		iRastersReady=0;		if (raster.rasterdata[color] != NULL)		{			return compressBuf;		}		else		{			return raster.rasterdata[color];		}	}}BYTE DJ9xxVIP::PhotoTrayStatus(    BOOL bQueryPrinter){    DRIVER_ERROR err;    char* pStr;    BYTE bDevIDBuff[DevIDBuffSize];    if (!IOMode.bDevID)    {        bQueryPrinter = FALSE;    }    err = pSS->GetDeviceID(bDevIDBuff, DevIDBuffSize, bQueryPrinter);    if (err!=NO_ERROR)    {        return 0;    }    if ( (pStr=(char *)strstr((const char*)bDevIDBuff+2,";S:")) == NULL )    {        return 0;    }    // skip over ";S:<version=2bytes><topcover><inklid><duplexer>"    pStr += 8;    BYTE b = *pStr;    return b;} //PhotoTrayStatusBOOL DJ9xxVIP::PhotoTrayPresent(    BOOL bQueryPrinter){    // for phototray present == 8    return ((PhotoTrayStatus(bQueryPrinter) & 8) == 8);} //PhotoTrayInstalledPHOTOTRAY_STATE DJ9xxVIP::PhotoTrayEngaged(    BOOL bQueryPrinter){/* *  When you add any new printer models to this class, make sure that the printer *  has the phototray sensor and reports the phototray state correctly. */    // for phototray present and engaged == 9    return ((PHOTOTRAY_STATE) ((PhotoTrayStatus(bQueryPrinter) & 9) == 9));} //PhotoTrayEngagedPAPER_SIZE DJ9xxVIP::MandatoryPaperSize(){    if (PhotoTrayEngaged (TRUE))        return PHOTO_SIZE;    else return UNSUPPORTED_SIZE;   // code for "nothing mandatory"} //MandatoryPaperSizeDRIVER_ERROR DJ9xxVIP::CheckInkLevel(){    DRIVER_ERROR err;    char* pStr;    BYTE bDevIDBuff[DevIDBuffSize];    if (!IOMode.bDevID)    {        return NO_ERROR;    }/* *  Check for unknown device id version. */    if ((pSS->GetVIPVersion ()) > 5)    {        return NO_ERROR;    }    err = pSS->GetDeviceID(bDevIDBuff, DevIDBuffSize, TRUE);    if (err!=NO_ERROR)    {        return err;    }    if ( (pStr=(char *)strstr((const char*)bDevIDBuff+2,";S:")) == NULL )    {        return SYSTEM_ERROR;    }    // skip to pen-count field next 3 should be 2C1    //   meaning 2 pens, first field is head/supply for K	/*	 *  VIPVersion = DevID Version + 1 - DevID Version no is 2 bytes following ;S:	 *  Version 00 and 01 report 12 bytes for status info	 *  Version 02 and onwards, report two additional bytes before pen info	 */    if (pSS->GetVIPVersion () <= 2)    {//      Aladdin style DeviceID        pStr += 19;        BYTE b1,b2,b3;        b1=*pStr++; b2=*pStr++; b3=*pStr++;        if ( (b1 != '2') || (b2 != 'C') || (b3 != '1'))        {            return SYSTEM_ERROR;        }        // black pen        pStr++;     // skip pen identifier        BYTE blackink = *pStr - 48;     // convert from ascii        // only look at low 3 bits        blackink = blackink & 7;        // skip into color field        pStr += 8;        BYTE colorink = *pStr - 48;        // only look at low 3 bits        colorink = colorink & 7;        if ((blackink<5) && (colorink<5))        {            return NO_ERROR;        }        if ((blackink>4) && (colorink>4))        {            return WARN_LOW_INK_BOTH_PENS;        }        if (blackink>4)        {            return WARN_LOW_INK_BLACK;        }        else        {            return WARN_LOW_INK_COLOR;        }    }    pStr += 21;    if (pSS->GetVIPVersion () > 4)    {        pStr += 4;    }    int     numPens = 0;    if (*pStr > '0' && *pStr < '9')    {        numPens = *pStr - '0';    }    else if (*pStr > 'A' && *pStr < 'F')    {        numPens = *pStr - 'A';    }    else if (*pStr > 'a' && *pStr < 'f')    {        numPens = *pStr - 'a';    }    pStr++;	BYTE    penInfoBits[4];    BYTE    blackink = 0;    BYTE    colorink = 0;    BYTE    photoink = 0;    BYTE    greyink = 0;    for (int i = 0; i < numPens; i++, pStr += 8)    {        AsciiHexToBinary (penInfoBits, pStr, 8);        if ((penInfoBits[0] & 0x80) != 0x80)        // if Bit 31 is 0, this is not a pen        {            continue;        }        int penColor = penInfoBits[0] & 0x3F;        switch (penColor)        {            case 1:                blackink =  penInfoBits[1] & 0x7;                break;            case 2:                colorink =  penInfoBits[1] & 0x7;                break;            case 3:                photoink =  penInfoBits[1] & 0x7;                break;            case 10:                greyink =  penInfoBits[1] & 0x7;                break;            case 4:            case 5:            case 6:            case 7:            case 8:            case 9:                colorink = penInfoBits[1] & 0x7;   // REVISIT: these are C, M, Y respectively                break;            default:                break;        }    }    if (blackink < 2 && colorink < 2 && photoink < 2 && greyink < 2)    {        return NO_ERROR;    }    else if (blackink > 1 && colorink > 1 && photoink > 1)    {        return WARN_LOW_INK_COLOR_BLACK_PHOTO;    }    else if (greyink > 1 && colorink > 1 && photoink > 1)    {        return WARN_LOW_INK_COLOR_GREY_PHOTO;    }    else if (blackink > 1 && colorink > 1)    {        return WARN_LOW_INK_BOTH_PENS;    }    else if (blackink > 1 && photoink > 1)    {        return WARN_LOW_INK_BLACK_PHOTO;    }    else if (greyink > 1 && colorink > 1)    {        return WARN_LOW_INK_COLOR_GREY;    }    else if (greyink > 1 && photoink > 1)    {        return WARN_LOW_INK_GREY_PHOTO;    }    else if (colorink > 1 && photoink > 1)    {        return WARN_LOW_INK_COLOR_PHOTO;    }    else if (blackink > 1)    {        return WARN_LOW_INK_BLACK;    }    else if (colorink > 1)    {        return WARN_LOW_INK_COLOR;    }    else if (photoink > 1)    {        return WARN_LOW_INK_PHOTO;    }    else if (greyink > 1)    {        return WARN_LOW_INK_GREY;	}    else if (colorink > 1)    {        return WARN_LOW_INK_COLOR;    }	else	{		return NO_ERROR;	}} //CheckInkLevelAPDK_END_NAMESPACE#endif  //APDK_DJ9xxVIP

⌨️ 快捷键说明

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