30 using namespace KKLSC;
149 delete compBuffer; compBuffer = NULL;
153 compBuffer =
new uchar[compBufferSize];
160 ScannerFile::ScanRate (_scanRate);
170 const uchar* txtBlockPtr = txtBlock;
171 while (charsLeft > 0)
178 fwrite (&rec,
sizeof (rec), 1, file);
179 fwrite (txtBlockPtr, charsLeft, 1, file);
180 txtBlockPtr += charsLeft;
186 kkuint32 bytesToWrite = Min ((kkuint32)65535, charsLeft);
191 fwrite (&rec,
sizeof (rec), 1, file);
192 fwrite (txtBlockPtr, bytesToWrite, 1, file);
193 txtBlockPtr += bytesToWrite;
194 charsLeft -= bytesToWrite;
208 for (
kkuint32 x = 0; x < frameBufferSpaceUsed; ++x)
217 if (compressedBuffLen <= 65535)
223 fwrite (&rec5,
sizeof (rec5), 1, file);
226 else if (compressedBuffLen <= 16777215)
228 kkuint32 buffLen = compressedBuffLen;
234 fwrite (&rec6,
sizeof (rec6), 1, file);
239 kkuint32 buffLen = compressedBuffLen;
246 fwrite (&rec7,
sizeof (rec7), 1, file);
249 fwrite (compressedData, compressedBuffLen, 1, file);
250 delete compressedData; compressedData = NULL;
268 memcpy (newBuffer, buffer, bufferSize);
273 bufferSize = bufferNewSize;
290 bufferSize = bufferNewSize;
298 bool bufferFrameRead =
false;
300 while ((feof (file) == 0) && (!bufferFrameRead))
303 fread (&opCode,
sizeof (opCode), 1, file);
305 if (feof (file) != 0)
313 fread (&textBlockLen, 1, 1, file);
314 if (feof (file) != 0)
316 SkipBytesForward (textBlockLen);
322 TwoByteRec textBlockLen;
323 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
324 if (feof (file) != 0)
326 kkuint32 len = textBlockLen.intHi * 256 + textBlockLen.intLo;
327 SkipBytesForward (len);
333 TwoByteRec textBlockLen;
334 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
335 if (feof (file) != 0)
337 kkuint32 compBufferLen = textBlockLen.intHi * 256 +
339 SkipBytesForward (compBufferLen);
340 bufferFrameRead =
true;
346 ThreeByteRec textBlockLen;
347 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
348 if (feof (file) != 0)
350 kkuint32 compBufferLen = textBlockLen.intByte0 * 256 * 256 +
351 textBlockLen.intByte1 * 256 +
352 textBlockLen.intByte2;
353 SkipBytesForward (compBufferLen);
354 bufferFrameRead =
true;
360 FourByteRec textBlockLen;
361 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
362 if (feof (file) != 0)
365 kkuint32 compBufferLen = textBlockLen.intByte0 * 256 * 256 * 256 +
366 textBlockLen.intByte1 * 256 * 256 +
367 textBlockLen.intByte2 * 256 +
368 textBlockLen.intByte3;
369 SkipBytesForward (compBufferLen);
370 bufferFrameRead =
true;
376 if (feof (file) != 0)
379 return osFTELL (file);
390 if (feof (file) != 0)
392 memset (frameBuffer, 0, frameBufferSize);
396 bool bufferFrameRead =
false;
400 while ((!feof (file)) && (!bufferFrameRead))
404 fread (&opCode,
sizeof (opCode), 1, file);
406 if (feof (file) != 0)
408 memset (frameBuffer, 0, frameBufferSize);
417 fread (&textBlockLen, 1, 1, file);
419 fread (&buff, textBlockLen, 1, file);
422 buff[textBlockLen] = 0;
423 ReportTextMsg (buff, textBlockLen);
430 TwoByteRec textBlockLen;
431 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
432 if (feof (file) == 0)
434 kkuint32 len = textBlockLen.intHi * 256 + textBlockLen.intLo;
435 fread (compBuffer, len, 1, file);
437 ReportTextMsg ((
char*)compBuffer, len);
444 TwoByteRec textBlockLen;
445 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
446 if (feof (file) == 0)
448 kkuint32 compBufferLen = textBlockLen.intHi * 256 +
450 if (compBufferLen > compBufferSize)
451 ExpandBufferNoCopy (compBuffer, compBufferSize, compBufferLen);
453 fread (compBuffer, compBufferLen, 1, file);
454 if (feof (file) == 0)
456 Compressor::Decompress (compBuffer, compBufferLen,
457 frameBuffer, frameBufferSize, frameBufferLen
461 bufferFrameRead =
true;
467 ThreeByteRec textBlockLen;
468 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
471 kkuint32 compBufferLen = textBlockLen.intByte0 * 256 * 256 +
472 textBlockLen.intByte1 * 256 +
473 textBlockLen.intByte2;
474 if (compBufferLen > compBufferSize)
475 ExpandBufferNoCopy (compBuffer, compBufferSize, compBufferLen);
477 fread (compBuffer, compBufferLen, 1, file);
478 if (feof (file) == 0)
480 Compressor::Decompress (compBuffer, compBufferLen,
481 frameBuffer, frameBufferSize, frameBufferLen
485 bufferFrameRead =
true;
491 FourByteRec textBlockLen;
492 fread (&textBlockLen,
sizeof (textBlockLen), 1, file);
495 kkuint32 compBufferLen = textBlockLen.intByte0 * 256 * 256 * 256 +
496 textBlockLen.intByte1 * 256 * 256 +
497 textBlockLen.intByte2 * 256 +
498 textBlockLen.intByte3;
499 if (compBufferLen > compBufferSize)
500 ExpandBufferNoCopy (compBuffer, compBufferSize, compBufferLen);
502 fread (compBuffer, compBufferLen, 1, file);
503 if (feof (file) == 0)
505 Compressor::Decompress (compBuffer, compBufferLen,
506 frameBuffer, frameBufferSize, frameBufferLen
510 bufferFrameRead =
true;
515 frameBufferNextLine = 0;
kkint64 frameBufferFileOffsetLast
Simple class that will compress and decompress specified buffers using the routines provided in zlib...
kkint64 frameBufferFileOffsetNext
ScannerFileZLib3BitEncoded(const KKStr &_fileName, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
kkint64 osFTELL(FILE *f)
Calls the appropriate 64 bit function for operating system.
unsigned __int32 kkuint32
static void * CreateCompressedBuffer(void *source, kkuint32 sourceLen, kkuint32 &compressedBuffLen)
ScannerFileZLib3BitEncoded(const KKStr &_fileName, RunLog &_log)
virtual void ScanRate(float _scanRate)
unsigned char uchar
Unsigned character.
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
Contains Classes that are specific to Cameras physical characteristics.
kkuint32 frameBufferNextLine
kkuint32 pixelsPerScanLine
Used for logging messages.
ScannerFile(const KKStr &_fileName, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
virtual void WriteTextBlock(const uchar *txtBlock, kkuint32 txtBlockLen)
ScannerFile(const KKStr &_fileName, RunLog &_log)
virtual ~ScannerFileZLib3BitEncoded()
Implements Zlib compression on 3bit pixel data.