Skip to content
Snippets Groups Projects
Select Git revision
  • edd4f1f948bf4465d7836c5e7e95d512184c4485
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

FlGui.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    gl2ppm.cpp 826 B
    // Gmsh - Copyright (C) 1997-2019 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
    
    #include "gl2ppm.h"
    
    void create_ppm(FILE *outfile, PixelBuffer *buffer)
    {
      if(buffer->getFormat() != GL_RGB || buffer->getType() != GL_UNSIGNED_BYTE) {
        Msg::Error("PPM only implemented for GL_RGB and GL_UNSIGNED_BYTE");
        return;
      }
    
      int width = buffer->getWidth();
      int height = buffer->getHeight();
      unsigned char *pixels = (unsigned char *)buffer->getPixels();
    
      fprintf(outfile, "P6\n");
      fprintf(outfile, "%d %d\n", width, height);
      fprintf(outfile, "%d\n", 255);
    
      int row_stride = width * 3;
      int i = height - 1;
      while(i >= 0) {
        fwrite(&pixels[i * row_stride], 1, row_stride, outfile);
        i--;
      }
    }