lwimageio.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * LWSDK Header File
  3. * Copyright 1999, NewTek, Inc.
  4. *
  5. * LWIMAGEIO.H -- LightWave Image Input/Ouput
  6. *
  7. * This header defines the structures required for basic image I/O.
  8. * This includes the different image matrix protocols and the local
  9. * structs for the image loader and image saver.
  10. */
  11. #ifndef LWSDK_IMAGEIO_H
  12. #define LWSDK_IMAGEIO_H
  13. #include <lwmonitor.h>
  14. #define LWIMAGELOADER_CLASS "ImageLoader"
  15. #define LWIMAGELOADER_VERSION 2
  16. #define LWIMAGESAVER_CLASS "ImageSaver"
  17. #define LWIMAGESAVER_VERSION 2
  18. /*
  19. * Image Pixel Datatypes.
  20. */
  21. typedef enum en_LWImageType {
  22. LWIMTYP_RGB24 = 0,
  23. LWIMTYP_GREY8,
  24. LWIMTYP_INDEX8,
  25. LWIMTYP_GREYFP,
  26. LWIMTYP_RGBFP,
  27. LWIMTYP_RGBA32,
  28. LWIMTYP_RGBAFP,
  29. LWIMTYP_SPECIAL
  30. } LWImageType;
  31. /*
  32. * Image Pixel Structures.
  33. */
  34. typedef void * LWPixelID;
  35. typedef struct st_LWPixelRGB24 {
  36. unsigned char r;
  37. unsigned char g;
  38. unsigned char b;
  39. } LWPixelRGB24;
  40. typedef struct st_LWPixelRGBFP {
  41. float r;
  42. float g;
  43. float b;
  44. } LWPixelRGBFP;
  45. typedef struct st_LWPixelRGBA32 {
  46. unsigned char r;
  47. unsigned char g;
  48. unsigned char b;
  49. unsigned char a;
  50. } LWPixelRGBA32;
  51. typedef struct st_LWPixelRGBAFP {
  52. float r;
  53. float g;
  54. float b;
  55. float a;
  56. } LWPixelRGBAFP;
  57. /*
  58. * Image Buffer Protocol with parameter tags.
  59. */
  60. typedef enum en_LWImageParam {
  61. LWIMPAR_ASPECT = 1, /* x / y Pixel Aspect. */
  62. LWIMPAR_NUMCOLS,
  63. LWIMPAR_PIXELWIDTH, /* Actual (scanned)Pixel Width in (mm). */
  64. LWIMPAR_FRAMESPERSECOND, /* Number Of Frames Per Second. */
  65. LWIMPAR_BLACKPOINT, /* Black Point Of Layer. */
  66. LWIMPAR_WHITEPOINT, /* White Point Of Layer. */
  67. LWIMPAR_GAMMA, /* Linearity Of RGB Color. */
  68. } LWImageParam;
  69. typedef struct st_LWImageProtocol {
  70. int type;
  71. void *priv_data;
  72. int (*done) (void *, int);
  73. void (*setSize) (void *, int w, int h);
  74. void (*setParam) (void *, LWImageParam, int, float);
  75. int (*sendLine) (void *, int, const LWPixelID);
  76. void (*setMap) (void *, int, const unsigned char[3]);
  77. } LWImageProtocol, *LWImageProtocolID;
  78. /*
  79. * "ImageLoader" local struct.
  80. */
  81. typedef struct st_LWImageLoaderLocal {
  82. void *priv_data;
  83. int result;
  84. const char *filename;
  85. LWMonitor *monitor;
  86. LWImageProtocolID (*begin) (void *, LWImageType);
  87. void (*done) (void *, LWImageProtocolID);
  88. } LWImageLoaderLocal;
  89. /*
  90. * "ImageSaver" local struct.
  91. */
  92. typedef struct st_LWImageSaverLocal {
  93. void *priv_data;
  94. int result;
  95. LWImageType type;
  96. const char *filename;
  97. LWMonitor *monitor;
  98. int (*sendData) (void *, LWImageProtocolID, int flags);
  99. } LWImageSaverLocal;
  100. /*
  101. Result Value
  102. The result value indicates the status of the loader or saver upon
  103. completion. If the load or save was sucessful, the value should be
  104. IPSTAT_OK. If a loader fails to recognize a file as something it can load
  105. it should set the result to IPSTAT_NOREC. If the server could not open
  106. the file it should return IPSTAT_BADFILE. Any other error is just a
  107. generic failure of the loader or saver and so should set the result to
  108. IPSTAT_FAILED. Other failure modes might be possible if required
  109. in the future.
  110. */
  111. #define IPSTAT_OK 0
  112. #define IPSTAT_NOREC 1
  113. #define IPSTAT_BADFILE 2
  114. #define IPSTAT_ABORT 3
  115. #define IPSTAT_FAILED 99
  116. /* Flags to be passed to 'setSize' and 'sendData' callbacks. */
  117. #define IMGF_REVERSE (1<<0)
  118. /* There are also some protocol macros defined
  119. to get the whole calling interface right. */
  120. #define LWIP_SETSIZE(p,w,h) (*(p)->setSize) ((p)->priv_data,w,h)
  121. #define LWIP_SETPARAM(p,t,i,f) (*(p)->setParam) ((p)->priv_data,t,i,f)
  122. #define LWIP_ASPECT(p,a) LWIP_SETPARAM (p, LWIMPAR_ASPECT, 0, a)
  123. #define LWIP_NUMCOLORS(p,n) LWIP_SETPARAM (p, LWIMPAR_NUMCOLS, n, 0.0)
  124. #define LWIP_SENDLINE(p,ln,d) (*(p)->sendLine) ((p)->priv_data,ln,d)
  125. #define LWIP_SETMAP(p,i,val) (*(p)->setMap) ((p)->priv_data,i,val)
  126. #define LWIP_DONE(p,err) (*(p)->done) ((p)->priv_data,err)
  127. /*
  128. Compatibility macros.
  129. These types are obsolete, but are included to make it easier to convert
  130. to the new image format. The IMG_* value have been replaced with the
  131. LWImageType type codes, although the values of 0, 1 and 2 map to equivalent
  132. types. The ImageValue type is gone completely, and a Pixel* structure
  133. type should be used, or an explicit reference to unsigned char.
  134. */
  135. #define IMG_RGB24 0
  136. #define IMG_GREY8 1
  137. #define IMG_INDEX8 2
  138. typedef unsigned char ImageValue;
  139. #endif