band-writer.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef MUPDF_FITZ_BAND_WRITER_H
  2. #define MUPDF_FITZ_BAND_WRITER_H
  3. #include "mupdf/fitz/system.h"
  4. #include "mupdf/fitz/context.h"
  5. #include "mupdf/fitz/output.h"
  6. /*
  7. fz_band_writer
  8. */
  9. typedef struct fz_band_writer_s fz_band_writer;
  10. typedef void (fz_write_header_fn)(fz_context *ctx, fz_band_writer *writer);
  11. typedef void (fz_write_band_fn)(fz_context *ctx, fz_band_writer *writer, int stride, int band_start, int band_height, const unsigned char *samples);
  12. typedef void (fz_write_trailer_fn)(fz_context *ctx, fz_band_writer *writer);
  13. typedef void (fz_drop_band_writer_fn)(fz_context *ctx, fz_band_writer *writer);
  14. struct fz_band_writer_s
  15. {
  16. fz_drop_band_writer_fn *drop;
  17. fz_write_header_fn *header;
  18. fz_write_band_fn *band;
  19. fz_write_trailer_fn *trailer;
  20. fz_output *out;
  21. int w;
  22. int h;
  23. int n;
  24. int alpha;
  25. int xres;
  26. int yres;
  27. int pagenum;
  28. int line;
  29. };
  30. fz_band_writer *fz_new_band_writer_of_size(fz_context *ctx, size_t size, fz_output *out);
  31. #define fz_new_band_writer(C,M,O) ((M *)Memento_label(fz_new_band_writer_of_size(ctx, sizeof(M), O), #M))
  32. /*
  33. fz_write_header: Cause a band writer to write the header for
  34. a banded image with the given properties/dimensions etc. This
  35. also configures the bandwriter for the format of the data to be
  36. passed in future calls.
  37. w, h: Width and Height of the entire page.
  38. n: Number of components (including alphas).
  39. alpha: Number of alpha components.
  40. xres, yres: X and Y resolutions in dpi.
  41. pagenum: Page number
  42. Throws exception if incompatible data format.
  43. */
  44. void fz_write_header(fz_context *ctx, fz_band_writer *writer, int w, int h, int n, int alpha, int xres, int yres, int pagenum);
  45. /*
  46. fz_write_band: Cause a band writer to write the next band
  47. of data for an image.
  48. stride: The byte offset from the first byte of the data
  49. for a pixel to the first byte of the data for the same pixel
  50. on the row below.
  51. band_height: The number of lines in this band.
  52. samples: Pointer to first byte of the data.
  53. */
  54. void fz_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_height, const unsigned char *samples);
  55. void fz_drop_band_writer(fz_context *ctx, fz_band_writer *writer);
  56. #endif