示例#1
0
  std::ostream& LoggerImpl::getAppender()
  {
    if (pipe)
      return *pipe;
    else if (!fname.empty())
    {
      if (!outfile.is_open())
      {
        outfile.clear();
        outfile.open(fname.c_str(), std::ios::out | std::ios::app);
        counter.resetCount(outfile.tellp());
      }

      if (maxfilesize > 0)
      {
        if (counter.getCount() > maxfilesize)
        {
          doRotate();
          counter.resetCount();
        }
        return tee;
      }
      else
        return outfile;
    }
    else if (loghost.isConnected())
      return udpmessage;
    else
      return std::cerr;
  }
示例#2
0
文件: log.cpp 项目: skynowa/cxxtools
 void RollingFileAppender::putMessage(const std::string& msg)
 {
   if (_fsize >= _maxfilesize)
     doRotate();
   FileAppender::putMessage(msg);
   _fsize += msg.size() + 1;  // FileAppender adds line feed to the message
 }
void BasicScreenObject::_update(ofEventArgs &e){
	if(!isupdating) return;
	if(age == 1) firstUpdate();
	
    // TODO: use Animation elements equal to Positioners Animator.h
    
	// Update Animations based on Tweening
	if (isMoveTweening)		setPosition(tweenx, tweeny, tweenz);
	if (isScaleTweening)	setScale(tweenscalex, tweenscaley, tweenscalez);
	if (isColorTweening)	setColor(tweenr,tweeng,tweenb);
	if (isSizeTweening)		setSize(tweenWidth, tweenHeight);
	if (isRotationTweening) {
		ofQuaternion nowquat=getOrientationQuat();
		nowquat.slerp(tweenrotslerp, startquat, endquat);
		setOrientation(nowquat);
	}
	
	
	// Animations based on Forces and Attractionpoints
	doRotate();
	doMove();
	
	if(isorderbyz) doOrderChildrenByZ();
	
	update();
	
	if(positioners.size()>0){
		for(positioner = positioners.begin(); positioner != positioners.end(); positioner++) {
			IPositioner* p = positioner->second;
			p->restrict(this);
		}
	}
	
	age++;	
}
示例#4
0
Boonas::Boonas(int argc, char** argv)
{
	cursor = 0;
	orig = new LNHHolder();
	temp = 0;
	colorValue = 0;
	Transformation matrix;
	
	if(argc < 3)
	{
		return;
	}
	if(strcmp(argv[1], "polygon") == 0) // DONE
	{
		polygon(argc, argv); // default the color to a grey, or a blue
	}
	else if(strcmp(argv[1], "polygonC") == 0)
	{
		polygonC(argc, argv);
	}
	else if(strcmp(argv[1], "assemble") == 0) // DONE
	{
		assemble(argc, argv);
	}
	else if(strcmp(argv[1], "transform") == 0) //WORKS
	{
		loadFile(argv[2]); // loads the data into a LNHHolder 
		matrix = parseParams(3, argc, argv, matrix); 
		doMult(matrix); // applies the matrix transformation
		writeFile(argv[2]); // writes file;
	}
	else if(strcmp(argv[1], "create") == 0) // WORKS
	{
		loadFile(argv[3]);
		matrix = parseParams(4, argc, argv, matrix);
		doMult(matrix);
		writeFile(argv[2]);
	}
	else if(strcmp(argv[1], "extrude") == 0) // WORKS
	{
		loadFile(argv[2]);
		doExtrude(argv[4], argv[3]); // extrudes argv 3 distance
	}
	else if(strcmp(argv[1], "clip") == 0) // clip, file, inpolies, outpolies, normalx normaly normalz, pointx, pointy, pointz
	{
		loadFile(argv[2]);
		//doClip(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10]);
		doClip(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9]);
	}
	else if(strcmp(argv[1], "rot") == 0) // rot infile outfile vectorx, y, z pointx, y, z, divisions, degrees
	{
		loadFile(argv[2]);
		doRotate(argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11]);
		writeFile(argv[3]);
	}
	return;
}
示例#5
0
ScannerGeometry* SingleAxisTiltRotator::createRotatedScannerGeometry(float tiltAngleInDegree, float xAxisTiltAngleInDegree)
{
    ScannerGeometry* geometry = baseScannerGeometry->clone();

    float tiltAngleInRadians = -tiltAngleInDegree / 180.f * (float)M_PI;
    float xAxisTiltAngleInRadians = xAxisTiltAngleInDegree / 180.f * (float)M_PI;

    Vec3f detector = baseScannerGeometry->getDetectorBase();
    Vec3f source = baseScannerGeometry->getSourceBase();
    Vec3f horizontalPitch = baseScannerGeometry->getHorizontalPitch();
    Vec3f verticalPitch = baseScannerGeometry->getVerticalPitch();
    doRotate(detector, tiltAngleInRadians, xAxisTiltAngleInRadians);
    doRotate(source, tiltAngleInRadians, xAxisTiltAngleInRadians);
    doRotate(horizontalPitch, tiltAngleInRadians, xAxisTiltAngleInRadians);
    doRotate(verticalPitch, tiltAngleInRadians, xAxisTiltAngleInRadians);

    geometry->set(source, detector, horizontalPitch, verticalPitch);
    return geometry;
}
示例#6
0
void Square::onMouseEvent(po::scene::MouseEvent &event)
{
	switch (event.getType()) {
		case po::scene::MouseEvent::DOWN_INSIDE:
			mIsMouseDown = true;
			setSelected(true);
			break;
		case po::scene::MouseEvent::UP_INSIDE:
			if (mIsMouseDown) doRotate();
			break;
		case po::scene::MouseEvent::UP:
			setSelected(false);
			break;
		default:
			break;
	}
}
示例#7
0
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f) 
	: QMainWindow(parent, f)
{
    setupUi(this);
    //initialize Experiment Manager
    treeWidget->setColumnCount(3);
    QStringList header;//EP Header
    header << "Name" << "Iteration" << "Step";
    treeWidget->setHeaderLabels(header);//assign headers

    //connect the signal related to the top bars
    connect(actionOpen, SIGNAL(triggered()), this, SLOT(openSelect()));
    connect(actionOpen_2, SIGNAL(clicked()), this, SLOT(openSelect()));
    connect(actionSave, SIGNAL(triggered()), this, SLOT(saveFile()));
    connect(actionSave_1, SIGNAL(triggered()), this, SLOT(saveFile()));
    connect(actionSave_2, SIGNAL(clicked()), this, SLOT(saveFile()));
    connect(actionAnimator, SIGNAL(clicked()), this, SLOT(OpenAnimatorWindow()));
    connect(actionZoom_1, SIGNAL(clicked()), this, SLOT(doZoom()));
    connect(actionZoom, SIGNAL(triggered()), this, SLOT(doZoom()));
    connect(actionSlice, SIGNAL(triggered()), this, SLOT(doSlice()));
    connect(actionSlice_1, SIGNAL(clicked()), this, SLOT(doSlice()));
    connect(actionPan, SIGNAL(triggered()), this, SLOT(doPan()));
    connect(actionRotate, SIGNAL(triggered()), this, SLOT(doRotate()));

    //connect vel
    connect(treeWidget, SIGNAL(itemDoubleClicked ( QTreeWidgetItem*, int ) ), this, SLOT(openModel(QTreeWidgetItem*)));

    //vswork connect widgets to references
    vswork.setTree(treeWidget);

    //Initialize custom cursor pointers
    QBitmap zoomB("zoom.png");
    QBitmap rotateB("rotate.jpeg");
    QBitmap sliceB("slice.png");
    zoomCursor = QCursor(zoomB, -1, -1);
    rotateCursor = QCursor(rotateB, -1, -1);
    sliceCursor = QCursor(sliceB, -1, -1);
 }
