aboutsummaryrefslogtreecommitdiff
path: root/src/IOJpeg.h
blob: 61a7ff65a98cec36c42d2a8317d3ca335a072e4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifdef __cplusplus
extern "C" {
#endif

#define SLABSKEL_MAXDIM 4

#include "StoreNamedData.h"

/* structure holding information on the output geometry */
typedef struct IOJpegGeo
{
  int vdim;                       /* dimension of the gridvariable (dynamic) */
  int sdim;                       /* dimension of the slab (dynamic) */
  int direction[SLABSKEL_MAXDIM]; /* direction of slab (by parameter) */
  int slab_start[SLABSKEL_MAXDIM];/* global start index  (by parameter) */
  int length[SLABSKEL_MAXDIM];    /* requested index slab length (by parameter) */
  int actlen[SLABSKEL_MAXDIM];    /* actual index slab length (by PUGHSlab)*/
  int downs[SLABSKEL_MAXDIM];     /* downsampling (by parameter) */
} IOJpegGeo_t;


/* IOJpeg  GH extension structure */
typedef struct  IOJpegGH  {

  /* how often to output */
  int  out2D_every;

  /* flags indicating output for var [i] */
  char   *do_out2D;

  /* directories in which to output */
  char  *outdir2D;

  /* the last iteration output */
  int   *out2D_last;

  /* geometry information (downsampling, zooming, etc.) */
   IOJpegGeo_t **out_geo; 

  /* flags indicating file [slab][variable] is advertised */
   char *advertised[SLABSKEL_MAXDIM]; 

} IOJpegGH;

/* function prototypes */
int IOJpeg_Write3D (cGH *GH, int index, const char *alias);
int IOJpeg_Write2D (cGH *GH, int index, const char *alias);
int IOJpeg_Write1D (cGH *GH, int index, const char *alias);

int  IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *fid);

int WriteJPEGToFileRGB(int nx, /* width of image in pixels */
		       int ny, /* height of the image in pixels */
		       void *data, /* buffer containing image data */
		       int Quality, /* Integer from 0 to 100 */
		       FILE* outfile);	/* name of file to store in */

int WriteJPEGToMemoryRGB(int nx,int ny, void *data, int Quality, char *memorybuffer,int bufsize);

void AutoColorDataSlice(int nx,int ny, /* size of the image x & y */
			CCTK_REAL *datain, /* 2D slice of data input */
			unsigned char *dataout, /* RGB image data output */
			CCTK_REAL min,CCTK_REAL max, /* range of the entire 3D dataset
						  This could be ranged based 
						  on the values of the slice,
						  but then that would be a
						  bit untrustworthy.  Its
						  best to pass in the 
						  range for the entire 
						  dataset or a pre-defined
						  fixed range.  It does
						  handle clamping of the
						  range. */
			CCTK_REAL bias,
			int rdfac);

#ifdef __cplusplus
} // extern "C"
#endif