Commit 76396b52f68546a8f6c96e82f7857f240c6f3f9c
1 parent
2e73e7bc
removed Qt from the colormap library, added CImg
Showing
8 changed files
with
26 additions
and
52 deletions
Show diff stats
cpp/colormap.cpp deleted
1 | -#include <qimage.h> | |
2 | -#include <qcolor.h> | |
3 | -#include <iostream> | |
4 | - | |
5 | -void qt_buffer2image(unsigned char* buffer, std::string filename, unsigned int x_size, unsigned int y_size) | |
6 | -{ | |
7 | - //x_size = 256; | |
8 | - //y_size = 256; | |
9 | - //create an image object | |
10 | - QImage image(x_size, y_size, QImage::Format_RGB32); | |
11 | - if(image.isNull()) | |
12 | - { | |
13 | - std::cout<<"Error creating QImage."<<std::endl; | |
14 | - return; | |
15 | - } | |
16 | - | |
17 | - int i; | |
18 | - unsigned char r, g, b; | |
19 | - unsigned int x, y; | |
20 | - for(y=0; y<y_size; y++) | |
21 | - for(x=0; x<x_size; x++) | |
22 | - { | |
23 | - //calculate the 1D index | |
24 | - i = y * x_size + x; | |
25 | - | |
26 | - r = buffer[i * 3 + 0]; | |
27 | - g = buffer[i * 3 + 1]; | |
28 | - b = buffer[i * 3 + 2]; | |
29 | - | |
30 | - //set the image pixel | |
31 | - QColor color(r, g, b); | |
32 | - image.setPixel(x, y, color.rgb()); | |
33 | - } | |
34 | - | |
35 | - if(!image.save(filename.c_str())) | |
36 | - std::cout<<"Error saving QImage."<<std::endl; | |
37 | -} |
cuda/threads.h
math/quaternion.h
math/triangle.h
optics/material.h
... | ... | @@ -8,9 +8,9 @@ |
8 | 8 | #include <complex> |
9 | 9 | #include <algorithm> |
10 | 10 | #include <sstream> |
11 | -#include "rts/math/complex.h" | |
12 | -#include "rts/math/constants.h" | |
13 | -#include "rts/math/function.h" | |
11 | +#include "../math/complex.h" | |
12 | +#include "../math/constants.h" | |
13 | +#include "../math/function.h" | |
14 | 14 | |
15 | 15 | namespace rts{ |
16 | 16 | ... | ... |
optics/mirst-1d.cuh
ui/arguments.h
... | ... | @@ -313,7 +313,7 @@ namespace stim{ |
313 | 313 | |
314 | 314 | int index(std::string _name) |
315 | 315 | { |
316 | - unsigned int i = find(args.begin(), args.end(), _name) - args.begin(); | |
316 | + int i = find(args.begin(), args.end(), _name) - args.begin(); | |
317 | 317 | |
318 | 318 | if(i >= args.size()) |
319 | 319 | i = -1; | ... | ... |
visualization/colormap.h
... | ... | @@ -3,12 +3,14 @@ |
3 | 3 | |
4 | 4 | #include <string> |
5 | 5 | #include <stdlib.h> |
6 | -#include "rts/cuda/error.h" | |
6 | +#include "../cuda/error.h" | |
7 | 7 | |
8 | +//saving an image to a file uses the CImg library | |
9 | + //this currently throws a lot of "unreachable" warnings (as of GCC 4.8.2, nvcc 6.5.12) | |
10 | +#include "../../CImg/CImg.h" | |
8 | 11 | |
9 | -#define BREWER_CTRL_PTS 11 | |
10 | 12 | |
11 | -void qt_buffer2image(unsigned char* buffer, std::string filename, unsigned int x_size, unsigned int y_size); | |
13 | +#define BREWER_CTRL_PTS 11 | |
12 | 14 | |
13 | 15 | static float BREWERCP[BREWER_CTRL_PTS*4] = {0.192157f, 0.211765f, 0.584314f, 1.0f, |
14 | 16 | 0.270588f, 0.458824f, 0.705882f, 1.0f, |
... | ... | @@ -28,15 +30,24 @@ texture<float4, cudaTextureType1D> cudaTexBrewer; |
28 | 30 | static cudaArray* gpuBrewer; |
29 | 31 | #endif |
30 | 32 | |
31 | - | |
32 | - | |
33 | 33 | namespace rts{ |
34 | 34 | |
35 | 35 | enum colormapType {cmBrewer, cmGrayscale, cmRainbow}; |
36 | 36 | |
37 | 37 | static void buffer2image(unsigned char* buffer, std::string filename, unsigned int x_size, unsigned int y_size) |
38 | 38 | { |
39 | - qt_buffer2image(buffer, filename, x_size, y_size); | |
39 | + unsigned char* non_interleaved = (unsigned char*)malloc(x_size * y_size * 3); | |
40 | + unsigned int S = x_size * y_size; | |
41 | + | |
42 | + for(unsigned int i = 0; i < S; i++){ | |
43 | + non_interleaved[i + 0 * S] = buffer[i * 3 + 0]; | |
44 | + non_interleaved[i + 1 * S] = buffer[i * 3 + 1]; | |
45 | + non_interleaved[i + 2 * S] = buffer[i * 3 + 2]; | |
46 | + } | |
47 | + | |
48 | + //create an image object | |
49 | + cimg_library::CImg<unsigned char> image(non_interleaved, x_size, y_size, 1, 3); | |
50 | + image.save(filename.c_str()); | |
40 | 51 | } |
41 | 52 | |
42 | 53 | #ifdef __CUDACC__ | ... | ... |