예제 #1
0
      STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
      {
         if (_inBuf == 0 || !_propsWereSet)
            return S_FALSE;

         if (!_state)
         {
            if (CreateDecompressor() != S_OK)
               return E_FAIL;
         }

         if (processedSize)
            *processedSize = 0;

         while (size != 0)
         {
            bool eofFlag = false;
            if (_inPos == _inSize)
            {
               _inPos = _inSize = 0;
               RINOK(_inStream->Read(_inBuf, _inBufSizeAllocated, &_inSize));
               if (!_inSize)
                  eofFlag = true;
            }

            lzham_uint8 *pIn_bytes = _inBuf + _inPos;
            size_t num_in_bytes = _inSize - _inPos;
            lzham_uint8* pOut_bytes = (lzham_uint8*)data;
            size_t out_num_bytes = size;

            lzham_decompress_status_t status = lzham_decompress(_state, pIn_bytes, &num_in_bytes, pOut_bytes, &out_num_bytes, eofFlag);

            if (num_in_bytes)
            {
               _inPos += (UInt32)num_in_bytes;
               _inSizeProcessed += num_in_bytes;
            }

            if (out_num_bytes)
            {
               _outSizeProcessed += out_num_bytes;
               size -= (UInt32)out_num_bytes;
               if (processedSize)
                  *processedSize += (UInt32)out_num_bytes;
            }

            if (status >= LZHAM_DECOMP_STATUS_FIRST_FAILURE_CODE)
               return S_FALSE;

            if (status == LZHAM_DECOMP_STATUS_SUCCESS)
               break;
         }

         return S_OK;
      }
예제 #2
0
      HRESULT CDecoder::SetOutStreamSizeResume(const UInt64 *outSize)
      {
         _outSizeDefined = (outSize != NULL);
         if (_outSizeDefined)
            _outSize = *outSize;
         _outSizeProcessed = 0;

         RINOK(CreateDecompressor());

         return S_OK;
      }
예제 #3
0
      HRESULT CDecoder::CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress)
      {
         if (_inBuf == 0 || !_propsWereSet)
            return S_FALSE;

         if (!_state)
         {
            if (CreateDecompressor() != S_OK)
               return E_FAIL;
         }

         UInt64 startInProgress = _inSizeProcessed;
         
         for (;;)
         {
            bool eofFlag = false;
            if (_inPos == _inSize)
            {
               _inPos = _inSize = 0;
               RINOK(inStream->Read(_inBuf, _inBufSizeAllocated, &_inSize));
               if (!_inSize)
                  eofFlag = true;
            }

            lzham_uint8 *pIn_bytes = _inBuf + _inPos;
            size_t num_in_bytes = _inSize - _inPos;
            lzham_uint8* pOut_bytes = _outBuf;
            size_t out_num_bytes = _outBufSize;
            if (_outSizeDefined)
            {
               UInt64 out_remaining = _outSize - _outSizeProcessed;
               if (out_num_bytes > out_remaining)
                  out_num_bytes = static_cast<size_t>(out_remaining);
            }
            
            lzham_decompress_status_t status = lzham_decompress(_state, pIn_bytes, &num_in_bytes, pOut_bytes, &out_num_bytes, eofFlag);
            
            if (num_in_bytes)
            {
               _inPos += (UInt32)num_in_bytes;
               _inSizeProcessed += (UInt32)num_in_bytes;
            }
                        
            if (out_num_bytes)
            {
               _outSizeProcessed += out_num_bytes;

               RINOK(WriteStream(outStream, _outBuf, out_num_bytes));
            }
            
            if (status >= LZHAM_DECOMP_STATUS_FIRST_FAILURE_CODE)
               return S_FALSE;

            if (status == LZHAM_DECOMP_STATUS_SUCCESS)
               break;
                        
            UInt64 inSize = _inSizeProcessed - startInProgress;
            if (progress)
            {
               RINOK(progress->SetRatioInfo(&inSize, &_outSizeProcessed));
            }
         }

         return S_OK;
      }
예제 #4
0
static Boolean DoDITLTextButton( short message, DITLItem *theItem, short keyPress )
{
Boolean	done;
TextButtGraphicsPriv * state;

	done = false;
	switch ( message )
	{
		case kInitDITLElement:
			theItem->refCon = 0;
			state = NewMemory ( false, sizeof(TextButtGraphicsPriv) );
			if ( state )
			{
				theItem->refCon = (long) state;
				state->textSprite = 0;
				state->buttReference = nil;
				state->animatorProc = nil;
				state->buttonID = 0;
				state->currentFrame = 0;
				state->toKeepDictCached = nil;
			}
			break;
			
		case kRenderDITLElement:
			RenderDITLTextButton( theItem );		
			break;
				
		case kSelectDITLElement:
			SelectDITLTextButton( theItem );
			break;
			
		case kDeselectDITLElement:
			DeselectDITLTextButton( theItem );
			break;
			
		case kClickDITLElement:
			done = ClickDITLTextButton( theItem, keyPress );
			break;
			
		case kCloseDITLElement:
			state = (TextButtGraphicsPriv *) theItem->refCon;
			if ( state )
			{
				if (state->animatorProc)
				{
					RemoveTimeRequest( state->animatorProc );
					state->animatorProc = nil;
				}

				if ( state->textSprite )
				{
					DisposeSprite ( state->textSprite );
				}
				
				if ( state->buttReference )
				{
					DisposeGraphicReference ( state->buttReference );	
				}
				
				if ( state->toKeepDictCached )
				{
					Decompressor dec = CreateDecompressor(
						GetDBButtonFrame( state->buttonID, kAnimationFrames ), 0, 0 );

					ReleaseDecompressorCache( dec, state->toKeepDictCached );
					DisposeDecompressor( dec );
				}
				
				DisposeMemory (state );
			}
			break;
			
		default:
			ERROR_MESG( "Got an illegal selector in DoDITLTextButton" );
			
	}
		
	return done;
}