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

📄 ljcolor.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************\  ljcolor.cpp : Implimentation for the LJColor class  Copyright (c) 1996 - 2001, Hewlett-Packard Co.  All rights reserved.  Redistribution and use in source and binary forms, with or without  modification, are permitted provided that the following conditions  are met:  1. Redistributions of source code must retain the above copyright     notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright     notice, this list of conditions and the following disclaimer in the     documentation and/or other materials provided with the distribution.  3. Neither the name of Hewlett-Packard nor the names of its     contributors may be used to endorse or promote products derived     from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\*****************************************************************************/#ifdef APDK_LJCOLOR#include "header.h"#include "io_defs.h"#include "ljcolor.h"#include "printerproxy.h"#include "resources.h"APDK_BEGIN_NAMESPACEextern uint32_t ulMapVOLTAIRE_CCM_K[ 9 * 9 * 9 ];extern uint32_t ulMapGRAY_K_6x6x1[9 * 9 * 9];LJColor::LJColor (SystemServices* pSS, int numfonts, BOOL proto)    : Printer(pSS, numfonts, proto){    if ((!proto) && (IOMode.bDevID))    {        constructor_error = VerifyPenInfo();        CERRCHECK;    }    else ePen = BOTH_PENS;    // matches default mode    pMode[GRAYMODE_INDEX]      = new LJColorGrayMode ();    pMode[DEFAULTMODE_INDEX]   = new LJColor300DPIMode ();    pMode[SPECIALMODE_INDEX]   = new LJColor600DPIMode ();    pMode[SPECIALMODE_INDEX+1] = new LJColor150DPIMode ();    pMode[SPECIALMODE_INDEX+2] = new LJColorKDraftMode ();    ModeCount = 5;    CMYMap = NULL;    m_bJobStarted = FALSE;#ifdef  APDK_AUTODUPLEX    m_bRotateBackPage = FALSE;  // Lasers don't require back side image to be rotated#endif#ifdef APDK_EXTENDED_MEDIASIZE    pMode[SPECIALMODE_INDEX+3] = new LJColorPlainBestMode ();    ModeCount = 6;#endif    m_pCompressor = NULL;    m_iYPos = 0;    DBG1("LJColor created\n");}LJColor::~LJColor (){    DISPLAY_STATUS  eDispStatus;    if (IOMode.bStatus && m_bJobStarted)    {        for (int i = 0; i < 5; i++)        {            pSS->BusyWait (2000);            eDispStatus = ParseError (0);            if (eDispStatus == DISPLAY_PRINTING_COMPLETE)            {                pSS->DisplayPrinterStatus (eDispStatus);                break;            }        }    }}LJColorKDraftMode::LJColorKDraftMode (): GrayMode (ulMapVOLTAIRE_CCM_K){    theQuality = qualityDraft;    pmQuality  = QUALITY_DRAFT;    pmColor    = GREY_K;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif}LJColorGrayMode::LJColorGrayMode () : GrayMode (ulMapGRAY_K_6x6x1){	ResolutionX[0] = 	ResolutionY[0] = 	BaseResX =	BaseResY = 600;    pmColor = GREY_K;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif}LJColor150DPIMode::LJColor150DPIMode (): PrintMode (NULL){    ResolutionX[0] = ResolutionY[0] = 150;    BaseResX = BaseResY = 150;	TextRes = 150;	Config.bColorImage = FALSE;	theQuality = qualityDraft;	pmQuality  = QUALITY_DRAFT;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif}LJColor300DPIMode::LJColor300DPIMode (): PrintMode (NULL){    ResolutionX[0] = 300;    ResolutionY[0] = 300;    BaseResX = BaseResY = 300;    Config.bColorImage = FALSE;	theQuality = qualityNormal;    bFontCapable = TRUE;    pmQuality = QUALITY_NORMAL;	Config.bColorImage = FALSE;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif}LJColor600DPIMode::LJColor600DPIMode (): PrintMode (NULL){    ResolutionX[0] = 600;    ResolutionY[0] = 600;    BaseResX = BaseResY = 600;    Config.bColorImage = FALSE;	theQuality = qualityPresentation;    bFontCapable = TRUE;    pmQuality   = QUALITY_BEST;    pmMediaType = MEDIA_PHOTO;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif}#ifdef  APDK_EXTENDED_MEDIASIZELJColorPlainBestMode::LJColorPlainBestMode (): PrintMode (NULL){    ResolutionX[0] = 600;    ResolutionY[0] = 600;    BaseResX = BaseResY = 600;    Config.bColorImage = FALSE;	theQuality = qualityPresentation;    bFontCapable = TRUE;    pmQuality   = QUALITY_BEST;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif}#endifHeaderLJColor::HeaderLJColor (Printer* p, PrintContext* pc)    : Header(p,pc){ }DRIVER_ERROR HeaderLJColor::Send (){    DRIVER_ERROR err;    char    uom[12];    COLORMODE       eC = COLOR;    MEDIATYPE       eM;    QUALITY_MODE    eQ;    BOOL            bD;    ((LJColor *)thePrinter)->bGrey_K = FALSE;    if ((thePrintContext->GetPrintModeSettings (eQ, eM, eC, bD)) == NO_ERROR &&        eC == GREY_K)    {        ((LJColor *)thePrinter)->bGrey_K = TRUE;    }    StartSend ();    if (eC != GREY_K)    {/* *      Configure image data - ESC*v#W - # = 6 bytes *      02 - RGB colorspace (00 - Device RGB) *      03 - Direct pixel *      08 - bits per index - ignored for direct pixel *      08, 08, 08 - bits per primary each */        err = thePrinter->Send ((const BYTE *) "\033*v6W\00\03\010\010\010\010", 11);        ERRCHECK;//      Continues tone dither//      Logical operation - 0//      err = thePrinter->Send ((const BYTE *) "\033*t18J\033*l204O", 13);        err = thePrinter->Send ((const BYTE *) "\033*t18J", 6);        ERRCHECK;/* *      Driver Configuration Command - ESC*#W - # = 3 bytes *      device id - 6 = color HP LaserJet Printer *      func index - 4 = Select Colormap *      argument - 2   = Vivid Graphics */        err = thePrinter->Send ((const BYTE *) "\033*o3W\06\04\06", 8);        ERRCHECK;/* *      Program color palette entries */        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v255B\033*v255C\033*v0I", 26);        ERRCHECK;        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v0B\033*v0C\033*v6I", 22);        ERRCHECK;        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v255B\033*v0C\033*v5I", 22);        ERRCHECK;        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v0B\033*v255C\033*v3I", 22);        ERRCHECK;        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v255B\033*v0C\033*v4I", 24);        ERRCHECK;        err = thePrinter->Send ((const BYTE *) "\033*v255A\033*v0B\033*v255C\033*v2I", 24);        ERRCHECK;        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v255B\033*v255C\033*v1I", 24);        ERRCHECK;        err = thePrinter->Send ((const BYTE *) "\033*v0A\033*v0B\033*v0C\033*v7I", 20);        ERRCHECK;    }    sprintf (uom, "\033*r%dS", thePrintContext->OutputPixelsPerRow ());    err = thePrinter->Send ((const BYTE*)uom, strlen (uom));    ERRCHECK;    err = Graphics ();     // start raster graphics and set compression mode    return err;}DRIVER_ERROR HeaderLJColor::StartSend (){    DRIVER_ERROR err;    char    res[64];    int     iRes;    iRes = thePrintContext->EffectiveResolutionY ();    err = thePrinter->Send ((const BYTE*)UEL,sizeof(UEL));    ERRCHECK;    sprintf (res, "@PJL SET PAGEPROTECT=AUTO@PJL SET RESOLUTION=%d\015\012", iRes);    err = thePrinter->Send ((const BYTE *) res, strlen (res));    ERRCHECK;    if (thePrinter->IOMode.bStatus)    {        sprintf (res, "@PJL JOB NAME = \"%d\"\015\012", (int) (thePrinter));        err = thePrinter->Send ((const BYTE *) res, strlen (res));        ERRCHECK;    }    QUALITY_MODE    eQ = QUALITY_NORMAL;    COLORMODE       eC;    MEDIATYPE       eM;    BOOL            bD;    thePrintContext->GetPrintModeSettings (eQ, eM, eC, bD);    if (eQ == QUALITY_DRAFT)    {        strcpy (res, "@PJL SET RET=OFF\015\012@PJL SET ECONOMODE=ON\015\012");        err = thePrinter->Send ((const BYTE *) res, strlen (res));        ERRCHECK;    }    if (thePrinter->IOMode.bStatus)    {        strcpy (res, "@PJL USTATUSOFF\015\012@PJL USTATUS DEVICE = ON\015\012@PJL USTATUS JOB = ON\015\012");        err = thePrinter->Send ((const BYTE *) res, strlen (res));        ERRCHECK;    }//  Duplexing directive    strcpy (res, "@PJL SET DUPLEX=OFF\015\012");

⌨️ 快捷键说明

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