Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #pragma once
0002 /**
0003 SIMG_Frame.h
0004 =============
0005 
0006 Connector between SIMG.h image handling and 
0007 for example SGLFW.h OpenGL umbrella. 
0008 
0009 **/
0010 
0011 #define SIMG_IMPLEMENTATION 1
0012 #include "SIMG.h"
0013 #include "ssys.h"
0014 
0015 struct SIMG_Frame
0016 {
0017     int width ; 
0018     int height ;
0019     int channels ;  // formerly used default of 4 
0020     int num_pixels ; 
0021     size_t size ;     
0022     int quality ; 
0023 
0024     unsigned char* pixels ; 
0025     SIMG*      img ; 
0026 
0027     SIMG_Frame(int _width, int _height, int _channels ); 
0028 
0029     void flipVertical(); 
0030 
0031     void writeJPG(const char* dir, const char* name) const ; 
0032     void writeJPG(const char* path) const ; 
0033 
0034     void writeNPY(const char* dir, const char* name) const ; 
0035     void writeNPY(const char* path) const ; 
0036 };
0037 
0038 inline SIMG_Frame::SIMG_Frame(int _width, int _height, int _channels)
0039     :
0040     width(_width),
0041     height(_height),
0042     channels(_channels),
0043     num_pixels(width*height),
0044     size(width*height*channels),
0045     quality(ssys::getenvint("SIMG_Frame__QUALITY", 50)),
0046     pixels(new unsigned char[size]),
0047     img(new SIMG(width, height, channels, pixels ))
0048 {
0049 }
0050 
0051 inline void SIMG_Frame::flipVertical()
0052 {
0053     img->flipVertical(); 
0054 }
0055 
0056 inline void SIMG_Frame::writeJPG(const char* dir, const char* name) const 
0057 {
0058     img->writeJPG(dir, name, quality );  
0059 }
0060 inline void SIMG_Frame::writeJPG(const char* path) const 
0061 {
0062     img->writeJPG(path, quality );  
0063 }
0064 
0065 inline void SIMG_Frame::writeNPY(const char* dir, const char* name) const 
0066 {
0067     img->writeNPY(dir, name);  
0068 }
0069 inline void SIMG_Frame::writeNPY(const char* path) const 
0070 {
0071     img->writeNPY(path);  
0072 }
0073 
0074