KiCad PCB EDA Suite
buffers_debug.cpp File Reference
#include "buffers_debug.h"
#include <wx/image.h>

Go to the source code of this file.

Functions

static void dbg_save_rgb_buffer (wxString aFileName, unsigned char *aRGBpixelBuffer, unsigned int aXSize, unsigned int aYSize)
 dbg_save_rgb_buffer More...
 
void DBG_SaveBuffer (wxString aFileName, const unsigned char *aInBuffer, unsigned int aXSize, unsigned int aYSize)
 
void DBG_SaveBuffer (wxString aFileName, const float *aInBuffer, unsigned int aXSize, unsigned int aYSize)
 
void DBG_SaveBuffer (wxString aFileName, const SFVEC3F *aInBuffer, unsigned int aXSize, unsigned int aYSize)
 
void DBG_SaveNormalsBuffer (wxString aFileName, const SFVEC3F *aInNormalsBuffer, unsigned int aXSize, unsigned int aYSize)
 

Function Documentation

static void dbg_save_rgb_buffer ( wxString  aFileName,
unsigned char *  aRGBpixelBuffer,
unsigned int  aXSize,
unsigned int  aYSize 
)
static

dbg_save_rgb_buffer

Parameters
aFileName
aRGBpixelBufferfrom wxWidget documentation "The data given must have the size (width*height*3). The data must have been allocated with malloc(), NOT with operator new."
aXSize
aYSize

Definition at line 42 of file buffers_debug.cpp.

Referenced by DBG_SaveBuffer(), and DBG_SaveNormalsBuffer().

46 {
47  wxImage image( aXSize, aYSize );
48  image.SetData( aRGBpixelBuffer );
49  image = image.Mirror( false );
50  image.SaveFile( aFileName + ".png", wxBITMAP_TYPE_PNG );
51  image.Destroy();
52 }
void DBG_SaveBuffer ( wxString  aFileName,
const unsigned char *  aInBuffer,
unsigned int  aXSize,
unsigned int  aYSize 
)

Definition at line 55 of file buffers_debug.cpp.

References dbg_save_rgb_buffer().

Referenced by CPOSTSHADER::DebugBuffersOutputAsImages(), and CIMAGE::SaveAsPNG().

59 {
60  const unsigned int wxh = aXSize * aYSize;
61 
62  unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
63 
64  for( unsigned int i = 0; i < wxh; ++i )
65  {
66  unsigned char v = aInBuffer[i];
67 
68  // Set RGB value with all same values intensities
69  pixelbuffer[i * 3 + 0] = v;
70  pixelbuffer[i * 3 + 1] = v;
71  pixelbuffer[i * 3 + 2] = v;
72  }
73 
74  dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
75 }
static void dbg_save_rgb_buffer(wxString aFileName, unsigned char *aRGBpixelBuffer, unsigned int aXSize, unsigned int aYSize)
dbg_save_rgb_buffer
void DBG_SaveBuffer ( wxString  aFileName,
const float *  aInBuffer,
unsigned int  aXSize,
unsigned int  aYSize 
)

Definition at line 78 of file buffers_debug.cpp.

References dbg_save_rgb_buffer(), and min.

82 {
83  const unsigned int wxh = aXSize * aYSize;
84 
85  unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
86 
87  for( unsigned int i = 0; i < wxh; ++i )
88  {
89  const unsigned char v = (unsigned char)glm::min( (int)(aInBuffer[i] * 255.0f),
90  255 );
91 
92  // Set RGB value with all same values intensities
93  pixelbuffer[i * 3 + 0] = v;
94  pixelbuffer[i * 3 + 1] = v;
95  pixelbuffer[i * 3 + 2] = v;
96  }
97 
98  dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
99 }
static void dbg_save_rgb_buffer(wxString aFileName, unsigned char *aRGBpixelBuffer, unsigned int aXSize, unsigned int aYSize)
dbg_save_rgb_buffer
#define min(a, b)
Definition: auxiliary.h:85
void DBG_SaveBuffer ( wxString  aFileName,
const SFVEC3F aInBuffer,
unsigned int  aXSize,
unsigned int  aYSize 
)

Definition at line 102 of file buffers_debug.cpp.

References dbg_save_rgb_buffer(), and min.

106 {
107  const unsigned int wxh = aXSize * aYSize;
108 
109  unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
110 
111  for( unsigned int i = 0; i < wxh; ++i )
112  {
113  const SFVEC3F &v = aInBuffer[i];
114  const unsigned int ix3 = i * 3;
115 
116  // Set RGB value with all same values intensities
117  pixelbuffer[ix3 + 0] = (unsigned char)glm::min( (int)(v.r * 255.0f), 255 );
118  pixelbuffer[ix3 + 1] = (unsigned char)glm::min( (int)(v.g * 255.0f), 255 );
119  pixelbuffer[ix3 + 2] = (unsigned char)glm::min( (int)(v.b * 255.0f), 255 );
120  }
121 
122  dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
123 }
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
static void dbg_save_rgb_buffer(wxString aFileName, unsigned char *aRGBpixelBuffer, unsigned int aXSize, unsigned int aYSize)
dbg_save_rgb_buffer
#define min(a, b)
Definition: auxiliary.h:85
void DBG_SaveNormalsBuffer ( wxString  aFileName,
const SFVEC3F aInNormalsBuffer,
unsigned int  aXSize,
unsigned int  aYSize 
)

Definition at line 126 of file buffers_debug.cpp.

References dbg_save_rgb_buffer(), and min.

Referenced by CPOSTSHADER::DebugBuffersOutputAsImages().

130 {
131  const unsigned int wxh = aXSize * aYSize;
132 
133  unsigned char *pixelbuffer = (unsigned char*) malloc( wxh * 3 );
134 
135  for( unsigned int i = 0; i < wxh; ++i )
136  {
137  const SFVEC3F &v = aInNormalsBuffer[i];
138  const unsigned int ix3 = i * 3;
139 
140  // Set RGB value with all same values intensities
141  pixelbuffer[ix3 + 0] = (unsigned char)glm::min( (int)((v.r + 1.0f) * 127.0f), 255 );
142  pixelbuffer[ix3 + 1] = (unsigned char)glm::min( (int)((v.g + 1.0f) * 127.0f), 255 );
143  pixelbuffer[ix3 + 2] = (unsigned char)glm::min( (int)((v.b + 1.0f) * 127.0f), 255 );
144  }
145 
146  dbg_save_rgb_buffer( aFileName, pixelbuffer, aXSize, aYSize );
147 }
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
static void dbg_save_rgb_buffer(wxString aFileName, unsigned char *aRGBpixelBuffer, unsigned int aXSize, unsigned int aYSize)
dbg_save_rgb_buffer
#define min(a, b)
Definition: auxiliary.h:85