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

📄 job.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// set OutputWidth -- this is local and may not agree with PrintContext// in cases where horizontal doubling is needed{    OutputWidth = thePrintContext->OutputWidth;    InputWidth = thePrintContext->InputWidth;    if (CurrentMode->BaseResX != CurrentMode->BaseResY) // if horizontal expansion needed    {        int mixedfactor = CurrentMode->BaseResX / CurrentMode->BaseResY;        int widthfactor = OutputWidth / InputWidth;        if (widthfactor >= mixedfactor)        {            OutputWidth = OutputWidth / mixedfactor;        }    }} //SetOutputWidthDRIVER_ERROR Job::InitScaler()// sets pResSynth & pReplicator{    unsigned int numerator, denominator;    // set OutputWidth -- this is local and may not agree with PrintContext    // in cases where horizontal doubling is needed (see next if clause)    SetOutputWidth();    if ((OutputWidth % InputWidth) == 0)    {        numerator = OutputWidth / InputWidth;        denominator = 1;    }    else    {        numerator = OutputWidth;        denominator = InputWidth;    }     float tempfactor = (float)numerator / (float)denominator;     tempfactor *= 1000.0f;     ScaleFactor = (unsigned int) (int) tempfactor;	// Two paths: if ResSynth included (proprietary path), then use it for the first doubling;	//            otherwise do it all in PixelReplication phase	//  but don't use ResSynth anyway if printer-res=600 and scale<4 (i.e. original-res<150),	//  or printer-res=300 and scale<2.33 (i.e. original-res<133)    BOOL RSok;    BOOL speedy=FALSE;#ifdef APDK_OPTIMIZE_FOR_SPEED    speedy = TRUE;#endif  // APDK_OPTIMIZE_FOR_SPEED    if (speedy)    {        RSok = FALSE;    }    else    {        if (thePrintContext->EffectiveResolutionX()>300)        {            // I don't know about 1200dpi, so I'm doing it this way            RSok = ScaleFactor >= 4000;        }        else        {            RSok = ScaleFactor >= 2333;        }    }    unsigned int ReplFormat;                    // how many bytes per pixel    if (CurrentMode->Config.bColorImage)    {        ReplFormat = CurrentMode->dyeCount;      // dealing with colormatching output    }    else    {        ReplFormat = 3;                        // RGB only    }    BOOL vip = !CurrentMode->Config.bColorImage;    if ((!ProprietaryScaling())  || !RSok )    // everything happens at Replication phase; input may be KCMY (or K, CMY, etc.) or RGB    {        pResSynth=NULL;        pReplicator = new Scaler_Open(pSS,InputWidth,numerator,denominator,vip,ReplFormat);        NEWCHECK(pReplicator);        return pReplicator->constructor_error;    }	// Proprietary path and scalefactor>=2, so break it up into 2 parts	// first give ResSynth a factor of 2, which is all it really does anyway.	// Scaler_Prop only operates on RGB, so it doesn't need the last two parameters    pResSynth = Create_Scaler(pSS,InputWidth,2,1,                              TRUE,     // as if VIP since it is working on RGB only at this phase                              3);       // 3 bytes per pixel    NEWCHECK(pResSynth);	pResSynth->myplane = COLORTYPE_COLOR;    if (pResSynth->constructor_error != NO_ERROR)    {        return pResSynth->constructor_error;    }	pBlackPlaneReplicator = new Scaler_Open(pSS,InputWidth,2,1,FALSE,1);    NEWCHECK(pBlackPlaneReplicator);	pBlackPlaneReplicator->myplane = COLORTYPE_BLACK;    if (pBlackPlaneReplicator->constructor_error != NO_ERROR)    {        return pBlackPlaneReplicator->constructor_error;    }	// now replicate the rest of the way -- only half as much left    pReplicator = new Scaler_Open(pSS,2*InputWidth,numerator,2*denominator,vip,ReplFormat);    NEWCHECK(pReplicator);    return pReplicator->constructor_error;} //InitScalerDRIVER_ERROR Job::Configure()// mode has been set -- now set up rasterwidths and pipeline{   DRIVER_ERROR err;   Pipeline* p=NULL;   unsigned int width;   BOOL useRS=FALSE;   err = InitScaler();      // create pReplicator and maybe pResSynth   ERRCHECK;   if ((CurrentMode->Config.bResSynth) && ProprietaryScaling()       && pResSynth)        // pResSynth==NULL if no scaling required   {       p = new Pipeline(pBlackPlaneReplicator);       NEWCHECK(p);       if (thePipeline)          thePipeline->AddPhase(p);       else thePipeline=p;       p = new Pipeline(pResSynth);       NEWCHECK(p);       if (thePipeline)          thePipeline->AddPhase(p);       else thePipeline=p;       useRS=TRUE;   }#if defined(APDK_DJ9xxVIP) && defined(APDK_VIP_COLORFILTERING)   if (CurrentMode->Config.bErnie)   {       // create Ernie (need pixelwidth for constructor)       if (p)       {           width = p->GetMaxOutputWidth(COLORTYPE_COLOR) / 3;     // GetOutputWidth returns # of bytes       }       else       {           width = thePrintContext->InputWidth;       }		// calculate Ernie threshold value		//Normal: threshold = (resolution) * (0.0876) - 2		// roughly: image at original 300 implies threshold=24; 600=>48, 150=>12, 75=>6		// to get resolution of "original" image, divide target resolution by scalefactor       float scale = (float)thePrintContext->OutputWidth / (float)thePrintContext->InputWidth;       float original_res = ((float)thePrintContext->EffectiveResolutionX()) / scale;       if (useRS && (scale >= 2.0f))       {           // image already doubled by ResSynth so consider the resolution as of now            original_res *= 2.0f;       }       float fthreshold = original_res * 0.0876f;       int threshold = (int)fthreshold - 2;       pErnie = new TErnieFilter(width, eBGRPixelData, threshold);       p = new Pipeline(pErnie);       NEWCHECK(p);       if (thePipeline)       {          thePipeline->AddPhase(p);       }       else       {           thePipeline = p;       }	}#endif //APDK_DJ9xxVIP && APDK_VIP_COLORFILTERING   if (CurrentMode->Config.bColorImage)   {       err = SetupColorMatching();      // create pColorMatcher       ERRCHECK;       p = new Pipeline(pColorMatcher);       NEWCHECK(p);       if (thePipeline)       {          thePipeline->AddPhase(p);      }       else       {           thePipeline = p;       }   }   if (CurrentMode->Config.bPixelReplicate)   {       // create Replicator       p = new Pipeline(pReplicator);       NEWCHECK(p);       if (thePipeline)       {          thePipeline->AddPhase(p);      }       else       {           thePipeline = p;       }   }   if (CurrentMode->Config.bColorImage)   {       err = SetupHalftoning(CurrentMode->Config.eHT);     // create pHalftoner       ERRCHECK;       p = new Pipeline(pHalftoner);       NEWCHECK(p);       if (thePipeline)       {          thePipeline->AddPhase(p);      }       else       {           thePipeline = p;       }   }   if (CurrentMode->Config.bCompress)   {       if (p)       {            width = p->GetMaxOutputWidth(COLORTYPE_COLOR);       }       else       {           width = thePrintContext->InputWidth;       }       unsigned int SeedBufferSize;       if (pHalftoner)      // if data is halftoned-output       {                        // format is 1 bit-per-pixel for each ink,drop,pass           SeedBufferSize = MAXCOLORPLANES * MAXCOLORDEPTH * MAXCOLORROWS * width;       }       else              // VIP data is just RGB24 here       {           SeedBufferSize = width;       }       theCompressor = thePrinter->CreateCompressor(SeedBufferSize);       NEWCHECK(theCompressor);       err = theCompressor->constructor_error;       ERRCHECK;	   theCompressor->myplane = COLORTYPE_COLOR;       p = new Pipeline(theCompressor);       NEWCHECK(p);       if (thePipeline)       {           thePipeline->AddPhase(p);       }       else       {           thePipeline = p;       }	   if (thePrinter->VIPPrinter())	   {			width = (width/3+7)/8;		    if (width > 0)			{			   // VIP black data is 1 bit here			   unsigned int SeedBufferSize;			   SeedBufferSize = width;			   pBlackPlaneCompressor = thePrinter->CreateBlackPlaneCompressor(SeedBufferSize);			   NEWCHECK(pBlackPlaneCompressor);			   err = pBlackPlaneCompressor->constructor_error;			   ERRCHECK;			   pBlackPlaneCompressor->myplane = COLORTYPE_BLACK;			   p = new Pipeline(pBlackPlaneCompressor);			   NEWCHECK(p);			   if (thePipeline)			   {				  thePipeline->AddPhase(p);			   }			   else			   {				   thePipeline = p;			   }		   }	   }   }   // always end pipeline with RasterSender   // create RasterSender object   pSender = new RasterSender(thePrinter,thePrintContext,this,pHalftoner);   NEWCHECK(pSender);   err = pSender->constructor_error;   ERRCHECK;   p = new Pipeline(pSender);   if (thePipeline)   {      thePipeline->AddPhase(p);  }   else   {       thePipeline = p;   }  return NO_ERROR;} //ConfigureDRIVER_ERROR Job::setblankraster(){    if (BlankRaster)    {        pSS->FreeMemory(BlankRaster);    }    size_t    BlankRasterSize = thePrintContext->OutputWidth * 3;          // Raghu    BlankRaster = (BYTE*)pSS->AllocMem (BlankRasterSize);    NEWCHECK(BlankRaster);    memset (BlankRaster, 0xFF, BlankRasterSize);    // Raghu    return NO_ERROR;} //setblankrasterDRIVER_ERROR Job::setblackraster(){	size_t    BlackRasterSize = thePrintContext->InputWidth;      if (!BlackRaster)    {		BlackRaster = (BYTE*)pSS->AllocMem (BlackRasterSize);		NEWCHECK(BlackRaster);	}    memset (BlackRaster, 0, BlackRasterSize);    return NO_ERROR;} //setblankraster//////////////////////////////////////////////////////////////////////#if defined(APDK_FONTS_NEEDED)/*!This method is used to send ASCII data to the printer, which it will renderas determined by the Font object.*/DRIVER_ERROR Job::TextOut(    const char* pTextString,    unsigned int iLenString,    const Font& font,    int iAbsX,    int iAbsY)// This is how ASCII data is sent to the driver.// Everything is really handled by the TextManager, including error checking.{#ifdef APDK_CAPTURE    Capture_TextOut(pTextString, iLenString, font, iAbsX, iAbsY);#endif    // Map coordinates (assumed to be in the graphical space) to the text-placement grid,    // which may be of lower resolution, indicated by TextRes    //    // using floats to cover the unusual case where graphical res is lower than text    float xfactor = ((float)CurrentMode->BaseResX) / ((float)CurrentMode->TextRes);    float yfactor = ((float)CurrentMode->BaseResY) / ((float)CurrentMode->TextRes);    float x = (float)iAbsX / xfactor;    float y = (float)iAbsY / yfactor;    iAbsX = (unsigned int)(int)x;   // double cast for webtv compiler    iAbsY = (unsigned int)(int)y;    DRIVER_ERROR err = theTextManager->TextOut(pTextString,iLenString,font,iAbsX,iAbsY);    ERRCHECK;    DataSent=TRUE;#ifdef APDK_USAGE_LOG    if (iLenString > UTextSize)    {        iLenString = UTextSize-1;        UHeader[iLenString] = '\0';    }    if (UTextCount<2)    {        strcpy(UHeader,pTextString);        UText += iLenString;    }    if (UTextCount==1)    {        UHeader[UText] = '\0';    }    UTextCount++;#endif    return err;} //TextOut#endif///////////////////////////////////////////////////////////// Pipeline managementPipeline::Pipeline(    Processor* E) :    next(NULL),    prev(NULL){    Exec = E;    Exec->myphase = this;} //Pipelinevoid Pipeline::AddPhase(Pipeline* newp){    Pipeline* p = this;    while (p->next)    {        p = p->next;    }    p->next = newp;    newp->prev = p;} //AddPhasePipeline::~Pipeline(){    if (next)    {        delete next;    }} //~PipelineBOOL Pipeline::Process(RASTERDATA* raster){    return Exec->Process(raster);} //ProcessDRIVER_ERROR Pipeline::Execute(RASTERDATA* InputRaster){    err=NO_ERROR;    if (Process(InputRaster)        // true if output ready; may set err        && (err==NO_ERROR))    {        if (next)        {			next->Exec->raster.rasterdata[COLORTYPE_BLACK] = NextOutputRaster(COLORTYPE_BLACK);			next->Exec->raster.rasterdata[COLORTYPE_COLOR] = NextOutputRaster(COLORTYPE_COLOR);            while (next->Exec->raster.rasterdata[COLORTYPE_COLOR] || 				   next->Exec->raster.rasterdata[COLORTYPE_BLACK])            {				next->Exec->raster.rastersize[COLORTYPE_COLOR] = GetOutputWidth(COLORTYPE_COLOR);				next->Exec->raster.rastersize[COLORTYPE_BLACK] = GetOutputWidth(COLORTYPE_BLACK);                err = next->Execute(&(next->Exec->raster));                ERRCHECK;				next->Exec->raster.rasterdata[COLORTYPE_BLACK] = NextOutputRaster(COLORTYPE_BLACK);				next->Exec->raster.rasterdata[COLORTYPE_COLOR] = NextOutputRaster(COLORTYPE_COLOR);            }        }    }    return err;} //ExecuteDRIVER_ERROR Pipeline::Flush(){    err=NO_ERROR;    Exec->Flush();    if (next && (err == NO_ERROR))    {		next->Exec->raster.rasterdata[COLORTYPE_BLACK] = NextOutputRaster(COLORTYPE_BLACK);		next->Exec->raster.rasterdata[COLORTYPE_COLOR] = NextOutputRaster(COLORTYPE_COLOR);        while (next->Exec->raster.rasterdata[COLORTYPE_COLOR] || next->Exec->raster.rasterdata[COLORTYPE_BLACK])        {			next->Exec->raster.rastersize[COLORTYPE_BLACK] = GetOutputWidth(COLORTYPE_BLACK);			next->Exec->raster.rastersize[COLORTYPE_COLOR] = GetOutputWidth(COLORTYPE_COLOR);            err = next->Execute(&(next->Exec->raster));			next->Exec->raster.rasterdata[COLORTYPE_BLACK] = NextOutputRaster(COLORTYPE_BLACK);			next->Exec->raster.rasterdata[COLORTYPE_COLOR] = NextOutputRaster(COLORTYPE_COLOR);            ERRCHECK;        }		// one more to continue flushing downstream		err = next->Flush();    }    return err;} //FlushProcessor::Processor() :    iRastersReady(0),    iRastersDelivered(0),    myphase(NULL),	myplane(COLORTYPE_BOTH){	for (int i = COLORTYPE_COLOR; i < MAX_COLORTYPE; i++)	{		raster.rasterdata[i] = NULL;		raster.rastersize[i] = 0;	}} //ProcessorProcessor::~Processor(){} //~ProcessorAPDK_END_NAMESPACE

⌨️ 快捷键说明

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