home *** CD-ROM | disk | FTP | other *** search
/ Computer Panoráma / computer_panorama_1997-12-hibas.iso / SHARE / GRAPH / PTC051.ZIP / EXAMPLES / IMAGE.CPP < prev    next >
C/C++ Source or Header  |  1997-09-23  |  990b  |  55 lines

  1. //////////////////
  2. // image viewer //
  3. //////////////////
  4.  
  5. #include "ptc.h"
  6. #include <iostream.h>
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. int main(int argc,char *argv[])
  14. {
  15.     // initialize from command line
  16.     PTC ptc(320,200,argc,argv);
  17.     if (!ptc.ok())
  18.     {
  19.         if (!ptc.Init(320,200))
  20.         {
  21.             // failure
  22.             ptc.Close();
  23.             cout << "could not initialize ptc\n";
  24.             return 1;
  25.         }
  26.     }
  27.     
  28.     // get display resolution
  29.     int xres=ptc.GetXResolution();
  30.     int yres=ptc.GetYResolution();
  31.  
  32.     // load image
  33.     Surface surface(ptc,"image.tga");
  34.     if (!surface.ok())
  35.     {
  36.         ptc.Close();
  37.         cout << "could not load image\n";
  38.         return 1;
  39.     }
  40.  
  41.     // convert image
  42.     if (!surface.Convert(ARGB8888))
  43.     {
  44.         // failure
  45.         ptc.Close();
  46.         cout << "could not convert image\n";
  47.         return 1;
  48.     }
  49.  
  50.     // display image
  51.     surface.Update();
  52.     ptc.getch();
  53.     return 0;
  54. }
  55.