imagefile.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. typedef struct Rawimage Rawimage;
  2. struct Rawimage
  3. {
  4. Rectangle r;
  5. uchar *cmap;
  6. int cmaplen;
  7. int nchans;
  8. uchar *chans[4];
  9. int chandesc;
  10. int chanlen;
  11. int fields; /* defined by format */
  12. int gifflags; /* gif only; graphics control extension flag word */
  13. int gifdelay; /* gif only; graphics control extension delay in cs */
  14. int giftrindex; /* gif only; graphics control extension transparency index */
  15. int gifloopcount; /* number of times to loop in animation; 0 means forever */
  16. };
  17. enum
  18. {
  19. /* Channel descriptors */
  20. CRGB = 0, /* three channels, no map */
  21. CYCbCr = 1, /* three channels, no map, level-shifted 601 color space */
  22. CY = 2, /* one channel, luminance */
  23. CRGB1 = 3, /* one channel, map present */
  24. CRGBV = 4, /* one channel, map is RGBV, understood */
  25. CRGB24 = 5, /* one channel in correct data order for loadimage(RGB24) */
  26. CRGBA32 = 6, /* one channel in correct data order for loadimage(RGBA32) */
  27. CYA16 = 7, /* one channel in correct data order for loadimage(Grey8+Alpha8) */
  28. CRGBVA16= 8, /* one channel in correct data order for loadimage(CMAP8+Alpha8) */
  29. /* GIF flags */
  30. TRANSP = 1,
  31. INPUT = 2,
  32. DISPMASK = 7<<2
  33. };
  34. enum{ /* PNG flags */
  35. II_GAMMA = 1 << 0,
  36. II_COMMENT = 1 << 1,
  37. };
  38. typedef struct ImageInfo {
  39. ulong fields_set;
  40. double gamma;
  41. char *comment;
  42. } ImageInfo;
  43. Rawimage** readjpg(int, int);
  44. Rawimage** Breadjpg(Biobuf *b, int);
  45. Rawimage** readpng(int, int);
  46. Rawimage** Breadpng(Biobuf *b, int);
  47. Rawimage** readgif(int, int);
  48. Rawimage** readpixmap(int, int);
  49. Rawimage* torgbv(Rawimage*, int);
  50. Rawimage* totruecolor(Rawimage*, int);
  51. int writerawimage(int, Rawimage*);
  52. void* _remaperror(char*, ...);
  53. typedef struct Memimage Memimage; /* avoid necessity to include memdraw.h */
  54. char* startgif(Biobuf*, Image*, int);
  55. char* writegif(Biobuf*, Image*, char*, int, int);
  56. void endgif(Biobuf*);
  57. char* memstartgif(Biobuf*, Memimage*, int);
  58. char* memwritegif(Biobuf*, Memimage*, char*, int, int);
  59. void memendgif(Biobuf*);
  60. Image* onechan(Image*);
  61. Memimage* memonechan(Memimage*);
  62. char* writeppm(Biobuf*, Image*, char*);
  63. char* memwriteppm(Biobuf*, Memimage*, char*);
  64. Image* multichan(Image*);
  65. Memimage* memmultichan(Memimage*);
  66. char* memwritepng(Biobuf*, Memimage*, ImageInfo*);