コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: uly55e5/PCover
void MainWindow::createActions()
{
    _openM3UAct = new QAction( tr( "M3U-&Playlist öffnen" ), this );
    _openM3UAct->setShortcut( tr( "Ctrl+O" ) );
    _openM3UAct->setStatusTip( tr( "Öffnet die Playlist zur Erstellung des Covers" ) );

    _saveCoverAct = new QAction( tr( "Cover speichern" ), this);
    _saveCoverAct->setShortcut( tr( "Ctrl+S" ) );
    _saveCoverAct->setStatusTip( tr( "Speichert das aktuelle Cover") );
    _saveCoverAct->setDisabled(TRUE);

    _savePlaylistAct = new QAction( tr( "Playlist als Text speichern" ), this);
    _savePlaylistAct->setShortcut( tr( "Ctrl+P" ) );
    _savePlaylistAct->setStatusTip( tr( "Speichert die aktuelle Playlist") );
    _savePlaylistAct->setDisabled(TRUE);

    _formatAlignmentAct = new QAction(tr( "Anordnung..." ),this);
    _formatAlignmentAct->setShortcut(tr ("Ctrl+A"));
    _formatAlignmentAct->setStatusTip(tr( "Anordnung der Einzelcover" ));
    _formatAlignmentAct->setDisabled(TRUE);

    _formatSizeColorAct = new QAction(tr("Größe und Farbe..."),this);
    _formatSizeColorAct->setStatusTip(tr("Einstellung von Größen und Farben"));
    _formatSizeColorAct->setDisabled(TRUE);

    _toolTextAct = new QAction(tr("Text..."),this);


    connect(_openM3UAct, SIGNAL(triggered()), this, SLOT(openM3UFile()));
    connect(_saveCoverAct, SIGNAL(triggered()), this, SLOT(saveCover()));
    connect(_savePlaylistAct, SIGNAL(triggered()), this, SLOT(savePlaylist()));
    connect(_formatAlignmentAct, SIGNAL(triggered()), this, SLOT(formatAlignment()));
    connect(_formatSizeColorAct, SIGNAL(triggered()), this, SLOT(setSizeColor()));
    connect(_toolTextAct, SIGNAL(triggered()), this, SLOT(setText()));
}
コード例 #2
0
int readImageColor(ImageColor *im, const char *fname) {  
  FILE *input;
  char line[1024];     
  int nCols,nRows;  
  int levels;
  int i, j;

  /* open it */
  if (!fname || (input=fopen(fname,"rb"))==0)
    return-1;

  /* check for the right "magic number" */
  if (
        fread(line,1,3,input)!=3
      ||strncmp(line,"P6\n",3)
     )
  {
    fclose(input);
    return -1;
  }
  
  /* skip the comments */
  do
    fgets(line,sizeof line,input);
  while(*line=='#');

  /* read the width and height */
  sscanf(line,"%d %d\n",&nCols,&nRows);
  setSizeColor(im, nRows, nCols);
 
  /* read # of gray levels */
  fgets(line,sizeof line,input);
  sscanf(line,"%d\n",&levels);
  setColorsColor(im, levels);
  
  /* read pixel row by row */
  for(i=0;i<nRows;i++)
  {
    for(j=0;j<nCols;j++)
    {
      int byteR, byteG, byteB;
      byteR=fgetc(input);
      if (byteR==EOF) /* short file */
      {
        fclose(input);
        return -1;
      }
      byteG=fgetc(input);
      if (byteG==EOF) /* short file */
      {
        fclose(input);
        return -1;
      }
      byteB=fgetc(input);
      if (byteB==EOF) /* short file */
      {
        fclose(input);
        return -1;
      }
      else
        setPixelColor(im,i,j, byteR, byteG, byteB);	
    }
  }

  /* close the file */
  fclose(input);
  return 0; /* OK */
}