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

📄 dj3320.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	{		if (m_iVertPosn < -600) m_iVertPosn = -600;	}    if (m_iBitDepth == 2)        m_iVertPosn += 6;}unsigned int LDLEncap::GetSwathWidth (int iStart, int iLast, int iWidth){    int k;    int i, j;    for (i = iWidth - 1 /*sizeof (long)*/; i > -1; i--)    {        for (j = iStart; j < iLast; j++)        {            for (k = m_iRasterCount / m_iNumColors-1; k >= 0; k--)            {                if (m_SwathData[j][k][i])                {                    return (i+1);                }            }        }    }    return 0;}void LDLEncap::Flush (){//  if (m_iRasterCount)//      Process (NULL, 0);}DRIVER_ERROR LDLEncap::SetVerticalSkip (int nBlankRasters){    DRIVER_ERROR    err = NO_ERROR;#if 0    if (m_iRasterCount == 0)    {        m_iBlankRasters += nBlankRasters;        return err;    }#endif    int     iCount = m_iNumColors * m_iBitDepth;    if (m_iBitDepth == 2)        iCount++;    while (nBlankRasters > 0)    {        for (int i = 0; i < iCount; i++)        {            err = Encapsulate (NULL, m_iImageWidth, 0);            ERRCHECK;        }        nBlankRasters--;    }    return err;}BOOL LDLEncap::IsBlankRaster (BYTE *raster, int width){    while (width > 0)    {        if (*raster)            return FALSE;        width--;    }    return FALSE;}DRIVER_ERROR LDLEncap::Encapsulate (const BYTE *input, DWORD size, BOOL bLastPlane){    DRIVER_ERROR    err = NO_ERROR;    int iPlaneNum = 0;    if (size > (DWORD) m_iImageWidth)        size = m_iImageWidth;    if (m_iBitDepth == 2)    {		if (m_iNumColors != 6)		{			if (m_cPlaneNumber == 0)			{				m_cPlaneNumber++;				return NO_ERROR;			}		}        int iCPlane;		if (m_iNumColors == 6)		{			iPlaneNum = m_cPlaneNumber % 2;		}		else		{			iPlaneNum = (m_cPlaneNumber + 1) % 2;		}        int iRowNum = (m_iRasterCount / 6) * 2 + iPlaneNum;        iRowNum = m_iNextRaster;		if (m_iNumColors == 6)		{			iCPlane = m_cPlaneNumber / 2;		}		else		{			iCPlane = (m_cPlaneNumber - 1) / 2;		}        if (iPlaneNum == 0)        {            if (!input)                memset (m_SwathData[iCPlane][iRowNum], 0, m_iImageWidth);            else                memcpy (m_SwathData[iCPlane][iRowNum], input, size);        }		if (m_iNumColors == 6)		{			m_cPlaneNumber = (m_cPlaneNumber + 1) % 12;		}		else		{			m_cPlaneNumber = (m_cPlaneNumber + 1) % 8;		}        if (iPlaneNum == 1)        {            // do the dotmapping here            BYTE    cbyte1, cbyte2;            BYTE    c1, c2;            int     j = 0;            BYTE    r1b1 = 0;            BYTE    r1b2 = 0;            BYTE    r2b1 = 0;            BYTE    r2b2 = 0;            BYTE    bitmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};            memcpy (m_szCompressBuf, m_SwathData[iCPlane][m_iNextRaster], size);            static  BYTE    rand_table[4][4] = {{0, 3, 1, 2},                                                {3, 1, 2, 0},                                                {1, 2, 0, 3},                                                {2, 0, 3, 1}};            BYTE    rt1, rt2;            rt1 = iRowNum % 4;            for (unsigned int i = 0; i < size; i++)            {                cbyte2 = m_szCompressBuf[i];                cbyte1 = (input == NULL) ? 0 : input[i];//              1200 dpi raster split into 2 600 dpi rasters                r1b1 = 0;                r1b2 = 0;                r2b1 = 0;                r2b2 = 0;                for (int ibit = 0; ibit < 8; ibit++)                {                    c1 = (cbyte1 & bitmask[ibit]) ? 1 : 0;                    c2 = (cbyte2 & bitmask[ibit]) ? 1 : 0;                    c1 = 2 * c1 + c2;                    rt2 = (i + ibit) % 4;                    rt2 = rand_table[rt1][rt2];                    if (c1 == 2)                    {                        if (rt2 == 0)                        {                            r1b1 = r1b1 | 0xff & (cbyte1 & bitmask[ibit]);                            r2b2 = r2b2 | (0xff & bitmask[ibit]);                        }                        else if (rt2 == 1)                        {                            r1b2 = r1b2 | (0xff & bitmask[ibit]);                            r2b1 = r2b1 | (0xff & bitmask[ibit]);                        }                        else if (rt2 == 2)                        {                            r1b1 = r1b1 | (0xff & bitmask[ibit]);                            r2b1 = r2b1 | (0xff & bitmask[ibit]);                        }                        else if (rt2 == 3)                        {                            r1b2 = r1b2 | (0xff & bitmask[ibit]);                            r2b2 = r2b2 | (0xff & bitmask[ibit]);                        }                    }                    else if (c1 == 1)                    {                        if (rt2 == 0)                            r1b1 = r1b1 | (0xff & bitmask[ibit]);                        else if (rt2 == 1)                            r1b2 = r1b2 | (0xff & bitmask[ibit]);                        else if (rt2 == 2)                            r2b1 = r2b1 | (0xff & bitmask[ibit]);                        else                            r2b2 = r2b2 | (0xff & bitmask[ibit]);                    }                    else if (c1 == 3)                    {                        r1b1 = r1b1 | (0xff & bitmask[ibit]);                        r1b2 = r1b2 | (0xff & bitmask[ibit]);                        r2b1 = r2b1 | (0xff & bitmask[ibit]);                        r2b2 = r2b2 | (0xff & bitmask[ibit]);                    }                }                m_SwathData[iCPlane][m_iNextRaster][j] = r1b1;                m_SwathData[iCPlane][m_iNextRaster][j+m_iImageWidth] = r1b2;                m_SwathData[iCPlane][m_iNextRaster+1][j]   = r2b1;                m_SwathData[iCPlane][m_iNextRaster+1][j+m_iImageWidth] = r2b2;                j++;            }			if (m_iNumColors == 6)			{				m_cPlaneNumber = m_cPlaneNumber % 12;			}			else			{				m_cPlaneNumber = m_cPlaneNumber % 7;			}        }    }    else    {        if (!input || size == 0)            memset (m_SwathData[m_iNextColor][m_iNextRaster], 0, m_iImageWidth);        else            memcpy (m_SwathData[m_iNextColor][m_iNextRaster], input, size);    }    m_iRasterCount++;    if (m_iBitDepth == 1 || (m_iBitDepth == 2 && iPlaneNum == 1))        m_iNextColor++;    if (m_iNextColor == m_iNumColors)    {        m_iNextColor = 0;        if (m_iBitDepth == 2)            m_iNextRaster += 2;        else            m_iNextRaster++;    }    if (m_iRasterCount < m_sSwathHeight * m_iNumColors)        return NO_ERROR;    if (m_bStartPageNotSent)    {        err = StartPage ();        if (err != NO_ERROR)            return err;    }    err = ProcessSwath (size);    if (m_iNextRaster >= m_sSwathHeight)    {        m_iNextRaster = 0;    }    return err;}DRIVER_ERROR LDLEncap::ProcessSwath (int iCurRasterSize){    DRIVER_ERROR    err = NO_ERROR;    unsigned int    start = 0;    int             size = 0;    Int32           iVertPosn;    Int16           sCurSwathHeight = m_iRasterCount / m_iNumColors;    Int32           LeftEdge  = 0;    int i;    m_iVertPosn += ((m_iBlankRasters) * 600 / m_iYResolution) * DEVUNITS_XBOW / 600;    m_iBlankRasters = 0;    iVertPosn = m_iVertPosn;    BOOL    bColorPresent = TRUE;    BOOL    bBlackPresent = TRUE;	BOOL    bPhotoPresent = TRUE;    short   sColorSize = 0;    int     StartColor = 0;    int     LastColor  = 1;    Int32   RightEdge;    int     delta = 2;    int     iColors = 0;    UInt32  uiSwathSize = 0;    if (m_iNumColors == 1)	{        bColorPresent = 0;		if (pPrinterXBow->ePen == BLACK_PEN)			bPhotoPresent = 0;		else			bBlackPresent = 0;	}    if (m_iNumColors == 3)	{        bBlackPresent = 0;		bPhotoPresent = 0;	}    if (m_iNumColors == 6)	{        bBlackPresent = 0;	}    if (m_iNumColors == 4)	{        bPhotoPresent = 0;	}    if (!m_bBidirectionalPrintingOn)        m_cPrintDirection = PRNDRN_LEFTTORIGHT;    Int16   j;    int     n;    int     count;    int     iStartRaster = m_cPassNumber % (2 * m_iBitDepth);    BYTE    mask = 0xFF;    if (m_cPrintQuality != QUALITY_DRAFT && m_iYResolution != 300)    {        if ((m_cPassNumber % (4 * m_iBitDepth)) < (2 * m_iBitDepth))            mask = 0xAA;        else            mask = 0x55;    }/* *  Photo Swath */    BYTE    csavMask = mask;	Int16       iOffset = 0;    if (m_sRefCount > 64000)        m_sRefCount = 6;    if (bPhotoPresent)    {		if (bColorPresent)		{			iColors = 6;			LastColor = 6;			StartColor = 0;			// 1200 dpi split into two			size = GetSwathWidth (StartColor, LastColor, iCurRasterSize/* * m_iBitDepth*/);		}		else		{			iColors = 1;			LastColor = 1;			StartColor = 0;			// 1200 dpi split into two			size = GetSwathWidth (StartColor, LastColor, iCurRasterSize/* * m_iBitDepth*/);		}    }    if (bPhotoPresent && size)    {        if (size % 2)            size = ((size / 2) + 1) * 2;        RightEdge = LeftEdge + (size * 8 * 600 / m_iXResolution - 1 * (600 / m_iYResolution)) * DEVUNITS_XBOW/600;        Int16   sLastNozzle;        Int16   sFirstNozzle = 1;//        int     iExtra = 0;        unsigned int    uSweepSize;        int     jDelta = m_iYResolution / 300;        jDelta *= m_iBitDepth;        uiSwathSize = size * iColors * sCurSwathHeight / jDelta;        uSweepSize = sCurSwathHeight * 2 / jDelta;        n = LDL_MAX_IMAGE_SIZE / (uSweepSize);        count = 0;        if (m_iBitDepth == 2)            iStartRaster = (4 - (iStartRaster+1)) % 4;        sLastNozzle = sFirstNozzle - 1 + sCurSwathHeight / jDelta;        BYTE *cb = m_szCompressBuf + 16;    // load sweep command        memset (m_szCompressBuf, 0x0, LDL_MAX_IMAGE_SIZE);		// 1200 dpi split into two        int    ib = 0;        if (m_iYResolution > 300 && m_cPrintQuality != QUALITY_DRAFT)        {            iOffset = (sCurSwathHeight / (4 * m_iBitDepth));            iOffset = iOffset + iOffset * ((m_cPassNumber) % (4 * m_iBitDepth));        }        BYTE    cVertAlign = 0;        if (bColorPresent)        {            cVertAlign = m_cPtoCVertAlign;        }        for (ib = 0; ib < (int) m_iBitDepth; ib++)        {            if (m_cPrintDirection == PRNDRN_RIGHTTOLEFT)            {                start = size - 2;                delta = -2;            }            else            {                start = 0;                delta = 2;            }            err = PrintSweep (uiSwathSize, bColorPresent, FALSE, bPhotoPresent,                              iVertPosn+cVertAlign, LeftEdge, 

⌨️ 快捷键说明

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