the resize image example demonstrates how to interactively resize a 2D image and display it using OpenGL. a image sampler is used to perform hardware-accelerated linear interpolation for the resized image.
| 209 | // 2D image and display it using OpenGL. a image sampler is used to perform |
| 210 | // hardware-accelerated linear interpolation for the resized image. |
| 211 | int main(int argc, char *argv[]) |
| 212 | { |
| 213 | // setup command line arguments |
| 214 | po::options_description options("options"); |
| 215 | options.add_options() |
| 216 | ("help", "show usage instructions") |
| 217 | ("file", po::value<std::string>(), "image file name (e.g. /path/to/image.png)") |
| 218 | ; |
| 219 | po::positional_options_description positional_options; |
| 220 | positional_options.add("file", 1); |
| 221 | |
| 222 | // parse command line |
| 223 | po::variables_map vm; |
| 224 | po::store( |
| 225 | po::command_line_parser(argc, argv) |
| 226 | .options(options) |
| 227 | .positional(positional_options) |
| 228 | .run(), |
| 229 | vm |
| 230 | ); |
| 231 | po::notify(vm); |
| 232 | |
| 233 | // check for file argument |
| 234 | if(vm.count("help") || !vm.count("file")){ |
| 235 | std::cout << options << std::endl; |
| 236 | return -1; |
| 237 | } |
| 238 | |
| 239 | // get file name |
| 240 | std::string file_name = vm["file"].as<std::string>(); |
| 241 | |
| 242 | // setup qt application |
| 243 | QApplication app(argc, argv); |
| 244 | |
| 245 | // setup image widget |
| 246 | ImageWidget widget(QString::fromStdString(file_name)); |
| 247 | widget.show(); |
| 248 | |
| 249 | // run qt application |
| 250 | return app.exec(); |
| 251 | } |
| 252 | |
| 253 | #include "resize_image.moc" |