当前位置: 首页>>代码示例>>C++>>正文


C++ MyImage::GetChannel方法代码示例

本文整理汇总了C++中MyImage::GetChannel方法的典型用法代码示例。如果您正苦于以下问题:C++ MyImage::GetChannel方法的具体用法?C++ MyImage::GetChannel怎么用?C++ MyImage::GetChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyImage的用法示例。


在下文中一共展示了MyImage::GetChannel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char** argv) {
   //if neither one or two parameters are input in command line, output the instruction of the usage of the program
   std::cout<<"argc"<<argc<<std::endl;
   if (argc < 2 || argc > 5) {
      std::cerr << "Usage: " << argv[0] << " [filename][writename][option] " << std::endl;
      exit(1);
   }
   //if second parameter is specified, store the file name to write the image
   else if (argc == 3)
   {
     std::string arg = argv[2];
     if (arg == "-pv"){ pvtag = 1; std::cout << "pvtag set." << std::endl; }
     else if (arg == "-ss"){ sstag = 1; std::cout << "sstag set." << std::endl;}
     else
     {
       writename = argv[2];
       std::cout << "writename is " << writename << std::endl;
     }
   }
   
   else if (argc == 4)
   {
     std::string arg = argv[3];
     std::string arg2 = argv[2];
     if (arg == "-pv" && arg2 != "-ss")
     { 
	pvtag = 1;        
	writename = argv[2];
        std::cout << "writename is " << writename << std::endl;
        std::cout << "pvtag is set." << std::endl;
     }	
     else if (arg == "-ss" && arg2 != "-pv")
     { 
	sstag = 1;       
	writename = argv[2]; 
        std::cout << "writename is " << writename << std::endl;
	std::cout << "sstag is set." << std::endl;
     }
     else if ((arg == "-ss" && arg2 == "-pv") || (arg == "-pv" && arg2 == "-ss")) 
     { 
	sstag = 1;
	pvtag = 1;       
	std::cout << "sstag is set." << std::endl;
	std::cout << "pvtag is set." << std::endl;
     }
     else
     {
        std::cerr << "Usage: " << argv[0] << " [filename][writename][option] " << std::endl;
        exit(1);
     }
   }
   else //argc == 5
   {
     std::string arg1 = argv[3], arg2 = argv[4];
     if (((arg1 == "-pv") && (arg2 == "-ss"))||((arg1 == "-ss") && (arg2 == "-pv")))
     {
	pvtag = 1;
	sstag = 1;
	writename = argv[2]; 
        std::cout << "writename is " << writename << std::endl;
	std::cout << "sstag and pvtag are set." << std::endl;
     }
   }

   //get the filename of the image, set the filename and read the image to get basic information of it
   filename = argv[1];
   std::cout << filename << std::endl;
   Image.SetFilename(filename);
   Image.ImageRead();
   Image.SetOriginalData();
   int h = Image.GetHeight();
   int w = Image.GetWidth();
   int c = Image.GetChannel();
   mask();
   //start up the glut utilities
   glutInit(&argc, argv);
   
   //create the graphics window, giving width, height and title text
   glutInitDisplayMode(GLUT_SINGLE | GLUT_DEPTH | GLUT_RGBA);
   glutInitWindowSize((Image.GetWidth()),Image.GetHeight());
   glutCreateWindow("Image");

   //glut keyboard function, display function and mouse function
   glutKeyboardFunc(handleKey);
   glutDisplayFunc(RenderScene);
   glutSpecialFunc(kfunc);
   //use glblend to display the alpha range 0~255 only in this program
   glEnable(GL_BLEND);
   glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
   glBlendEquation(GL_FUNC_ADD);
   //define the drawing coordinate system on the viewport
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluOrtho2D(0, w, 0, h);
     
  // specify window clear (background) color to be opaque white
   glClearColor(1, 1, 1, 1);

//glut loops
   glutMainLoop();
//.........这里部分代码省略.........
开发者ID:SiqiwuStella,项目名称:Computer-Graphic-Images,代码行数:101,代码来源:alphamask.cpp


注:本文中的MyImage::GetChannel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。