Exemple #1
0
/////////////////////////////////////////////////////////
// openFile
//
/////////////////////////////////////////////////////////
void pix_file_read :: openFile(t_symbol *filename)
{
  closeFile();

  // make the right filename
  char tmp_buff[MAXPDSTRING];
  char *path=tmp_buff;
  canvas_makefilename(getCanvas(), filename->s_name, tmp_buff, MAXPDSTRING);
  if (FILE*fd=fopen(tmp_buff, "r")) fclose(fd);
  else path=filename->s_name;

  // TODO: actually the fileReader should be returned based on the <file>
  // and not the other way round...

  fileReader = m_kernel.getFileReadServer().getPlugin();

  if(fileReader) {
    // get GEM framerate
    fileReader->setHostFramerate( GemMan::getFramerate() );

    // open file
    if(!(fileReader->openFile(path)))
      {
        error("could not open file %s", path);
        closeFile();
        return;
      }
    reallocate_m_image();
    infoSize();
  } else {
    error("couldn't find (suitable) VideoIO plugin for reading '%s'", path);
    return;
  }
}
Exemple #2
0
/////////////////////////////////////////////////////////
// render
//
// TODO: check what georg had in mind with the framesize things
// TODO: fix the re-allocate thing
/////////////////////////////////////////////////////////
void pix_file_read :: render(GemState *state)
{
  if(!fileReader) return;


  // set Frame Data
  unsigned char *image_ptr = m_image.image.data;

  fileReader->setFrameData(image_ptr, 
                           m_image.image.xsize, m_image.image.ysize, 
                           m_image.image.csize);

  // read frame data into m_image
  int status = fileReader->processFrameData();

  if( status == VideoIO_::VIDEO_STOPPED )
  {
    // output end of video bang in playing mode
    // and stop video
    if(!m_already_banged)
    {
      outlet_bang(m_outEnd);
      m_already_banged = true;
    }
    return;
  }

  if( status == VideoIO_::VIDEO_SIZE_CHANGED )
  {
    // check if image size changed
    if( m_image.image.xsize != fileReader->getWidth() ||
      m_image.image.ysize != fileReader->getHeight() ||
      m_image.image.csize != fileReader->getColorSize() ) 
      reallocate_m_image();

    infoSize();
    // process frame with new size again
    fileReader->processFrameData();
  }

  // set flag if we have a new film
  if(m_newfilm)
  {
    m_image.newfilm = true;
    m_newfilm = false;
  }
  m_image.newimage = true;

  // set image
  state->image = &m_image;
}
void TextView::skip(WordCursor &cursor, SizeUnit unit, int size) {
  WordCursor paragraphStart = cursor;
  paragraphStart.moveToParagraphStart();
  WordCursor paragraphEnd = cursor;
  paragraphEnd.moveToParagraphEnd();

  myStyle.reset();
  myStyle.applyControls(paragraphStart, cursor);

  while (!cursor.isEndOfParagraph() && (size > 0)) {
    const LineInfo info = processTextLine(cursor, paragraphEnd);
    cursor = info.End;
    size -= infoSize(info, unit);
  }
}
int TextView::paragraphSize(const WordCursor &cursor, bool beforeCurrentPosition, SizeUnit unit) {
  WordCursor word = cursor;
  word.moveToParagraphStart();
  WordCursor end = cursor;
  if (!beforeCurrentPosition) {
    end.moveToParagraphEnd();
  }
  
  myStyle.reset();

  int size = 0;

  while (!word.sameElementAs(end)) {
    const LineInfo info = processTextLine(word, end);
    word = info.End;
    size += infoSize(info, unit);
  }

  return size;
}