Skip to content
Snippets Groups Projects
Select Git revision
  • eaf92a706980022fc5f558e7088b61a18cdfb8c8
  • master default protected
  • steplayer
  • bl
  • pluginMeshQuality
  • fixBugsAmaury
  • hierarchical-basis
  • alphashapes
  • relaying
  • new_export_boris
  • oras_vs_osm
  • reassign_partitions
  • distributed_fwi
  • rename-classes
  • fix/fortran-api-example-t4
  • robust_partitions
  • reducing_files
  • fix_overlaps
  • 3115-issue-fix
  • 3023-Fillet2D-Update
  • convert_fdivs
  • gmsh_4_14_0
  • gmsh_4_13_1
  • gmsh_4_13_0
  • gmsh_4_12_2
  • gmsh_4_12_1
  • gmsh_4_12_0
  • gmsh_4_11_1
  • gmsh_4_11_0
  • gmsh_4_10_5
  • gmsh_4_10_4
  • gmsh_4_10_3
  • gmsh_4_10_2
  • gmsh_4_10_1
  • gmsh_4_10_0
  • gmsh_4_9_5
  • gmsh_4_9_4
  • gmsh_4_9_3
  • gmsh_4_9_2
  • gmsh_4_9_1
  • gmsh_4_9_0
41 results

gl2ppm.cpp

Blame
  • 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--;
      }
    }