Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 #pragma once
0021 
0022 /**
0023 SPPM
0024 ======
0025 
0026 Implementation of the minimal(and uncompressed) PPM image file format. 
0027 
0028 * PPM uses 24 bits per pixel: 8 for red, 8 for green, 8 for blue.
0029 * https://en.wikipedia.org/wiki/Netpbm_format
0030 
0031 * SPPM is used as the base class of oglrap/Pix and used by oglra/Frame::snap 
0032 
0033 
0034 Deficiencies
0035 -------------
0036 
0037 Much of SPPM is general image manipulation unrelated to the PPM image format. 
0038 
0039 * TODO : integrate image manipulation into SIMG or perhspa SIMGExtra
0040 
0041 
0042 DevNotes
0043 ----------
0044 
0045 * examples/UseOpticksGLFWSnap/UseOpticksGLFWSnap.cc
0046 * examples/UseOpticksGLFWSPPM/UseOpticksGLFWSPPM.cc
0047 * /Developer/OptiX_380/SDK/primeMultiGpu/primeCommon.cpp
0048 
0049 **/
0050 
0051 
0052 #include <string>
0053 #include <vector>
0054 #include "plog/Severity.h"
0055 
0056 #include "SYSRAP_API_EXPORT.hh"
0057 
0058 struct SYSRAP_API SPPM 
0059 {
0060     static const plog::Severity LEVEL ; 
0061 
0062     SPPM(); 
0063 
0064     unsigned char* pixels ; 
0065     int pwidth ; 
0066     int pheight ; 
0067     int pscale ; 
0068     bool yflip ; 
0069 
0070     std::string desc() const ; 
0071 
0072     virtual void download() = 0 ;
0073 
0074     void resize(int width, int height, int scale=1);
0075     void save(const char* path=NULL);
0076     void snap(const char* path=NULL); 
0077 
0078     static void save( const char* path, int width, int height, const unsigned char* image, bool yflip ) ;
0079 
0080     static void write( const char* filename, const unsigned char* image, int width, int height, int ncomp, bool yflip) ;
0081     static void write( const char* filename, const         float* image, int width, int height, int ncomp, bool yflip) ;
0082 
0083 
0084     static int read( const char* path, std::vector<unsigned char>& data, unsigned& width, unsigned& height, const unsigned ncomp, const bool yflip );
0085     static void dumpHeader( const char* path ) ; 
0086     static int readHeader( const char* path, unsigned& width, unsigned& height, unsigned& mode, unsigned& bits ) ; 
0087 
0088     static unsigned char* MakeTestImage(const int width, const int height, const int ncomp, const bool yflip,  const char* config); 
0089     static unsigned ImageCompare(const int width, const int height, const int ncomp, const unsigned char* imgdata, const unsigned char* imgdata2 ); 
0090 
0091     static void AddBorder( std::vector<unsigned char>& img, const int width, const int height, const int ncomp, const bool yflip );
0092     static void AddBorder(unsigned char* imgdata, const int width, const int height, const int ncomp, const bool yflip );
0093     static void AddMidline( std::vector<unsigned char>& img, const int width, const int height, const int ncomp, const bool yflip );
0094     static void AddMidline(unsigned char* imgdata, const int width, const int height, const int ncomp, const bool yflip );
0095     static void AddQuadline( std::vector<unsigned char>& img, const int width, const int height, const int ncomp, const bool yflip );
0096     static void AddQuadline(unsigned char* imgdata, const int width, const int height, const int ncomp, const bool yflip );
0097 
0098 
0099 
0100     // hmm need an SImage ? or do in SPPM ?
0101  
0102 };
0103 
0104 
0105 
0106