예제 #1
0
MemoryReader::MemoryReader( Memory &source )
:curPos( 0 )
{
  this->curData = source.GetData();
  this->curLength = source.GetLength();
  this->curPos = 0;
}//constructor
예제 #2
0
bool FileManagerWin32::GetFile( const std::string& fileName, Memory& fileContent, bool endZeroByte ) const {
  std::string name = fileName;
  FILE *file;
  fileContent.Free();
  fopen_s( &file, name.c_str(), "rb" );
  if( !file ) {
    LOGE( "File '%s' not found", name.c_str() );
    return false;
  }
  fseek( file, 0, SEEK_END );
  size_t fileSize = ftell( file );
  if( fileSize ) {
    fseek( file, 0, SEEK_SET );
    fileContent.Alloc( fileSize + ( endZeroByte ? 1 : 0 ) );
    fread( fileContent.GetData(), fileSize, 1, file );
    fileContent[ fileContent.GetLength() - 1 ] = 0;
  }
  fclose( file );

  return true;
}//GetFile
예제 #3
0
  }

  Module::EncodeETC1( imageDataRGBA, width, height, imageDataETC1, quality );
  return Py_BuildValue( "{s:y#,s:i,s:i,s:i}", "data", imageDataETC1.GetData(), imageDataETC1.GetLength(), "width", width, "height", height, "length", imageDataETC1.GetLength() );
}//picture2etc1


void Module::EncodeETC1( Memory &inBuffer, size_t width, size_t height, Memory &outBuffer, int quality ) {
  size_t
    resultBufferSize = ( width * height ) >> 1,
    blocksPerRow = width >> 2,
    blocksPerColumn = height >> 2;
  Memory memBlock( 4 * 4 * 4 );
  outBuffer.Alloc( resultBufferSize );
  uint8_t
    *srcData = memBlock.GetData(),
    *destData = outBuffer.GetData();
  rg_etc1::etc1_pack_params packParams;

  packParams.m_dithering = false;
  switch( quality ) {
  case 0: packParams.m_quality = rg_etc1::cLowQuality; break;
  case 1: packParams.m_quality = rg_etc1::cMediumQuality; break;
  case 2: packParams.m_quality = rg_etc1::cHighQuality; break;
  default: packParams.m_quality = rg_etc1::cLowQuality; break; LOGE( "Module::EncodeETC1 => quality[%d] is unavailable", quality ); break;
  }

  rg_etc1::pack_etc1_block_init();
  for( size_t blockRow = 0; blockRow < blocksPerColumn; ++blockRow ) {
    for( size_t blockColumn = 0; blockColumn < blocksPerRow; ++blockColumn ) {
      for( size_t row = 0; row < 4; ++row ) {