Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:07

0001 #include "QTex.hh"
0002 #include "QTexRotate.hh"
0003 
0004 #include <vector_types.h>
0005 #include <vector_functions.h>
0006 #include <cuda_runtime.h>
0007 
0008 #include "cudaCheckErrors.h"
0009 
0010 #include <iostream>
0011 #define SIMG_IMPLEMENTATION 1 
0012 #include "SIMG.h"
0013 
0014 struct NP ; 
0015 
0016 int main(int argc, char** argv)
0017 {
0018     const char* ipath = argc > 1 ? argv[1] : "/tmp/i.png" ;
0019     const char* opath = argc > 2 ? argv[2] : "/tmp/o.png" ;
0020 
0021     int desired_channels = 4 ;
0022     // hmm *desired_channels* does not change channels, the input image must be 4-channel 
0023     // (png are often 4-channel, jpg are 3 channel) 
0024 
0025     SIMG img(ipath, desired_channels);
0026     std::cout << img.desc() << std::endl ;
0027 
0028     if( img.channels == 0 )
0029     {
0030         std::cout 
0031             << argv[0]
0032             << " failed to open input path to png image with 4 channels  " << ipath 
0033             << std::endl 
0034             ;
0035         return 0 ; 
0036     }
0037 
0038     assert( img.channels == 4 );
0039 
0040     char filterMode = 'P' ; // cudaFilterModePoint : no interpolation, necessary with uchar4 
0041     bool normalizedCoords = false ; 
0042     const NP* a = nullptr ; 
0043  
0044     QTex<uchar4> qtex(img.width, img.height, img.data, filterMode, normalizedCoords, a );
0045 
0046 
0047     QTexRotate<uchar4> qrot(&qtex); 
0048 
0049     float theta = 1.f ; // radian
0050     qrot.rotate(theta); 
0051 
0052     cudaDeviceSynchronize();
0053 
0054     std::cout << "writing to " << opath << std::endl ;
0055 
0056     SIMG img2(img.width, img.height, img.channels, (unsigned char*)qrot.rotate_dst );
0057     img2.writePNG(opath);
0058 
0059     return 0;
0060 }
0061