main(int argc, char *argv[]) { int istat, narg, nchar; char process[MAXLINE]; // set program name strcpy(prog_name, PNAME); // check command line for correct usage fprintf(stdout, "\n%s Arguments: ", prog_name); for (narg = 0; narg < argc; narg++) fprintf(stdout, "<%s> ", argv[narg]); fprintf(stdout, "\n"); if (argc > 1) sscanf(argv[1], "%s", process); else strcpy(process, ""); nchar = 0; while ( nchar < MAXLINE && (process[nchar] = toupper(process[nchar])) ) nchar++; if (strcmp(process, "90CW") == 0) { if (argc < 4) { puterr("ERROR wrong number of command line arguments."); disp_usage(PNAME, "90CW <input_gridfile> <output_gridfile>"); exit(-1); } if ((istat = Rotate90CW(argc, argv)) < 0) { puterr("ERROR doing Rotate 90CW process."); exit(-1); } } else { sprintf(MsgStr, "ERROR unrcognized process - <%s>.", process); puterr(MsgStr); disp_usage(PNAME, "90CW/... <arguments>"); exit(-1); } exit(0); }
bool RotationInstance::ExecuteOn( View& view ) { if ( !view.IsMainView() ) return false; // should never reach this point! AutoViewLock lock( view ); ImageVariant image = view.Image(); if ( image.IsComplexSample() ) return false; double degrees = Round( Deg( p_angle ), 4 ); if ( degrees == 0 ) { Console().WriteLn( "<end><cbr><* Identity *>" ); return true; } ImageWindow window = view.Window(); window.RemoveMaskReferences(); window.RemoveMask(); window.DeletePreviews(); Console().EnableAbort(); StandardStatus status; image.SetStatusCallback( &status ); if ( p_optimizeFast ) switch ( TruncI( degrees ) ) { case 90: Rotate90CCW() >> image; return true; case -90: Rotate90CW() >> image; return true; case 180: case -180: Rotate180() >> image; return true; default: break; } AutoPointer<PixelInterpolation> interpolation( NewInterpolation( p_interpolation, 1, 1, 1, 1, true, p_clampingThreshold, p_smoothness, image ) ); Rotation T( *interpolation, p_angle ); /* * On 32-bit systems, make sure the resulting image requires less than 4 GB. */ if ( sizeof( void* ) == sizeof( uint32 ) ) { int width = image.Width(), height = image.Height(); T.GetNewSizes( width, height ); uint64 sz = uint64( width )*uint64( height )*image.NumberOfChannels()*image.BytesPerSample(); if ( sz > uint64( uint32_max-256 ) ) throw Error( "Rotation: Invalid operation: Target image dimensions would exceed four gigabytes" ); } T.SetFillValues( p_fillColor ); T >> image; return true; }