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

📄 dj3320.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	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;	}} //CheckInkLevelDRIVER_ERROR DJ3320::SkipRasters (int nBlankRasters){    return (pLDLEncap->SetVerticalSkip (nBlankRasters));}DRIVER_ERROR DJ3320::CleanPen(){    return pLDLEncap->CleanPen ();}DRIVER_ERROR DJ3320::Flush (int FlushSize){    pLDLEncap->Flush ();    return NO_ERROR;}Header3320::Header3320 (Printer* p,PrintContext* pc)    : Header(p,pc){}DRIVER_ERROR Header3320::FormFeed (){    return (((DJ3320 *) thePrinter)->pLDLEncap->EndPage ());}DRIVER_ERROR Header3320::EndJob(){    ((DJ3320 *) thePrinter)->pLDLEncap->EndJob ();    return NO_ERROR;}DRIVER_ERROR Header3320::Send (){    DJ3320  *pXBow = (DJ3320 *) thePrinter;    return (pXBow->pLDLEncap->StartJob ());}DRIVER_ERROR Header3320::SendCAPy (unsigned int iAbsY){    return NO_ERROR;}LDLEncap::LDLEncap (DJ3320 *pPrinter, SystemServices *pSys, PrintContext *pc){    constructor_error = NO_ERROR;    piCreditCount = NULL;    m_pSys = pSys;    pPrinterXBow = pPrinter;    m_iXResolution = pc->EffectiveResolutionX ();    m_iYResolution = pc->EffectiveResolutionY ();    m_pthisPC = pc;    m_cPrintDirection = PRNDRN_LEFTTORIGHT;    m_SwathData = NULL;    m_sRefCount = 6;    m_iBlankRasters = 0;    m_iRasterCount = 0;    m_iVertPosn = (int) (m_pthisPC->PrintableStartY () * DEVUNITS_XBOW);    m_iNumColors = 4;    m_iLeftMargin = (int) (m_pthisPC->PrintableStartX () * DEVUNITS_XBOW);    ////////////////////////////////////////////////////////////////////////////////////    float   fXOverSpray = 0.0;    float   fYOverSpray = 0.0;    float   fLeftOverSpray = 0.0;    float   fTopOverSpray  = 0.0;	FullbleedType   fbType;    if (m_pthisPC->bDoFullBleed &&        pPrinterXBow->FullBleedCapable (m_pthisPC->thePaperSize,									  &fbType,                                      &fXOverSpray, &fYOverSpray,                                      &fLeftOverSpray, &fTopOverSpray))    {		/*		 *      To get the printer to do fullbleed printing, move the vertical postion 		 *      to cover the overspary. Overspray is needed to take care of		 *      skew during paper pick. These values may be mech dependent.		 *      Currently, supported only on PhotoSmart 100, Malibu. Spear supports		 *      fullbleed printing also. The current values for overspray are		 *      0.059 inch for top, bottom and left edges and 0.079 for right edge.		 */		m_iVertPosn = (int) (-fTopOverSpray * DEVUNITS_XBOW);		m_iLeftMargin = (int) (-fLeftOverSpray * DEVUNITS_XBOW);    }    m_bStartPageNotSent = TRUE;    m_iNextRaster = 0;    m_iNextColor  = 0;    m_iBitDepth = 1;    m_cPlaneNumber = 0;    m_cPrintQuality = (BYTE) QUALITY_NORMAL;    m_cMediaType    = (BYTE) MEDIA_PLAIN;    BYTE    cm = COLOR;    QUALITY_MODE cqm;    MEDIATYPE cmt;    COLORMODE ccm;    BOOL cdt;    DRIVER_ERROR err = m_pthisPC->GetPrintModeSettings (cqm, cmt, ccm, cdt);    if (err == NO_ERROR)    {        if (cqm == QUALITY_BEST && cmt == MEDIA_PHOTO)            m_iBitDepth = 2;        m_cPrintQuality = (BYTE) cqm;        m_cMediaType    = (BYTE) cmt;        cm = (BYTE) ccm;    }    if (pPrinterXBow->ePen == BLACK_PEN || pPrinterXBow->ePen == MDL_PEN || cm == GREY_K)        m_iNumColors = 1;    else if (pPrinterXBow->ePen == COLOR_PEN || cm == GREY_CMY)        m_iNumColors = 3;	else if (pPrinterXBow->ePen == BOTH_PENS && m_iBitDepth == 2)		m_iNumColors = 3;	else if (pPrinterXBow->ePen == MDL_BOTH)		m_iNumColors = 6;    m_bBidirectionalPrintingOn = TRUE; //FALSE;    UInt16 mem_needed =   SIZEOF_LDLHDR                        + SIZEOF_LDL_PRTSWP_CMDOPT                        + SIZEOF_LDL_PRTSWP_OPTFLDS                        + 6 * SIZEOF_LDL_PRTSWP_COLROPT                        + SIZEOF_LDL_COLROPT_ACTIVECOLR                        + SIZEOF_LDLTERM;    m_szCmdBuf = new BYTE[mem_needed];    CNEWCHECK (m_szCmdBuf);    m_bLittleEndian = TRUE;    {        union        {            short   a;            char    b[2];        }c;        c.a = 0x1234;        if (c.b[0] == 0x12)            m_bLittleEndian = FALSE;    }    m_szCmdBuf[0] = FRAME_SYN;    m_szCmdBuf[1] = 0;    m_szCmdBuf[3] = 0;    m_szCmdBuf[4] = 0;    m_szCmdBuf[5] = 0;    m_szCmdBuf[6] = 0;    m_szCmdBuf[8] = 0;    // Pacing and status handling data    bNewStatus = FALSE;    memset(byStatusBuff, 0, sizeof(byStatusBuff));    m_pbyPacketBuff = NULL;    m_pbyPacketBuff = pSys->AllocMem (MAX_PACKET_READ_SIZE);    CNEWCHECK (m_pbyPacketBuff);    m_dwPacketBuffSize = MAX_PACKET_READ_SIZE;    // Setup Sync command    pbySync = m_pSys->AllocMem(SYNCSIZE);    CNEWCHECK(pbySync);    memset(pbySync, 0, SYNCSIZE);    memcpy(pbySync, bySync, sizeof(bySync));    memset((pbySync + sizeof(bySync)), 0, SYNC_CMD_OPT_SIZE);    pbySync[sizeof(bySync) + SYNC_CMD_OPT_SIZE] = FRAME_SYN;    memset((pbySync + sizeof(bySync) + SYNC_CMD_OPT_SIZE + sizeof(FRAME_SYN)), 0, LDL_MAX_IMAGE_SIZE);/* *  Alignment Values. *  Currently, only Black to Color Vertical Alignment value is used. *  This value should really be obtained by running the pen alignment test. *  A value of 12 device units seems to be a good default. */	BYTE cVertAlign = 0;	if (pPrinterXBow->ePen == BOTH_PENS)	{		if (pSys->GetVerticalAlignmentValue(&cVertAlign))		{			m_cKtoCVertAlign = cVertAlign;		}		else		{			m_cKtoCVertAlign = 12;		}	}	else if (pPrinterXBow->ePen == MDL_BOTH)	{		if (pSys->GetVerticalAlignmentValue(&cVertAlign))		{			m_cPtoCVertAlign = cVertAlign;		}		else		{			m_cPtoCVertAlign = 6;		}	}	else	{		m_cKtoCVertAlign = 12;		m_cPtoCVertAlign = 6;	}}void LDLEncap::AllocateSwathBuffer (unsigned int RasterSize){    int size = RasterSize;    size = (size / 8 + 1) * 8;    m_iImageWidth = size;    constructor_error = NO_ERROR;#ifdef  APDK_LDL_COMPRESS    m_ldlCompressData = new comp_ptrs_t;#endif    if (m_iBitDepth == 2)    {        size *= 2;    }    int     m_szCompressBufSize = LDL_MAX_IMAGE_SIZE+20;    // additional space for load sweep command    m_szCompressBuf = new BYTE[m_szCompressBufSize];    CNEWCHECK (m_szCompressBuf);    memset (m_szCompressBuf, 0, m_szCompressBufSize);    BYTE    *p = NULL;    int     iSwathBuffSize;    m_sSwathHeight = SWATH_HEIGHT;	/*	 *  This swath buffer cannot be greater than the number of nozzles - 400 for black	 *  and 100 for color - we can use.	 */    if (pPrinterXBow->ePen == BLACK_PEN)    {        m_sSwathHeight = m_sSwathHeight * 4;        if (m_sSwathHeight * 1200 / m_iYResolution > 400)            m_sSwathHeight = m_iYResolution / 3;    }    else if (m_iYResolution > 300 && m_iNumColors > 1 && m_iBitDepth == 1)    {        m_sSwathHeight = (m_sSwathHeight / 4) * 4 * 2;        if (m_sSwathHeight > 200)            m_sSwathHeight = 200;    }    else if (m_iBitDepth == 2)        m_sSwathHeight = 96 * 4;    if (m_cPrintQuality == QUALITY_NORMAL)        m_sSwathHeight = 96 * 2;    while (m_sSwathHeight > 16)    {        iSwathBuffSize = m_iNumColors * sizeof (BYTE *) +                         m_iNumColors * m_sSwathHeight * sizeof (BYTE *) +                         size * m_iNumColors * m_sSwathHeight;		// Camera folks ask this be AllocMem instead of new		// if ((p = new BYTE[iSwathBuffSize]) == NULL)        if ((p = m_pSys->AllocMem(iSwathBuffSize)) == NULL)        {            m_sSwathHeight = (m_sSwathHeight / 16) * 8;            continue;        }        break;    }    if (m_sSwathHeight < 16)    {        m_sSwathHeight = 16;        iSwathBuffSize = m_iNumColors * sizeof (BYTE *) +                         m_iNumColors * m_sSwathHeight * sizeof (BYTE *) +                         size * m_iNumColors * m_sSwathHeight;	// Camera folks ask this be AllocMem instead of new	//        p = new BYTE[iSwathBuffSize];        p = m_pSys->AllocMem(iSwathBuffSize);        CNEWCHECK (p);    }    int     i;    m_SwathData = (BYTE ***) p;    for (i = 0; i < m_iNumColors; i++)        m_SwathData[i] = (BYTE **) (p + sizeof (BYTE *) * m_iNumColors + i * m_sSwathHeight * sizeof (BYTE *));    for (i = 0; i < m_iNumColors; i++)    {        p = (BYTE *) m_SwathData + sizeof (BYTE *) * m_iNumColors +                m_iNumColors * m_sSwathHeight * sizeof (BYTE *) +                size * m_sSwathHeight * i;        for (int j = 0; j < m_sSwathHeight; j++)        {            memset (p, 0, size);            m_SwathData[i][j] = p;            p = p + size;        }    }    if (m_cPrintQuality != QUALITY_DRAFT && m_iYResolution != 300)    {        m_iRasterCount = (m_sSwathHeight - m_sSwathHeight / (4*m_iBitDepth)) * m_iNumColors;        m_iVertPosn -= (((m_sSwathHeight - m_sSwathHeight / (4*m_iBitDepth)) * 600 / m_iYResolution) * DEVUNITS_XBOW / 600);    }    m_cPassNumber = 0;    float   fXOverSpray = 0.0;    float   fYOverSpray = 0.0;    float   fLeftOverSpray = 0.0;    float   fTopOverSpray  = 0.0;	FullbleedType   fbType;    if (m_pthisPC->bDoFullBleed &&        pPrinterXBow->FullBleedCapable (m_pthisPC->thePaperSize,									  &fbType,                                      &fXOverSpray, &fYOverSpray,                                      &fLeftOverSpray, &fTopOverSpray))	{		if (m_iVertPosn < -850) m_iVertPosn = -850;	}	else

⌨️ 快捷键说明

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