Lines Matching refs:this
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
19 additional uses of the libraries contained in this release of SANE.
22 to produce an executable, this does not by itself cause the
33 those changes may be distributed with this exception intact.
36 whether to permit this exception to apply to your modifications.
37 If you do not wish that, delete this exception notice.
85 The program is aborted, all handles and resources are freed (this
91 int SetError(TInstance *this, int nError, const char *szFormat, ...)
94 if (this->nErrorState) return 0; /* do not overwrite error state */
95 this->nErrorState=nError;
96 this->szErrorReason=malloc(500);
98 if (szFormat!=NULL && this->szErrorReason)
101 vsnprintf(this->szErrorReason,499,szFormat,ap);
103 this->szErrorReason[499]='\0';
144 TState FreeState(TInstance *this, TState nReturn)
146 if (this->state.ppchLines)
149 for (i=0; i<this->state.cBacklog; i++)
151 if (this->state.ppchLines[i])
152 free(this->state.ppchLines[i]);
154 free(this->state.ppchLines);
156 if (this->state.pchLineOut) free(this->state.pchLineOut);
157 if (this->state.pchBuf) free(this->state.pchBuf);
158 this->state.pchBuf =NULL;
159 this->state.pchLineOut=NULL;
160 this->state.ppchLines =NULL;
171 TState EndScan(TInstance *this)
173 if (!this->state.bScanning) return SANE_STATUS_GOOD;
175 this->state.bScanning=false;
176 FreeState(this,0);
178 return DoJog(this,-this->state.cyTotalPath);
183 TState CancelScan(TInstance *this)
188 TState CancelScan(TInstance *this)
193 this->state.cyTotalPath-=RegRead(this,R_POS,2);
194 DBG(DEBUG_JUNK,"stepping back %d steps\n",this->state.cyTotalPath);
195 /* this->state.cyTotalPath=0; */
198 DoReset(this);
199 EndScan(this); /* and step back! */
201 DBG(DEBUG_JUNK,"cs4: %d\n",(int)this->nErrorState);
202 bCanceled=this->state.bCanceled;
203 this->state.bCanceled=false; /* re-enable Origination! */
204 if (!this->bOptSkipOriginate)
205 DoOriginate(this,false); /* have an error here... */
206 this->state.bCanceled=bCanceled;
207 DBG(DEBUG_JUNK,"cs5: %d\n",(int)this->nErrorState);
221 TState ReadChunk(TInstance *this, unsigned char *achOut,
229 if (!this->state.bScanning)
231 if (this->state.bCanceled) /* deferred cancellation? */
232 return CancelScan(this);
241 if (this->state.iLine)
244 rc=(*(this->state.ReadProc))(this); /* preread one line */
247 while (this->state.iReadPos + cchMax > this->state.cchLineOut)
251 cch = this->state.cchLineOut - this->state.iReadPos;
253 this->state.pchLineOut+this->state.iReadPos,
258 this->state.iReadPos=0;
259 rc=(*(this->state.ReadProc))(this);
268 this->state.pchLineOut+this->state.iReadPos,
270 this->state.iReadPos += cchMax;
281 void GetAreaSize(TInstance *this)
283 /* this->state.cxPixel : pixels, we *want* (after interpolation)
284 this->state.cxMax : pixels, we *need* (before interpolation) */
286 nRefResX=nRefResY=this->param.res;
287 switch (this->param.res)
289 case 75: nRefResX=100; this->state.nFixAspect=75; break;
290 default: this->state.nFixAspect=100; break;
292 this->state.cxPixel =this->param.cx*this->param.res/1200;
293 this->state.cyPixel =this->param.cy*this->param.res/1200;
294 this->state.cxMax =this->state.cxPixel*100/this->state.nFixAspect;
295 this->state.cxWindow =this->state.cxMax*600/nRefResX;
296 this->state.cyWindow =this->state.cyPixel*600/nRefResY;
298 this->state.cxWindow,this->state.cxPixel,this->state.cxMax);
310 void ResetCalibration(TInstance *this)
312 if (this->calibration.achStripeY)
313 free(this->calibration.achStripeY);
314 if (this->calibration.achStripeR)
315 free(this->calibration.achStripeR);
316 if (this->calibration.achStripeG)
317 free(this->calibration.achStripeG);
318 if (this->calibration.achStripeB)
319 free(this->calibration.achStripeB);
321 memset(&(this->calibration),0,sizeof(this->calibration));
323 this->calibration.xMargin=200;
324 this->calibration.yMargin=0x019D;
325 this->calibration.nHoleGray=10;
326 this->calibration.rgbBias=0x888884;
327 this->calibration.nBarGray=0xC0;
339 TState InitGammaTables(TInstance *this, int nBrightness, int nContrast)
352 this->agammaY[i]=n;
353 this->agammaR[i]=n;
354 this->agammaG[i]=n;
355 this->agammaB[i]=n;
373 TState DoScanFile(TInstance *this)
382 rc=InitGammaTables(this, this->param.nBrightness, this->param.nContrast);
384 if (this->mode==color)
385 rc=StartScanColor(this);
387 rc=StartScanGray(this);
388 cx=this->state.cxPixel;
389 cy=this->state.cyPixel;
390 if (this->bVerbose)
392 if (this->fhScan && !this->bWriteRaw && !this->pchPageBuffer)
394 switch (this->mode)
396 case color: fprintf(this->fhScan,"P6\n%d %d\n255\n",cx,cy);
398 case gray: fprintf(this->fhScan,"P5\n%d %d\n255\n",cx,cy);
400 default: fprintf(this->fhScan,"P4\n%d %d\n",cx,cy);
409 rc=ReadChunk(this,achBuf,APP_CHUNK_SIZE,&cch);
410 if (cch>0 && this->fhScan && cch<=APP_CHUNK_SIZE)
412 if (this->pchPageBuffer)
415 if (this->bVerbose)
417 this->ichPageBuffer,cch,this->cchPageBuffer);
419 CHECK_ASSERTION(this->ichPageBuffer+cch<=this->cchPageBuffer);
420 memcpy(this->pchPageBuffer+this->ichPageBuffer,
422 this->ichPageBuffer+=cch;
424 else if (!this->bWriteRaw)
425 fwrite(achBuf,1,cch,this->fhScan);
430 if (this->bVerbose)
432 EndScan(this);