コード例 #1
0
ファイル: screenGrabber.cpp プロジェクト: rballester/Livre
void ScreenGrabber::saveScreenshot( const GLEWContext* context, const std::string& nameTemplate, const eq::fabric::PixelViewport& pvp, int numBytes )
{
    LBASSERT( numBytes == 3 || numBytes == 4 );
    LBASSERT( context );

    static uint32_t _lastScreenshotNumber = 0;
    // get next free name
    std::string fName;
    do
    {
        fName = nameTemplate;
        util::paddFilename( fName, _lastScreenshotNumber );
        fName.append( ".png" );

        ++_lastScreenshotNumber;
    }while( util::fileSize( fName ) != 0 && _lastScreenshotNumber < 10000 );

    FrameSharedPtr frame( new Frame( pvp.w, pvp.h, numBytes ));
    uint8_t* dst = &(frame->data[0]);

    eq::util::Texture texture( GL_TEXTURE_RECTANGLE_ARB, context );
    texture.copyFromFrameBuffer(( numBytes == 3 ? GL_RGB : GL_RGBA ), pvp );
    texture.download( dst );
    texture.flush();

    _writeImage( frame, fName );
}
コード例 #2
0
ファイル: screenGrabber.cpp プロジェクト: rballester/Livre
void ScreenGrabber::_writeImage( const FrameSharedPtr framePtr, const std::string& nameTemplate, uint32_t frameNum )
{
    std::string fName = nameTemplate;

    util::paddFilename( fName, frameNum );

    fName.append( ".png" );

    _writeImage( framePtr, fName );
}
コード例 #3
0
ファイル: Zinrimage.c プロジェクト: Peiffert/CGoGN
/* Write inrimage given in inr in fileName. If fileName's suffix is
   .gz, the image is gziped. If filename is NULL, image is written
   on stdout */
