📄 ppmdraw.cc
字号:
const char *help = "\progname: ppmdraw.cc\n\code2html: This program reads a ppm image and draws on it.\n\version: Torch3 vision2.0, 2004-2005\n\(c) Sebastien Marcel (marcel@idiap.ch)\n";#include "ImageRgb.h"#include "Rectangle2D.h"#include "DiskXFile.h"#include "CmdLine.h"using namespace Torch;int main(int argc, char **argv){ char *image_filename; char *color_name; bool verbose; // Construct the command line CmdLine cmd; cmd.setBOption("write log", false); // Put the help line at the beginning cmd.info(help); cmd.addText("\nArguments:"); cmd.addSCmdArg("image filename", &image_filename, "image filename"); cmd.addText("\nOptions:"); cmd.addBCmdOption("-verbose", &verbose, false, "verbose"); cmd.addSCmdOption("-colorname", &color_name, "green", "color name"); cmd.read(argc, argv); DiskXFile *image_file = NULL; Image *image = NULL; image = new ImageRgb(); image->setBOption("verbose", verbose); image_file = new DiskXFile(image_filename, "r"); image->loadXFile(image_file); delete image_file; if(verbose) { print("Image info:\n"); print(" width = %d\n", image->width); print(" height = %d\n", image->height); print(" format = %s (%d)\n", image->coding, image->n_planes); } if((image->width < 100) || (image->height < 100)) { print("Image too small to draw in it."); delete image_file; delete image; return 1; } // Point2D A(10,10); Point2D B(100,10); Point2D C(100,60); Point2D D(10,60); Rectangle2D r1(A, B, C, D); r1.draw(image, red); // A.reset(100,60); B.reset(200,60); C.reset(200,100); D.reset(100,100); Rectangle2D r2(A, B, C, D); r2.draw(image, color_name); image_file = new DiskXFile("test.ppm", "w"); image->saveXFile(image_file); delete image_file; delete image; return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -