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

📄 dj9xxvip.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************\  dj9xxvip.cpp : Implimentation for the DJ9xxVIP class  Copyright (c) 1996 - 2002, 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_DJ9xxVIP#include "header.h"#include "io_defs.h"#include "dj9xxvip.h"#include "printerproxy.h"APDK_BEGIN_NAMESPACE#define OUR_PJL_JOBNAME "_PJL_pjl_PJL_pjl_" // this can be anything we want it to be#define DRIVERWARE_JOBNAME  "NEWDRIVERWARE" // don't change this - it is defined in firmware!extern uint32_t ulMapVOLTAIRE_CCM_K[ 9 * 9 * 9 ];const char GrayscaleSeq[]= {ESC, '*', 'o', '5', 'W', 0x0B, 0x01, 0x00, 0x00, 0x02};extern BYTE EscAmplCopy(BYTE *dest, int num, char end);extern void AsciiHexToBinary(BYTE* dest, char* src, int count);DJ9xxVIP::DJ9xxVIP(    SystemServices* pSS,    BOOL proto) :    Printer(pSS, NUM_DJ6XX_FONTS, proto),    PCL3acceptsDriverware(TRUE){    m_bVIPPrinter = TRUE;    if (!proto && IOMode.bDevID)    {        bCheckForCancelButton = TRUE;        constructor_error = VerifyPenInfo();        CERRCHECK;    }    else ePen = BOTH_PENS;    // matches default mode    PCL3acceptsDriverware = IsPCL3DriverwareAvailable();    ModeCount = 0;    pMode[ModeCount++] = new GrayModeAladdin(ulMapVOLTAIRE_CCM_K,PCL3acceptsDriverware);  // Grayscale K    pMode[ModeCount++] = new AladdinMode();           // Automatic Color    pMode[ModeCount++] = new AladdinCMYGrayMode();    // Automatic Grayscale CMY#ifdef APDK_AUTODUPLEX/* *  When bidi is available, query printer for duplexer *  For now, this is available only on Linux which is unidi only. */    bDuplexCapable = TRUE;#endif #ifdef APDK_EXTENDED_MEDIASIZE    pMode[ModeCount++] = new AladdinKGrayMode ();        // Normal Grayscale K    pMode[ModeCount++] = new Aladdin2400Mode ();         // HiRes    pMode[ModeCount++] = new AladdinDraftMode ();        // Draft Color#endif    pMode[ModeCount++] = new AladdinBestMode ();        // Photo Best}GrayModeAladdin::GrayModeAladdin(    uint32_t *map,    BOOL PCL3OK) :    GrayMode(map){#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = TRUE;#endif    Config.bColorImage=FALSE;    if (!PCL3OK)    {        bFontCapable = FALSE;    }#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif#ifdef APDK_EXTENDED_MEDIASIZE    theQuality = qualityDraft;    pmQuality = QUALITY_DRAFT;#endif}AladdinMode::AladdinMode(): PrintMode(NULL){/* *  The resolutions here are set to 300 for better performance from Cameras. *  REVISIT: Must provide a true 600 dpi printmode later. *  12/21/01 * *  For now have added APDK_HIGH_RES_MODES which sets VIP_BASE_RES to 600 in dj9xxvip.h *  If APDK_HIGH_RES_MODES is not defined then VIP_BASE_RES is 300. *  1/9/2002 - JLM */    BaseResX = BaseResY = TextRes = ResolutionX[0] = ResolutionY[0] = VIP_BASE_RES;    medium = mediaAuto;     // enable media-detect#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = TRUE;#endif    Config.bColorImage = FALSE;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif} //AladdinModeAladdinCMYGrayMode::AladdinCMYGrayMode(): PrintMode(NULL){/* *  See comments above regarding 300/600 dpi change */    BaseResX = BaseResY = TextRes = ResolutionX[0] = ResolutionY[0] = VIP_BASE_RES;    medium = mediaAuto;     // enable media-detect#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = TRUE;#endif    Config.bColorImage = FALSE;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif    pmColor = GREY_CMY;    bFontCapable = FALSE;} //AladdinCMYGrayMode#ifdef APDK_EXTENDED_MEDIASIZEAladdinKGrayMode::AladdinKGrayMode () : PrintMode (NULL){/* *  See comments above regarding 300/600 dpi change. */    BaseResX = BaseResY = ResolutionX[0] = ResolutionY[0] = VIP_BASE_RES;    medium = mediaPlain;#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = TRUE;#endif    Config.bColorImage = FALSE;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif    pmColor = GREY_K;    bFontCapable = FALSE;    dyeCount = 1;} //AladdinKGrayModeAladdin2400Mode::Aladdin2400Mode () : PrintMode (NULL){    BaseResX =    BaseResY = 1200;    ResolutionX[0] = 1200;    ResolutionY[0] = 1200;    bFontCapable = FALSE;#ifdef APDK_AUTODUPLEX    bDuplexCapable = FALSE;#endif#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = TRUE;#endif    Config.bColorImage = FALSE;    medium = mediaHighresPhoto;    theQuality = qualityPresentation;    pmMediaType = MEDIA_PHOTO;    pmQuality = QUALITY_HIGHRES_PHOTO;} // Aladdin2400ModeAladdinDraftMode::AladdinDraftMode () : PrintMode (NULL){    bFontCapable = FALSE;#ifdef APDK_AUTODUPLEX    bDuplexCapable = TRUE;#endif#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = TRUE;#endif   Config.bColorImage = FALSE;    medium = mediaAuto;    theQuality = qualityDraft;    pmQuality = QUALITY_DRAFT;} // AladdinDraftMode#endif  // APDK_EXTENDED_MEDIASIZE/* *  Some VIP printers do not have Media Sensing device. To enable *  selection of Photo/Best mode for these printers, use this mode. */AladdinBestMode::AladdinBestMode () : PrintMode (NULL){    BaseResX = BaseResY = ResolutionX[0] = ResolutionY[0] = VIP_BASE_RES;	bFontCapable = FALSE;#ifdef  APDK_AUTODUPLEX	bDuplexCapable = TRUE;#endif#if defined(APDK_VIP_COLORFILTERING)    Config.bErnie = TRUE;#endif   Config.bColorImage = FALSE;	medium      = mediaGlossy;	theQuality  = qualityPresentation;	pmQuality   = QUALITY_BEST;    pmMediaType = MEDIA_PHOTO;} // AladdinBestModeBOOL DJ9xxVIP::UseGUIMode(    PrintMode* pPrintMode){	// The reason to change all print mode in DJ9xxVIP family to PCL3GUI mode is that 	// the PCL3 path in VIP printers is not tested.  They don't support newer CRD 	// command.  The device fint support for this group is not recommended.	return TRUE;	/*	if (pPrintMode->medium == mediaHighresPhoto)	{		return TRUE;	}	else	{#ifdef APDK_AUTODUPLEX		if (pPrintMode->QueryDuplexMode() != DUPLEXMODE_NONE)		{			return TRUE;		}#endif	}#if defined(APDK_FONTS_NEEDED)//    return ((!pPrintMode->bFontCapable) && (!PCL3acceptsDriverware));    return (!pPrintMode->bFontCapable);#else    return TRUE;#endif	*/ } //UseGUIModeMode10::Mode10(    SystemServices* pSys,    Printer* pPrinter,    unsigned int PlaneSize) :    Compressor(pSys, PlaneSize, TRUE),    thePrinter(pPrinter)    // needed by Flush{    if (constructor_error != NO_ERROR)  // if error in base constructor    {        return;    }	// In the worst case, compression expands data by 50%	compressBuf = (BYTE*)pSS->AllocMem(PlaneSize + PlaneSize/2);	if (compressBuf == NULL)		constructor_error=ALLOCMEM_ERROR;    memset(SeedRow,0xFF,PlaneSize);} //Mode10Mode10::~Mode10(){ }const BYTE ResetSeedrow[]={ESC,'*','b','0','Y'};void Mode10::Flush()// special problem here regarding white rasters: we can't just reset our seedrow to white,// because if a true white raster comes next it will compress to zero, and firmware will// print ITS seedrow. So when we zero our seedrow, we need to zero the firmware seedrow.// The way to do this is to send ESC*b0Y. So that's what we will do here.{    if (!seeded)    {        return;    }	compressedsize=0;	    iRastersReady = 0;    seeded = FALSE;    memset(SeedRow,0xFF,inputsize);    thePrinter->Send(ResetSeedrow, sizeof(ResetSeedrow));} //FlushCompressor* DJ9xxVIP::CreateCompressor(unsigned int RasterSize){    return new Mode10(pSS,this,RasterSize);}Header* DJ9xxVIP::SelectHeader(PrintContext* pc){    return new HeaderAladdin(this,pc);}HeaderAladdin::HeaderAladdin(Printer* p,PrintContext* pc)    : Header(p,pc){    SetMediaSource(pc->GetMediaSource());}DRIVER_ERROR HeaderAladdin::ConfigureRasterData()// This is the more sophisticated way of setting color and resolution info.//// NOTE: Will need to be overridden for DJ5xx.{	char buff[50];      // 20 + 3 for crdstart + 3 for ##W	char *out = buff;    // begin the CRD command    memcpy(out,crdStart,sizeof(crdStart) );    out += sizeof(crdStart);    // now set up the "#W" part, where #= number of data bytes in the command    // #= 20    //      format,ID,components(2bytes),resolutions (4bytes),    //      compresssion method, orientation, bits/component,planes/component	*out++ = 0x32;    // "2"    *out++ = 0x30;    // "0"    *out++ = 'W';#define VIPcrdFormat 6#define VIPKRGBID 0x1F    *out++ = VIPcrdFormat;    *out++ = VIPKRGBID;    // 2-byte component count field    // number of components for sRGB is 1 by defintiion    *out++ = 0;     // leading byte    *out++ = 2;     // 2 "component"    *out++ = ResolutionX[0]/256;    *out++ = ResolutionX[0]%256;    *out++ = ResolutionY[0]/256;    *out++ = ResolutionY[0]%256;    // compression method    *out++ = 9;    // mode 9 compression    // orientation    *out++ = 0;     // pixel major code    // bits per component    *out++ = 1;    // 1 bits each for k    // planes per component    *out++ = 1;     // K = one component, one "plane"    *out++ = ResolutionX[0]/256;    *out++ = ResolutionX[0]%256;    *out++ = ResolutionY[0]/256;    *out++ = ResolutionY[0]%256;    // compression method    *out++ = 10;    // mode 10 compression    // orientation    *out++ = 1;     // pixel major code    // bits per component    *out++ = 32;    // 8 bits each for s,R,G,B    // planes per component    *out++ = 1;     // sRGB = one component, one "plane"    return thePrinter->Send((const BYTE*) buff, out-buff);} //ConfigureRasterDataDRIVER_ERROR HeaderAladdin::ConfigureImageData(){    DRIVER_ERROR err = thePrinter->Send((const BYTE*)cidStart, sizeof(cidStart));    ERRCHECK;    char sizer[3];    sprintf(sizer,"%dW",6);    err = thePrinter->Send((const BYTE*)sizer,2);    ERRCHECK;    BYTE colorspace = 2;    // RGB    BYTE coding = 3;    BYTE bitsindex = 3;     // ??    BYTE bitsprimary = 8;    BYTE CID[6];    CID[0] = colorspace;    CID[1]=coding;    CID[2] = bitsindex;    CID[3] = CID[4] = CID[5] = bitsprimary;    return thePrinter->Send((const BYTE*) CID, 6);} //ConfigureImageDataDRIVER_ERROR HeaderAladdin::Send()/// ASSUMES COMPRESSION ALWAYS ON -- required by aladdin{    DRIVER_ERROR err;//    PRINTMODE_VALUES    *pPMV;    StartSend();#ifdef APDK_AUTODUPLEX    if (thePrintContext->QueryDuplexMode () != DUPLEXMODE_NONE)    {        err = thePrinter->Send ((const BYTE *) EnableDuplex, sizeof (EnableDuplex));    }#endif    err = ConfigureImageData();    ERRCHECK;    err = ConfigureRasterData();    ERRCHECK;    COLORMODE       eColorMode = COLOR;    MEDIATYPE       eMediaType;    QUALITY_MODE    eQualityMode;    BOOL            bDeviceText;    if (thePrintMode->dyeCount == 1)    // grayscale    {        err=thePrinter->Send((const BYTE*)GrayscaleSeq, sizeof(GrayscaleSeq) );        ERRCHECK;    }    else    {        thePrintContext->GetPrintModeSettings (eQualityMode, eMediaType, eColorMode, bDeviceText);        if (eColorMode == GREY_CMY)        {            char    pStr[12];            memcpy (pStr, GrayscaleSeq, 10);            pStr[9] = 0x01;            err = thePrinter->Send ((const BYTE *) pStr, 10);        }    }    /////////////////////////////////////////////////////////////////////////////////////    // unit-of-measure command --- seems to be need in aladdin PCL3 mode    char uom[10];    sprintf(uom,"%c%c%c%d%c",ESC,'&','u',thePrintMode->ResolutionX[K],'D');    err = thePrinter->Send((const BYTE*)uom, strlen (uom));    ERRCHECK;    // another command that helps PCLviewer    unsigned int width=thePrintContext->OutputPixelsPerRow();    unsigned int digits = 1;    unsigned int x = width;    while (x > 10)    {        digits++;        x = x / 10;    }    sprintf(uom,"%c%c%c%d%c",ESC,'*','r', width,'S');    err = thePrinter->Send((const BYTE*)uom, 4 + digits );    ERRCHECK;    ////////////////////////////////////////////////////////////////////////////////////    float   fXOverSpray = 0.0;    float   fYOverSpray = 0.0;    float   fLeftOverSpray = 0.0;    float   fTopOverSpray  = 0.0;

⌨️ 快捷键说明

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