示例#8
0
///
// Perform a single game tick.
//
// This is just a state machine which is repeatedly called from the main
// game loop. We do not want a 1 frame delay for some actions so we allow
// some to run 'instantly'.
///
void fsGameTick(FSEngine *f, const FSInput *i)
{
    i8 distance;
    bool moved = false, rotated = false;

    f->se = 0;
    f->totalTicksRaw++;

    // TODO: Remove lastInput since unused
    f->lastInput = *i;

    // Always handle restart/quit events at any time.
    if (i->extra & FST_INPUT_RESTART) {
        f->state = FSS_RESTART;
    }
    if (i->extra & FST_INPUT_QUIT) {
        f->state = FSS_QUIT;
    }

    // Always update the current piece finesse counters
    if (i->extra & FST_INPUT_FINESSE_ROTATE) {
        f->pieceRotateCount += 1;
    }
    if (i->extra & FST_INPUT_FINESSE_MOVE) {
        f->pieceMovePressCount += 1;
    }

    // Always count the number of new keys pressed
    f->totalKeysPressed += i->newKeysCount;

beginTick:
    switch (f->state) {
      case FSS_READY:
      case FSS_GO:

        // Ready, Go has has slightly different hold mechanics. Since we do not
        // yet have a piece we need to copy directly from the next queue to the
        // hold piece. Further, we can optionally hold as many times as we want
        // so need to discard the hold piece if required.
        if ((i->extra & FST_INPUT_HOLD) && f->holdAvailable) {
            f->holdPiece = nextPreviewPiece(f);
            f->se |= FST_SE_FLAG_HOLD;

            if (!f->infiniteReadyGoHold) {
                f->holdAvailable = false;
            }
        }

        if (f->genericCounter == 0) {
            f->se |= FST_SE_FLAG_READY;
        }

        if (f->genericCounter == TICKS(f->readyPhaseLength)) {
            f->se |= FST_SE_FLAG_GO;
            f->state = FSS_GO;
        }

        // This cannot be an `else if` since goPhaseLength could be 0.
        if (f->genericCounter == TICKS(f->readyPhaseLength) +
                                 TICKS(f->goPhaseLength)) {
            f->state = FSS_NEW_PIECE;
        }

        f->genericCounter++;

        // We need an explicit return here to avoid incrementing `totalTicks
        return;

      case FSS_ARE:
        // Even if ARE is instant, we still want to check for IHS and IRS state.
        // This allows the following behaviour:
        //
        // Currently we should be able to have three different actions for an initial
        // action:
        //
        //  NONE - IRS/IHS disabled and not checked
        //  HELD - Allows input action to remain set from last piece
        //  HIT  - Requires a new input action to trigger (not implemented)
        //
        // If ARE can be cancelled then the action will occur on the next
        // frame with the piece already playable.
        // This may need some more tweaking since during fast play initial stack
        // far too easily.
        if (f->initialActionStyle == FST_IA_PERSISTENT) {
            // Only check the current key state.
            // This is only dependent on the value on the final frame before the
            // piece spawns. Could adjust to allow any mid-ARE initial action to
            // stick till spawn.

            // We need an implicit ordering here so are slightly biased. May want to
            // give an option to adjust this ordering or have a stricter
            // order.
            if (i->currentKeys & FST_VK_FLAG_ROTR) {
                f->irsAmount = FST_ROT_CLOCKWISE;
            }
            else if (i->currentKeys & FST_VK_FLAG_ROTL) {
                f->irsAmount = FST_ROT_ANTICLOCKWISE;
            }
            else if (i->currentKeys & FST_VK_FLAG_ROTH) {
                f->irsAmount = FST_ROT_HALFTURN;
            }
            else {
                f->irsAmount = FST_ROT_NONE;
            }

            if (i->currentKeys & FST_VK_FLAG_HOLD) {
                f->ihsFlag = true;
            }
            else {
                f->ihsFlag = false;
            }
        }

        if (f->areCancellable && (
                i->rotation != 0 ||
                i->movement != 0 ||
                i->gravity  != 0 ||
                i->extra    != 0 ||
                // We need to check ihs/irs since this is solely based on new
                // key state and otherwise may not be picked up.
                f->ihsFlag || f->irsAmount
                )
        ) {
            f->areTimer = 0;
            f->state = FSS_NEW_PIECE;
            goto beginTick;
        }

        if (f->areTimer++ > TICKS(f->areDelay)) {
            f->areTimer = 0;
            f->state = FSS_NEW_PIECE;
            goto beginTick;
        }
        break;

      case FSS_NEW_PIECE:
        newPiece(f);

        // Apply ihs/irs before checking lockout.
        if (f->irsAmount != FST_ROT_NONE) {
            doRotate(f, f->irsAmount);
        }
        if (f->ihsFlag) {
            tryHold(f);
        }

        f->irsAmount = FST_ROT_NONE;
        f->ihsFlag = false;

        // Check lockout (irs/ihs has been applied already)
        if (isCollision(f, f->x, f->y, f->theta)) {
            f->state = FSS_GAMEOVER;
            goto beginTick;
        }

        updateHardDropY(f);
        f->state = FSS_FALLING;
        break;

      case FSS_FALLING:
      case FSS_LANDED:
        // If a hard drop occurs we want to immediately drop the piece and not
        // apply any other movement. This is far more natural and results in
        // less misdrops than if movement is processed prior.
        //
        // See issue #49 for details.
        if ((i->extra & FST_INPUT_HARD_DROP) ||
                // We must recheck the lock timer state here since we may have
                // moved back to FALLING from LANDED on the last frame and do
                // **not** want to lock in mid-air!
                (f->lockTimer >= TICKS(f->lockDelay) && f->state == FSS_LANDED)) {
            f->state = FSS_LINES;

            // Still need to apply piece gravity before entering FSS_LINES.
            doPieceGravity(f, i->gravity);
            break;
        }

        if (i->extra & FST_INPUT_HOLD) {
            tryHold(f);
        }

        if (i->rotation) {
            if (doRotate(f, i->rotation)) {
                rotated = true;
            }
        }

        // Left movement
        distance = i->movement;
        for (; distance < 0; ++distance) {
            if (!isCollision(f, f->x - 1, f->y, f->theta)) {
                f->x -= 1;
                moved = true;
            }
        }

        // Right movement
        for (; distance > 0; --distance) {
            if (!isCollision(f, f->x + 1, f->y, f->theta)) {
                f->x += 1;
                moved = true;
            }
        }

        if (moved || rotated) {
            if (moved) {
                f->se |= FST_SE_FLAG_MOVE;
            }
            if (rotated) {
                f->se |= FST_SE_FLAG_ROTATE;
            }

            updateHardDropY(f);
        }

        doPieceGravity(f, i->gravity);

        // This must occur after we process the lockTimer to allow floorkick
        // limits to be processed correctly. If we encounter a floorkick limit
        // we set the lockTimer to max to allow a lock next frame, while still
        // giving the user an option to perform a move/rotate input.
        if ((moved || rotated) && f->lockStyle == FST_LOCK_MOVE) {
            f->lockTimer = 0;
        }

        if (f->state == FSS_LANDED) {
            f->lockTimer++;
        }

        break;

      case FSS_LINES:
        lockPiece(f);

        // NOTE: Make this conversion less *magic*
        f->se |= (1 << (FST_SE_IPIECE + f->piece));
        f->piece = FS_NONE;

        const int lines = clearLines(f);
        if (0 < lines && lines <= 4) {
            // NOTE: Make this conversion less *magic*
            f->se |= (FST_SE_FLAG_ERASE1 << (lines - 1));
        }

        f->linesCleared += lines;
        f->state = f->linesCleared < f->goal ? FSS_ARE : FSS_GAMEOVER;
        goto beginTick;

      case FSS_GAMEOVER:
        f->se |= FST_SE_FLAG_GAMEOVER;
        /* FALLTHROUGH */

      case FSS_QUIT:
      case FSS_RESTART:
        break;

      default:
        fsLogError("Unknown state entered!");
        break;
    }

    f->totalTicks += 1;
}
int main (int argc, const char * const argv[])
{
    char buf[BUFSIZE];
    apr_size_t nRead, nWrite;
    apr_file_t *f_stdin;
    apr_file_t *f_stdout;
    apr_getopt_t *opt;
    apr_status_t rv;
    char c;
    const char *opt_arg;
    const char *err = NULL;
#if APR_FILES_AS_SOCKETS
    apr_pollfd_t pollfd = { 0 };
    apr_status_t pollret = APR_SUCCESS;
    int polltimeout;
#endif

    apr_app_initialize(&argc, &argv, NULL);
    atexit(apr_terminate);

    memset(&config, 0, sizeof config);
    memset(&status, 0, sizeof status);
    status.rotateReason = ROTATE_NONE;

    apr_pool_create(&status.pool, NULL);
    apr_getopt_init(&opt, status.pool, argc, argv);
#if APR_FILES_AS_SOCKETS
    while ((rv = apr_getopt(opt, "lL:p:ftvecn:", &c, &opt_arg)) == APR_SUCCESS) {
#else
    while ((rv = apr_getopt(opt, "lL:p:ftven:", &c, &opt_arg)) == APR_SUCCESS) {
#endif
        switch (c) {
        case 'l':
            config.use_localtime = 1;
            break;
        case 'L':
            config.linkfile = opt_arg;
            break;
        case 'p':
            config.postrotate_prog = opt_arg;
            break;
        case 'f':
            config.force_open = 1;
            break;
        case 't':
            config.truncate = 1;
            break;
        case 'v':
            config.verbose = 1;
            break;
        case 'e':
            config.echo = 1;
            break;
#if APR_FILES_AS_SOCKETS
        case 'c':
            config.create_empty = 1;
            break;
#endif
        case 'n':
            config.num_files = atoi(opt_arg);
            status.fileNum = -1;
            break;
        }
    }

    if (rv != APR_EOF) {
        usage(argv[0], NULL /* specific error message already issued */ );
    }

    /*
     * After the initial flags we need 2 to 4 arguments,
     * the file name, either the rotation interval time or size
     * or both of them, and optionally the UTC offset.
     */
    if ((argc - opt->ind < 2) || (argc - opt->ind > 4) ) {
        usage(argv[0], "Incorrect number of arguments");
    }

    config.szLogRoot = argv[opt->ind++];

    /* Read in the remaining flags, namely time, size and UTC offset. */
    for(; opt->ind < argc; opt->ind++) {
        if ((err = get_time_or_size(&config, argv[opt->ind],
                                    opt->ind < argc - 1 ? 0 : 1)) != NULL) {
            usage(argv[0], err);
        }
    }

    config.use_strftime = (strchr(config.szLogRoot, '%') != NULL);

    if (config.use_strftime && config.num_files > 0) { 
        fprintf(stderr, "Cannot use -n with %% in filename\n");
        exit(1);
    }

    if (status.fileNum == -1 && config.num_files < 1) { 
        fprintf(stderr, "Invalid -n argument\n");
        exit(1);
    }

    if (apr_file_open_stdin(&f_stdin, status.pool) != APR_SUCCESS) {
        fprintf(stderr, "Unable to open stdin\n");
        exit(1);
    }

    if (apr_file_open_stdout(&f_stdout, status.pool) != APR_SUCCESS) {
        fprintf(stderr, "Unable to open stdout\n");
        exit(1);
    }

    /*
     * Write out result of config parsing if verbose is set.
     */
    if (config.verbose) {
        dumpConfig(&config);
    }

#if APR_FILES_AS_SOCKETS
    if (config.create_empty && config.tRotation) {
        pollfd.p = status.pool;
        pollfd.desc_type = APR_POLL_FILE;
        pollfd.reqevents = APR_POLLIN;
        pollfd.desc.f = f_stdin;
    }
#endif

    /*
     * Immediately open the logfile as we start, if we were forced
     * to do so via '-f'.
     */
    if (config.force_open) {
        doRotate(&config, &status);
    }

    for (;;) {
        nRead = sizeof(buf);
#if APR_FILES_AS_SOCKETS
        if (config.create_empty && config.tRotation) {
            polltimeout = status.tLogEnd ? status.tLogEnd - get_now(&config) : config.tRotation;
            if (polltimeout <= 0) {
                pollret = APR_TIMEUP;
            }
            else {
                pollret = apr_poll(&pollfd, 1, &pollret, apr_time_from_sec(polltimeout));
            }
        }
        if (pollret == APR_SUCCESS) {
            rv = apr_file_read(f_stdin, buf, &nRead);
            if (APR_STATUS_IS_EOF(rv)) {
                break;
            }
            else if (rv != APR_SUCCESS) {
                exit(3);
            }
        }
        else if (pollret == APR_TIMEUP) {
            *buf = 0;
            nRead = 0;
        }
        else {
            fprintf(stderr, "Unable to poll stdin\n");
            exit(5);
        }
#else /* APR_FILES_AS_SOCKETS */
        rv = apr_file_read(f_stdin, buf, &nRead);
        if (APR_STATUS_IS_EOF(rv)) {
            break;
        }
        else if (rv != APR_SUCCESS) {
            exit(3);
        }
#endif /* APR_FILES_AS_SOCKETS */
        checkRotate(&config, &status);
        if (status.rotateReason != ROTATE_NONE) {
            doRotate(&config, &status);
        }

        nWrite = nRead;
        rv = apr_file_write_full(status.current.fd, buf, nWrite, &nWrite);
        if (nWrite != nRead) {
            apr_off_t cur_offset;

            cur_offset = 0;
            if (apr_file_seek(status.current.fd, APR_CUR, &cur_offset) != APR_SUCCESS) {
                cur_offset = -1;
            }
            status.nMessCount++;
            apr_snprintf(status.errbuf, sizeof status.errbuf,
                         "Error %d writing to log file at offset %" APR_OFF_T_FMT ". "
                         "%10d messages lost (%pm)\n",
                         rv, cur_offset, status.nMessCount, &rv);

            truncate_and_write_error(&status);
        }
        else {
            status.nMessCount++;
        }
        if (config.echo) {
            if (apr_file_write_full(f_stdout, buf, nRead, &nWrite)) {
                fprintf(stderr, "Unable to write to stdout\n");
                exit(4);
            }
        }
    }

    return 0; /* reached only at stdin EOF. */
}
示例#10
0
	void doLookAt() const {
		doRotate();
		doMove();
	}
示例#11
0
int main(int argc,char* argv[]){
    unsigned char * fp_temp;
    int i,blur,rotate,re_h,re_w;
    double thr;
    char* temp1,* temp2;
    char temp[100],fileadd[100],fileadd2[100]="out.bmp";
    float brightness=1.0,contrast=1.0;
    FILE * filein;
    FILE * fileout;
    fileadd[0]='\0';
    for(i=0;i<argc;i++){
        if(!strcmp(argv[i],"-h")){//jump to help menu
            help();
            return 0;
        }
        //get output filename
        if(!strcmp(argv[i],"-o")) strcpy(fileadd2,argv[i+1]);
        //get input filename
    }
    temp1=argv[argc-1]+(strlen(argv[argc-1])-3);
    if (!strcasecmp(temp1,"bmp")){
        strcpy(fileadd,argv[argc-1]);
    }
    else{
        printf("You should Input the input file\n");
        help();
        return 1;
    }
    if(fileadd[0]=='\0'){
        printf("Cannot find the input file\n");
        return 1;
    }
    //input file start
    filein=fopen(fileadd,"rb");
    if(filein==NULL)
    {
        printf("Open File failed(%s)!!Please input your filename again!!\n",fileadd);
        return 1;
    }
    printf("\n%s has already been opened\n",fileadd);
//input file over
//output file start
    fileout=fopen(fileadd2,"wb+");
    if(fileout==NULL)
    {
        printf("Open out.bmp failed!!\n");
        return 1;
    }
    printf("%s has already been created\n\n",fileadd2);
//output file over
//read file
    Create_File(filein);

//save header
    fseek(filein,0,SEEK_SET);
    fseek(fileout,0,SEEK_SET);
    fp_temp=malloc(OffSet);
    fread(fp_temp,1,OffSet,filein);
    fwrite(fp_temp,1,OffSet,fileout);
//save data
    data(filein);

    printf("**********BMP Converting ********************\n");

    for(i=0;i<argc;i++){
//do Threshold filter
        if(!strcmp(argv[i],"-t")){
            if (bits!=24){

                printf("Sorry!! This commond can only work for 24 bits per pixel\n");
                continue;
            }
            strcpy(temp,argv[i+1]);
            thr=atof(temp);
            if(thr==0||thr>1||thr<0){
                printf("Threshold input ERROR!! Nothing to be done\n");
                continue;
            }
            doThreshold_filter(thr);
        }
        if(!strcmp(argv[i],"-g"))
            doGrayscale();
        if(!strcmp(argv[i],"-sr"))
            Shield_r();
        if(!strcmp(argv[i],"-sb"))
            Shield_b();
        if(!strcmp(argv[i],"-sg"))
            Shield_g();

//do filter brightness&contrast
        if(!strcmp(argv[i],"-br")){
            strcpy(temp,argv[i+1]);
            brightness=atof(temp);
            if(brightness==0||brightness>2||brightness<0){
                printf("Converting brightness: Input ERROR!!! Nothing to be done\n");
                continue;
            }
            brightness=(brightness<0)?1.0:brightness;//got brightness
            printf("Convert: Brightness  %0.2f",brightness);
            doBrightnessContrast(brightness,1.0);
        }

        if(!strcmp(argv[i],"-c")){
            strcpy(temp,argv[i+1]);
            contrast=atof(temp);
            if(contrast==0||contrast>4||contrast<0){
                printf("Converting contrast: Input ERROR!!! Nothing to be done\n");
                continue;
            }
            contrast=(contrast<0)?1.0:contrast;//got contrast
            printf("Convert: Contrast  %0.2f",contrast);
            doBrightnessContrast(1.0,contrast);
        }
//convering brightness&contrast over
//do bluring
        if(!strcmp(argv[i],"-bl")){
            strcpy(temp,argv[i+1]);
            blur=atoi(temp);
            if(blur==0){
                printf("Converting blur: Input ERROR!!! Nothing to be done\n");
                continue;
            }
            if(blur>height||blur>width||blur<=0){
                printf("Blur should between 1 and min(height,width)!!Nothing to be done\n");
                continue;
            }
            doBluring(blur);
        }
// bluring done
//doRotate
        if(!strcmp(argv[i],"-r")){
            strcpy(temp,argv[i+1]);
            rotate=atoi(temp);
            if(rotate==0){
                printf("Converting rotate: Input ERROR!!! Nothing to be done\n");
                continue;
            }
            if(rotate%90!=0){
                printf("We can only rotate image by 90/180/270/360 degrees e.t.c\n");
                continue;
            }
            rotate=(rotate/90)%4;
            doRotate(rotate,fileout);
            printf("Rotate %d degree :done.\n",atoi(temp));
        }
//reSize
        if(!strcmp(argv[i],"-s")){
            temp2=argv[i+2];
            temp1=argv[i+1];
            if (temp1[strlen(temp1)-1]=='%'){
                temp1[strlen(temp1)-1]='\0';
                re_h=(int)(atof(temp1)*height/100);
            }
            else re_h=atoi(temp1);
            if (temp2[strlen(temp2)-1]=='%'){
                temp2[strlen(temp2)-1]='\0';
                re_w=(int)(atof(temp2)*width/100);
            }
            else re_w=atoi(temp2);
            if(re_h==0||re_w==0){
                printf("Resize Input ERROR!! Nothint to be done\n");
                continue;
            }
            doResize(re_w,re_h,fileout);
        }

    }

//output file
        output(fileout);
//        break;

    printf("*********************************************\n");
    printf("Thanks for using.  Good bye!!!\n");
    printf("\t\t\t\t\tCopyright:Nanxuan Huang\n");
    fclose(filein);
    fclose(fileout);
    return 0;
}