int writeZInrimage(const inrimage *inr, const char *fileName) {
  _image *img;
  int i;

  img = inrimage2_image(inr);
  i = _writeImage(img, fileName);
  img->data = NULL;
  _freeImage(img);

  if(i >= 0) return 0;
  else return i;
}
コード例 #4
0
ファイル: screenGrabber.cpp プロジェクト: rballester/Livre
void ScreenGrabber::saveFrames( const std::string& nameTemplate, int frameRate )
{
    LBWARN << "saving to: " << nameTemplate.c_str() << " framerate: " << frameRate << std::endl;

    if( frameRate <= 0 )
    {
        LBERROR << "frame rate has to be positive!" << std::endl;
        return;
    }

    if( _frameNumber == 0 )
    {
        LBWARN << "No frames were captured" << std::endl;
        return;
    }

    // during first  iteration check how many files would be written
    // during second iteration write files if no errors occure
    const uint32_t maxImageNum = 20*60*60; // 20 fps * 60 min
    for( int iter = 0; iter < 2; ++iter )
    {
        const float timeStep = 1000.f / static_cast<float>( frameRate ); // time step in ms
        float time = 0.f;

        uint32_t fPos     = 1;
        uint32_t imageNum = 0;
        while( fPos < _frameNumber && imageNum < maxImageNum )
        {
            int32_t nextTime = _frames[ fPos ]->time;
            while( nextTime > static_cast<int>( time ) && imageNum < maxImageNum )
            {
                // TODO: copy duplicated frames as file copies
                if( iter == 1 )
                    _writeImage( _frames[ fPos-1 ], nameTemplate, imageNum );
                time += timeStep;
                ++imageNum;
            }
            ++fPos;
        }
        if( imageNum >= maxImageNum )
        {
            LBWARN << "too many frames would be written, exiting without saving files" << std::endl;
            break;
        }
    }

    _frameNumber = 0;
}
コード例 #5
0
ファイル: GxEPD2_270.cpp プロジェクト: ZinggJM/GxEPD2
void GxEPD2_270::writeImageAgain(const uint8_t bitmap[], int16_t x, int16_t y, int16_t w, int16_t h, bool invert, bool mirror_y, bool pgm)
{
  _writeImage(0x14, bitmap, x, y, w, h, invert, mirror_y, pgm);
}
コード例 #6
0
ファイル: test-libio.c プロジェクト: VirtualPlants/timagetk
int main(int argc, char *argv[])
{
  _image *theIm;
  
  if ( argc == 1 ) {
    fprintf( stderr, "Usage: %s input output\n", argv[0] );
    exit( -1 );
  }
  
  theIm = _readImage( argv[1] );
  if ( theIm == NULL ) {
    fprintf( stderr, "%s: unable to read '%s'\n", argv[0], argv[1] );
    exit( -1 );
  }

  fprintf( stderr, "Information on '%s'\n", argv[1] );
  fprintf( stderr, "- image size is %lu x %lu x %lu\n",
	   theIm->xdim, theIm->ydim,  theIm->zdim );
  fprintf( stderr, "- voxel size is %f x %f x %f\n",
	   theIm->vx, theIm->vy,  theIm->vz );
  fprintf( stderr, "- image encoding is " );

  switch( theIm->wordKind ) {
  default :
    fprintf( stderr, "not handled\n" );
    break;
  case WK_FLOAT :
    switch( theIm->wdim ) {
    default :
      fprintf( stderr, "not handled\n" );
      break;
    case 4 :
      fprintf( stderr, "float\n" );
      break;
    case 8 :
      fprintf( stderr, "double\n" );
      break;
    }
    break;
  case WK_FIXED :
    switch( theIm->sign ) {
    default :
      fprintf( stderr, "not handled\n" );
      break;
    case SGN_SIGNED :
      switch( theIm->wdim ) {
      default :
	fprintf( stderr, "not handled\n" );
	break;
      case 1 :
	fprintf( stderr, "signed char\n" );
	break;
      case 2 :
	fprintf( stderr, "signed short int\n" );
	break;
      case 4 :
	fprintf( stderr, "signed int\n" );
	break;
      }
      break;
    case SGN_UNSIGNED :
      switch( theIm->wdim ) {
      default :
	fprintf( stderr, "not handled\n" );
	break;
      case 1 :
	fprintf( stderr, "unsigned char\n" );
	break;
      case 2 :
	fprintf( stderr, "unsigned short int\n" );
	break;
      case 4 :
	fprintf( stderr, "unsigned int\n" );
	break;
      }
      break;
    } /* switch( theIm->sign ) */
    break;
  }

  /* image data is in the buffer 'theIm->data' that is void*, meaning you can not use it directly.
     You have to use a pointer with the right type and cast the data pointer, e.g. for 'signed short int'
     encoding,
     short int *buf = (short int*)theIm->data;
     buf[z*theIm->xdim*theIm->ydim + y*theIm->xdim + x] is then the image value at (x,y,z)
  */

   if ( argc > 2 ) {
     if ( _writeImage( theIm, argv[2] ) != 0 ) {
       fprintf( stderr, "%s: unable to write '%s'\n", argv[0], argv[2] );
       exit( -1 );
     }
   }

   _freeImage( theIm ); 
   exit( 0 );
}
コード例 #7
0
ファイル: vt_inrimage.c プロジェクト: VirtualPlants/timagetk
int VT_WriteInrimageWithName( vt_image *image, char *name )
{
  char *proc = "VT_WriteImage";
  _image *inr = NULL;

  if ( _VT_DEBUG_ ) {
    fprintf( stderr, "%s: uses LIBINRIMAGE routines\n", proc );
  }

  if ( _flag_init_readers == 0 ) {
    _init_readers();
    _flag_init_readers = 1;
  }

  inr = _initImage();


  switch ( image->type ) {
  case SCHAR :
    inr->wordKind = WK_FIXED;
    inr->sign     = SGN_SIGNED;
    inr->wdim     = sizeof( char );
    break;
  case UCHAR :
    inr->wordKind = WK_FIXED;
    inr->sign     = SGN_UNSIGNED;
    inr->wdim     = sizeof( char );
    break;
  case SSHORT :
    inr->wordKind = WK_FIXED;
    inr->sign     = SGN_SIGNED;
    inr->wdim     = sizeof( short int );
    break;
  case USHORT :
    inr->wordKind = WK_FIXED;
    inr->sign     = SGN_UNSIGNED;
    inr->wdim     = sizeof( short int );
    break;
  case FLOAT :
    inr->wordKind = WK_FLOAT;
    inr->sign     = SGN_UNKNOWN;
    inr->wdim     = sizeof( float );
    break;
  case DOUBLE :
    inr->wordKind = WK_FLOAT;
    inr->sign     = SGN_UNKNOWN;
    inr->wdim     = sizeof( double );
    break;
  case SINT :
    inr->wordKind = WK_FIXED;
    inr->sign     = SGN_SIGNED;
    inr->wdim     = sizeof( int );
    break;
  case UINT :
    inr->wordKind = WK_FIXED;
    inr->sign     = SGN_UNSIGNED;
    inr->wdim     = sizeof( int );
    break;
  default :
    free(inr);
    return 0;
  }

  inr->xdim = image->dim.x;
  inr->ydim = image->dim.y;
  inr->zdim = image->dim.z;
  inr->vdim = image->dim.v;

  inr->vx = image->siz.x;
  inr->vy = image->siz.y;
  inr->vz = image->siz.z;

  inr->tx = image->off.x;
  inr->ty = image->off.y;
  inr->tz = image->off.z;

  inr->rx = image->rot.x;
  inr->ry = image->rot.y;
  inr->rz = image->rot.z;

  inr->cx = image->ctr.x;
  inr->cy = image->ctr.y;
  inr->cz = image->ctr.z;

  inr->nuser = image->nuser;
  inr->user  = image->user;

  inr->data = image->buf;

  if ( _writeImage( inr, name ) == -1 ) {
    if ( _VT_VERBOSE_ )
      fprintf( stderr, "%s: unable to write image '%s'", proc, image->name );
    free( inr );
    return 0;
  }

  free( inr );
  return 1;
}