2
0

API-CXX.html 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. <html>
  2. <head>
  3. <meta http-equiv="content-type" content="text/html; charset=windows-1252">
  4. </head>
  5. <body>
  6. <p>LibRaw C++ API<a href="index.html">[back to Index]</a></p>
  7. <h1>LibRaw C++ API</h1>
  8. <p>Contents</p>
  9. <ol>
  10. <li><a href="#LibRaw">LibRaw Objects</a></li>
  11. <li><a href="#return">Returned values</a></li>
  12. <li><a href="#dataload">Methods Loading Data from a File</a>
  13. <ul>
  14. <li><a href="#open_datastream">int
  15. LibRaw::open_datastream(LibRaw_abstract_datastream *stream)</a></li>
  16. <li><a href="#open_file">int LibRaw::open_file(const char
  17. *rawfile[,INT64 bigfile_size])</a></li>
  18. <li><a href="#open_buffer">int LibRaw::open_buffer(void *buffer,
  19. size_t bufsize)</a></li>
  20. <li><a href="#open_bayer">int LibRaw::open_bayer(...)</a></li>
  21. <li><a href="#unpack">int LibRaw::unpack(void)</a></li>
  22. <li><a href="#unpack_thumb">int LibRaw::unpack_thumb(void)</a></li>
  23. </ul>
  24. </li>
  25. <li><a href="#utility">Auxiliary Functions</a>
  26. <ul>
  27. <li>Library version info
  28. <ul>
  29. <li><a href="#version">const char* LibRaw::version()</a></li>
  30. <li><a href="#versionNumber">int LibRaw::versionNumber()</a></li>
  31. <li><a href="#LIBRAW_CHECK_VERSION">bool
  32. LIBRAW_CHECK_VERSION(major,minor,patch)</a></li>
  33. </ul>
  34. </li>
  35. <li>List of supported cameras
  36. <ul>
  37. <li><a href="#cameraCount">int LibRaw::cameraCount()</a></li>
  38. <li><a href="#cameraList">const char** LibRaw::cameraList()</a></li>
  39. </ul>
  40. </li>
  41. <li><a href="#set_rawspeed_camerafile">int
  42. LibRaw::set_rawspeed_camerafile(char *path_to_cameras_xml)</a></li>
  43. <li><a href="#get_decoder_info">int
  44. LibRaw::get_decoder_info(libraw_decoder_info_t *)</a></li>
  45. <li><a href="#unpack_function_name">const char*
  46. LibRaw::unpack_function_name()</a></li>
  47. <li><a href="#COLOR">int LibRaw::COLOR()</a></li>
  48. <li><a href="#error_count">int LibRaw::error_count()</a></li>
  49. <li><a href="#setCancelFlag">void LibRaw::setCancelFlag()</a></li>
  50. <li><a href="#clearCancelFlag">void LibRaw::clearCancelFlag()</a></li>
  51. <li><a href="#subtract_black">int LibRaw::subtract_black()</a></li>
  52. <li><a href="#adjust_to_raw_inset_crop">int
  53. LibRaw::adjust_to_raw_inset_crop()</a></li>
  54. <li><a href="#floatingpoint">Support for Floating Point data</a></li>
  55. <li><a href="#ycc">Support for YCC formats</a></li>
  56. <li><a href="#recycle">void LibRaw::recycle_datastream(void)</a></li>
  57. <li><a href="#recycle">void LibRaw::recycle(void)</a></li>
  58. <li><a href="#%7ELibRaw">LibRaw::~LibRaw()</a></li>
  59. <li><a href="#strprogress">const char* LibRaw::strprogress(enum
  60. LibRaw_progress code)</a></li>
  61. <li><a href="#libraw_strerror">const char* LibRaw::strerror(int
  62. errorcode)</a></li>
  63. <li><a href="#callbacks">Setting Error Notification Functions and
  64. other callbacks</a>
  65. <ul>
  66. <li><a href="#progress">User callback for progress
  67. indication/interruption</a></li>
  68. <li><a href="#exif">User callback for exif/makernotes parser
  69. routines</a></li>
  70. <li><a href="#memerror">Out-of-Memory Notifier</a></li>
  71. <li><a href="#dataerror">File Read Error Notifier</a></li>
  72. </ul>
  73. </li>
  74. </ul>
  75. </li>
  76. <li><a href="#dcrawemu">Data Postprocessing: Emulation of dcraw Behavior</a>
  77. <ul>
  78. <li><a href="#dcraw_params">Parameter Setting</a></li>
  79. <li><a href="#raw2image">int LibRaw::raw2image</a></li>
  80. <li><a href="#free_image">void LibRaw::free_image</a></li>
  81. <li><a href="#adjust_sizes_info_only">int
  82. LibRaw::adjust_sizes_info_only(void)</a></li>
  83. <li><a href="#dcraw_process">int LibRaw::dcraw_process(void)</a></li>
  84. </ul>
  85. </li>
  86. <li><a href="#dcrawrite">Data Output to Files: Emulation of dcraw Behavior</a>
  87. <ul>
  88. <li><a href="#dcraw_ppm_tiff_writer">int
  89. LibRaw::dcraw_ppm_tiff_writer(const char *outfile)</a></li>
  90. <li><a href="#dcraw_thumb_writer">int LibRaw::dcraw_thumb_writer(const
  91. char *thumbfile)</a></li>
  92. </ul>
  93. </li>
  94. <li><a href="#memwrite">Copying unpacked data into memory buffer</a>
  95. <ul>
  96. <li><a href="#get_mem_image_format">void get_mem_image_format(int
  97. *widthp, int *heightp, int *colorsp, int *bpp)</a></li>
  98. <li><a href="#copy_mem_image">int LibRaw::copy_mem_image(void* scan0,
  99. int stride, int bgr)</a></li>
  100. <li><a href="#dcraw_make_mem_image">libraw_processed_image_t
  101. *dcraw_make_mem_image(int *errorcode)</a></li>
  102. <li><a href="#dcraw_make_mem_thumb">libraw_processed_image_t
  103. *dcraw_make_mem_thumb(int *errorcode)</a></li>
  104. <li><a href="#dcraw_clear_mem">void
  105. LibRaw::dcraw_clear_mem(libraw_processed_image_t *)</a></li>
  106. </ul>
  107. </li>
  108. <li><a href="#datastream">Input layer abstraction</a>
  109. <ul>
  110. <li><a href="LibRaw_abstract_datastream">class
  111. LibRaw_abstract_datastream - abstract RAW read interface</a><a href="#datastream_methods">LibRaw_abstract_datastream
  112. class methods</a>
  113. <ul>
  114. <li><a href="#datastream_methods_utility">Object verification</a></li>
  115. <li><a href="#datastream_methods_read">Stream read and positioning</a></li>
  116. <li><a href="#datastream_methods_other">Other methods</a></li>
  117. </ul>
  118. </li>
  119. <li><a href="#datastream_derived">Derived input classes included in
  120. LibRaw</a>
  121. <ul>
  122. <li><a href="#file_datastream">class LibRaw_file_datastream - file
  123. input interface</a></li>
  124. <li><a href="#bigfile_datastream">class LibRaw_file_datastream -
  125. file input interface for large files</a></li>
  126. <li><a href="#buffer_datastream">class LibRaw_buffer_datastream -
  127. input from memory buffer</a></li>
  128. </ul>
  129. </li>
  130. <li><a href="#own_datastreams">Own datastream derived classes</a>
  131. <ul>
  132. <li><a href="#substream">substream field: secondary input stream</a></li>
  133. </ul>
  134. </li>
  135. </ul>
  136. </li>
  137. </ol>
  138. <p><a name="LibRaw"></a></p>
  139. <h2>LibRaw Objects</h2>
  140. <p>The main LibRaw object (class) is created either without parameters or
  141. with flags determining the object behavior.</p>
  142. <pre>#include "libraw/libraw.h"<br>...<br><br> LibRaw ImageProcessor(unsigned int flags=0);<br>...<br> </pre>
  143. <p>Flags (several flags are combined via operator |, i.e., bitwise OR):</p>
  144. <ul>
  145. <li><strong>LIBRAW_OPTIONS_NO_MEMERR_CALLBACK</strong>: do not set the
  146. standard <a href="#callbacks">out-of-memory error handler</a> (standard
  147. handler outputs the error report in stderr);</li>
  148. <li><strong>LIBRAW_OPTIONS_NO_DATAERR_CALLBACK</strong>: do not set the
  149. standard <a href="#callbacks">file read error handler</a> (standard
  150. handler outputs the error report in stderr).</li>
  151. </ul>
  152. <p>Three groups of methods are used for image processing</p>
  153. <ul>
  154. <li><a href="#dataload">Data loading from the RAW file</a></li>
  155. <li><a href="#dcrawemu">Postprocessing functions emulating the dcraw
  156. behavior</a></li>
  157. <li><a href="#dcrawrite">File output functions emulating the dcraw
  158. behavior</a>.</li>
  159. </ul>
  160. <p>The results of processing are placed in the imgdata field of type <a href="API-datastruct.html">libraw_data_t</a>;
  161. the same data set contains fields that control the postprocessing and
  162. output.</p>
  163. <p><a name="return"></a></p>
  164. <h2>Returned Values</h2>
  165. <p>All LibRaw API functions return an integer number in accordance with the
  166. <a href="API-notes.html#errors">return code convention</a>. Please read
  167. the descriptions of <a href="API-notes.html#errors">this convention</a>
  168. and <a href="#callbacks">LibRaw behavior in cases of fatal errors</a>.</p>
  169. <p><a name="dataload"></a></p>
  170. <h2>Methods Loading Data from a File</h2>
  171. <p><a name="open_datastream"></a></p>
  172. <h3>int LibRaw::open_datastream(LibRaw_abstract_datastream *stream)</h3>
  173. <p>Opens a datastream with RAW data, reads metadata (EXIF) from it, and
  174. fills the following structures:</p>
  175. <ul>
  176. <li>imgdata.idata (<a href="API-datastruct.html#libraw_iparams_t">libraw_iparams_t</a>),</li>
  177. <li>imgdata.sizes (<a href="API-datastruct.html#libraw_image_sizes_t">libraw_image_sizes_t</a>),</li>
  178. <li>imgdata.color (<a href="API-datastruct.html#libraw_colordata_t">libraw_colordata_t</a>),</li>
  179. <li>imgdata.other (<a href="API-datastruct.html#libraw_imgother_t">libraw_imgother_t</a>),
  180. and</li>
  181. <li>imgdata.thumbnail (<a href="API-datastruct.html#libraw_thumbnail_t">libraw_thumbnail_t</a>).</li>
  182. </ul>
  183. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  184. code convention</a>: positive if any system call has returned an error,
  185. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  186. error list</a>) if there has been an error situation within LibRaw.</p>
  187. <p>Before file opening, <a href="#recycle">recycle()</a> is always called;
  188. hence, if several images are processed in the batch mode, there is no need
  189. to call recycle() at the end of each processing cycle.</p>
  190. <p><strong>Input data</strong>: pointer to object, derived from <a href="#datastream">LibRaw_abstract_datastream</a>
  191. class. This object should be initialized and ready to read. This object
  192. should be destroyed in calling application after use.</p>
  193. <p><a name="open_file"></a></p>
  194. <h3>int LibRaw::open_file(const char *filename[,INT64 bigfile_size])</h3>
  195. <h3>Win32 only: int LibRaw::open_file(const wchar_t *filename[,INT64
  196. bigfile_size])</h3>
  197. <p>Creates an <a href="#file_datastream">LibRaw_file_datastream</a> object,
  198. calls <a href="#open_datastream">open_datastream()</a>. If succeed, sets
  199. internal flag which signals to destroy internal datastream object on <a href="#recycle">recycle()</a>.
  200. On failure, just created file_datastream destroyed immediately.</p>
  201. <p>Second optional parameter <strong>bigfile_size</strong> controls
  202. background I/O interface used for file operations. For files smaller than
  203. bigfile_size the <a href="#file_datastream">LibRaw_file_datastream</a>
  204. will be used and the <a href="#bigfile_datastream">LibRaw_bigfile_datastream</a>
  205. otherwise.</p>
  206. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  207. code convention</a>: positive if any system call has returned an error,
  208. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  209. error list</a>) if there has been an error situation within LibRaw.</p>
  210. <p><a name="open_buffer"></a></p>
  211. <h3>int LibRaw::open_buffer(void *buffer, size_t bufsize)</h3>
  212. <p>Created an <a href="#buffer_datastream">LibRaw_buffer_datastream</a>
  213. object, calls <a href="#open_datastream">open_datastream()</a>. If
  214. succeed, sets internal flag which signals to destroy internal datastream
  215. object on <a href="#recycle">recycle()</a>. On failure, just created
  216. file_datastream destroyed immediately.</p>
  217. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  218. code convention</a>: positive if any system call has returned an error,
  219. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  220. error list</a>) if there has been an error situation within LibRaw.</p>
  221. <p><a name="open_bayer"></a></p>
  222. <h3>int LibRaw::open_bayer(unsigned char *data, unsigned datalen, ushort
  223. _raw_width, ushort _raw_height, ushort _left_margin, ushort _top_margin,
  224. ushort _right_margin, ushort _bottom_margin, unsigned char procflags,
  225. unsigned char bayer_pattern, unsigned unused_bits, unsigned otherflags,
  226. unsigned black_level)</h3>
  227. <p>Parameters: </p>
  228. <ul>
  229. <li>data, datalen - buffer passed </li>
  230. <li>_raw_width/_raw_height/*margin - image size and margins </li>
  231. <li> procflags:
  232. <ul>
  233. <li>for 10-bit format:
  234. <ul>
  235. <li>1: "4 pixels in 5 bytes" packing is used </li>
  236. <li>0: "6 pixels in 8 bytes" packing is used </li>
  237. </ul>
  238. </li>
  239. <li>for 16-bit format:
  240. <ul>
  241. <li>1: Big-endian data </li>
  242. </ul>
  243. </li>
  244. </ul>
  245. </li>
  246. <li>bayer_pattern: one of LIBRAW_OPENBAYER_RGGB,LIBRAW_OPENBAYER_BGGR,
  247. LIBRAW_OPENBAYER_GRBG,LIBRAW_OPENBAYER_GBRG </li>
  248. <li>unused_bits: count of upper zero bits </li>
  249. <li>otherflags:
  250. <ul>
  251. <li>Bit 1 - filter (average neighbors) for pixels with values of zero
  252. </li>
  253. <li>Bits 2-4 - the orientation of the image (0=do not rotate, 3=180,
  254. 5=90CCW, 6=90CW) </li>
  255. </ul>
  256. </li>
  257. <li>black_level: file black level (it also may be specified via
  258. imgdata.params) </li>
  259. </ul>
  260. See samples/openbayer_sample.cpp for usage sample (note, this sample is
  261. 'sample only', suited for Kodak KAI-0340 sensor, you'll need change
  262. open_bayer() params for your data).
  263. <p><a name="unpack"></a></p>
  264. <h3>int LibRaw::unpack(void)</h3>
  265. <p>Unpacks the RAW files of the image, calculates the black level (not for
  266. all formats). The results are placed in imgdata.image.</p>
  267. <p>Data reading is sometimes (not frequently) affected by settings made in
  268. imgdata.params (<a href="API-datastruct.html#libraw_output_params_t">libraw_output_params_t</a>);
  269. see <a href="API-notes.html">API notes</a> for details.</p>
  270. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  271. code convention</a>: positive if any system call has returned an error,
  272. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  273. error list</a>) if there has been an error situation within LibRaw.</p>
  274. <p><a name="unpack_thumb"></a></p>
  275. <h3>int LibRaw::unpack_thumb(void)</h3>
  276. <p>Reads (or unpacks) the image preview (thumbnail), placing the result into
  277. the imgdata.thumbnail.thumb buffer.<br>
  278. JPEG previews are placed into this buffer without any changes (with the
  279. header etc.). Other preview formats are placed into the buffer in the form
  280. of the unpacked bitmap image (three components, 8 bits per component).<br>
  281. The thumbnail format is written to the imgdata.thumbnail.tformat field;
  282. for the possible values, see <a href="API-datastruct.html#LibRaw_thumbnail_formats">description
  283. of constants and data structures</a>.</p>
  284. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  285. code convention</a>: positive if any system call has returned an error,
  286. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  287. error list</a>) if there has been an error situation within LibRaw.</p>
  288. <p><a name="utility"></a></p>
  289. <h2>Auxiliary Functions</h2>
  290. <h3>Library version check</h3>
  291. <p><a name="version"></a></p>
  292. <h4>const char* LibRaw::version()</h4>
  293. <p>Returns string representation of LibRaw version in
  294. MAJOR.MINOR.PATCH-Status format (i.e. 0.6.0-Alpha2 or 0.6.1-Release).</p>
  295. <p><a name="versionNumber"></a></p>
  296. <h4>int LibRaw::versionNumber()</h4>
  297. <p>Returns integer representation of LibRaw version. During LibRaw
  298. development, the version number is always increase .</p>
  299. <p><a name="LIBRAW_CHECK_VERSION"></a></p>
  300. <h4>bool LIBRAW_CHECK_VERSION(major,minor,patch)</h4>
  301. <p>Macro for version check in caller applications. Returns 'true' if current
  302. library version is greater or equal to set in macro parameters. This macro
  303. executes at runtime (not at compile time) and may be used for checking
  304. version of dynamically loaded LibRaw (from DLL/shared library).</p>
  305. <h3>List of supported RAW formats (cameras)</h3>
  306. <p><a name="cameraCount"></a></p>
  307. <h4>int LibRaw::cameraCount()</h4>
  308. <p>Returns count of cameras supported.</p>
  309. <p><a name="cameraList"></a></p>
  310. <h4>const char** LibRaw::cameraList()</h4>
  311. <p>Returns list of supported cameras. Latest item of list is set to NULL
  312. (for easy printing).</p>
  313. <p><a name="#set_rawspeed_camerafile"></a></p>
  314. <h4>int LibRaw::set_rawspeed_camerafile(char *path_to_cameras_xml)</h4>
  315. <p>(Only if LibRaw was built with RawSpeed support).</p>
  316. <p>Loads XML file with RawSpeed camera description data (cameras.xml)
  317. specified by path_to_cameras_xml. Returns 0 on success, nonzero on error.
  318. <a name="get_decoder_info"></a></p>
  319. <h4>int LibRaw::get_decoder_info(libraw_decoder_info_t *)</h4>
  320. <p>The function fills <a href="API-datastruct.html#libraw_decoder_info_t">libraw_decoder_info_t</a>
  321. structure by passed pointer with current raw decoder data.</p>
  322. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  323. code convention</a>: positive if any system call has returned an error,
  324. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  325. error list</a>) if there has been an error situation within LibRaw.</p>
  326. <p><a name="unpack_function_name"></a></p>
  327. <h3>const char* LibRaw::unpack_function_name()</h3>
  328. <p>Returns function name of file unpacking function. Intended only for
  329. LibRaw test suite designers to use in test coverage evaluation.</p>
  330. <p><a name="setCancelFlag"></a></p>
  331. <h4>void LibRaw::setCancelFlag()</h4>
  332. <p>This call sets internal fast cancel flags. If set, current Raw decoder
  333. will be terminated ASAP. This call is useful if you need to cancel all
  334. LibRaw decoders in multithreaded program (e.g. for fast program
  335. termination or just for cancel current processing).</p>
  336. <p><a name="clearCancelFlag"></a></p>
  337. <h4>void LibRaw::clearCancelFlag()</h4>
  338. <p>This call clears internal fast cancel flags, so (early) terminated LibRaw
  339. decoder may work again.</p>
  340. <p><a name="COLOR"></a></p>
  341. <h4>int LibRaw::COLOR(int row, int col)</h4>
  342. <p>This call returns pixel color (color component number) in bayer patter at
  343. row,col. The returned value is in 0..3 range for 4-component Bayer (RGBG2,
  344. CMYG and so on) and in 0..2 range for 3-color data.</p>
  345. <p>Color indexes returned could be used as index in imgdata.idata.cdesc
  346. string to get color 'name'.</p>
  347. <p><a name="error_count"></a></p>
  348. <h4>int LibRaw::error_count()</h4>
  349. <p>This call returns count of non-fatal data errors (out of range, etc)
  350. occured in unpack() stage.</p>
  351. <p><a name="subtract_black"></a></p>
  352. <h4>int LibRaw::subtract_black()</h4>
  353. <p>This call will subtract black level values from RAW data (for suitable
  354. RAW data). <a href="API-datastruct.html#libraw_colordata_t">colordata.data_maximum</a>
  355. and <strong>colordata.maximum</strong> and black level data (<a href="API-datastruct.html#libraw_colordata_t">colordata.black</a>
  356. and colordata.cblack) will be adjusted too.</p>
  357. <p>This call should be used if you postprocess RAW data by your own code.
  358. LibRaw <a href="#dcrawemu">postprocessing functions</a> will call <strong>subtract_black()</strong>
  359. by oneself.</p>
  360. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  361. code convention</a>: positive if any system call has returned an error,
  362. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  363. error list</a>) if there has been an error situation within LibRaw.</p>
  364. <a name="adjust_to_raw_inset_crop"></a>
  365. <h4>int LibRaw::adjust_to_raw_inset_crop(unsigned mask, float maxcrop =
  366. 0.55f)</h4>
  367. <p> Promotes imgdata.sizes.raw_inset_crops[] values to imgdata.sizes.*margin
  368. and imgdata.sizes.width/height fields</p>
  369. <p> Parameters<br>
  370. mask: </p>
  371. <ul>
  372. <li>if bit 1 is set: prefer raw_inset_crops[1] </li>
  373. <li>if bit 0 is set: prefer raw_inset_crops[0] </li>
  374. </ul>
  375. <p>maxcrop: limits crop to not less than (original width/height)*maxcrop; if
  376. raw_inset_crops[i] data results in tighter crop, than this item is
  377. ignored. </p>
  378. <p>return value: index in raw_inset_crops[] used increased by one, so </p>
  379. <ul>
  380. <li>0: no changes made </li>
  381. <li>1: [0]th data used </li>
  382. <li>2: [1]th data used </li>
  383. </ul>
  384. <p>Note: this call SHOULD be used after LibRaw::unpack(), otherwise black
  385. level calculation from masked area may be fooled resulting in wrong black
  386. levels. </p>
  387. <p><a name="floatingpoint"></a></p>
  388. <h4>Support for floating point data</h4>
  389. <p>Libraw can read floating point DNG files (no other RAW formats may use
  390. floating point) with or without conversion to integer data. Floating point
  391. values are stored in imgdata.rawdata buffers:</p>
  392. <ul>
  393. <li><span style="font-family: monospace;">float * float_image</span> (if
  394. not NULL) points to floating point bayer data</li>
  395. <li><span style="font-family: monospace;">float (*float3_image)[3]</span>
  396. (if not NULL) points to floating point 3-channel buffer</li>
  397. <li><span style="font-family: monospace;">float (*float4_image)[4]</span>
  398. (if not NULL) points to floating point 4-channel buffer</li>
  399. </ul>
  400. <p>Function calls for floating point support:</p>
  401. <ul>
  402. <li><span style="font-family: monospace;">int LibRaw::is_floating_point();
  403. </span>function will return 1 if file contains floating point data</li>
  404. <li><span style="font-family: monospace;">int LibRaw::have_fpdata();</span>
  405. function will return 1 if FP data has read (decoded) into memory and not
  406. converted to integer data</li>
  407. <li>int LibRaw::convertFloatToInt(float dmin=4096.f, float dmax=32767.f,
  408. float dtarget = 16383.f) converts floating point data to integer. If
  409. data maximum is out of dmin..dmax range, than data scaled to set maximum
  410. to dtarget</li>
  411. </ul>
  412. <p><a name="ycc"></a></p>
  413. <h4>Support for YCC formats (Canon sRAW/mRAW and Nikon Small NEF)</h4>
  414. <pre> int LibRaw::is_sraw();<br> int LibRaw::is_nikon_sraw();<br> int LibRaw::sraw_midpoint()</pre>
  415. <ul>
  416. <li>is_sraw() call returns nonzero if current image is YCC-based.</li>
  417. <li>is_nikon_sraw() call returns nonzero for Nikon Small NEF files</li>
  418. <li>sraw_midpoint() call returns neutral (gray) point for color channels</li>
  419. </ul>
  420. <p><a name="recycle_datastream"></a></p>
  421. <h4>void LibRaw::set_dng_host(void* p)</h4>
  422. <p>If LibRaw is compiled with Adobe DNG SDK support and you wish to use this
  423. support:</p>
  424. <ul>
  425. <li>you need to create own dng_host object</li>
  426. <li>and pass it to LibRaw object using this function</li>
  427. </ul>
  428. <h4>void LibRaw::recycle_datastream(void)</h4>
  429. <p>This call closes input datastream with associated data buffer and
  430. unblocks opened file. <a name="recycle"></a></p>
  431. <h3>void LibRaw::recycle(void)</h3>
  432. <p>Frees the allocated data of LibRaw instance, enabling one to process the
  433. next file using the same processor. Repeated calls of recycle() are quite
  434. possible and do not conflict with anything.</p>
  435. <p><a name="~LibRaw"></a></p>
  436. <h3>LibRaw::~LibRaw()</h3>
  437. <p>Destructor, which consists in calling recycle().</p>
  438. <p><a name="strprogress"></a></p>
  439. <h3>const char* LibRaw::strprogress(enum LibRaw_progress code)</h3>
  440. <p>Converts progress stage code to description string (in English).</p>
  441. <p><a name="libraw_strerror"></a></p>
  442. <h3>const char* LibRaw::strerror(int errorcode)</h3>
  443. <p>Analog of strerror(3) function: outputs the text descriptions of LibRaw
  444. error codes (in English).</p>
  445. <p><a name="callbacks"></a></p>
  446. <h3>Setting Error Notification Functions</h3>
  447. <p>In process of RAW conversion LibRaw can call user-setted callback. This
  448. callback can be used for:</p>
  449. <ul>
  450. <li>Dynamic status update (progress bar and so on).</li>
  451. <li>Cancel of processing (for example, user pressed Cancel button).</li>
  452. </ul>
  453. <p>Also, work of the library may cause two types of exceptional situations
  454. that require notification of the calling application:</p>
  455. <ul>
  456. <li>Memory shortage</li>
  457. <li>Data read error.</li>
  458. </ul>
  459. <p>An application may set its own callbacks that will be called in the cases
  460. mentioned above to notify the user (or the calling program).</p>
  461. <p><a name="progress"></a></p>
  462. <h4>Progress indication/processing termination</h4>
  463. <pre> typedef int (*progress_callback)(void *callback_data,enum LibRaw_progress stage, int iteration, int expected);<br> void LibRaw::set_progress_handler(progress_callback func,void *callback_data);<br> </pre>
  464. <p>LibRaw user can set own callback which will be called 10-50 times during
  465. RAW postprocessing by dcraw_process().</p>
  466. <p>This callback may terminate current image processing by returning of
  467. non-zero value. In such case all processing will be cancelled immediately
  468. and all resources will be returned to system by recycle() call. Current
  469. call of dcraw_process() will return error code
  470. LIBRAW_CANCELLED_BY_CALLBACK.</p>
  471. <p>Callback parameters:</p>
  472. <dl>
  473. <dt>void *callback_data</dt>
  474. <dd>void*-pointer, passed as 2nd argument to set_progress_handler(). This
  475. pointer should be used to pass additional data to callback (i.e. thread
  476. local data and so on).</dd>
  477. <dt>enum LibRaw_progress stage</dt>
  478. <dd>Current processing stage. This number can be converted to string by
  479. call to <a href="#strprogress">LibRaw::strprogress</a>. Not all
  480. processing stages are covered by callback calls.</dd>
  481. <dt>int iteration</dt>
  482. <dd>Iteration number within current stage (from 0 to expected-1).</dd>
  483. <dt>int expected</dt>
  484. <dd>Expected number of iterations on current stage.</dd>
  485. </dl>
  486. <p>Callback should return value of: <strong>0</strong> for continue
  487. processing and <strong>non-zero</strong> for immediate cancel of
  488. processing.</p>
  489. <p>&nbsp;</p>
  490. <p>If LibRaw compiled with OpenMP support, iteration parameter may not
  491. always increase within one stage. Out of order callback calls are
  492. possible.</p>
  493. <p>Callback code sample:</p>
  494. <pre>int my_progress_callback(void *data,enum LibRaw_progress p,int iteration, int expected)<br>{<br> char *passed_string = (char *data);<br> printf("Callback: %s pass %d of %d, data passed: %s\n",libraw_strprogress(p),iteration,expected,passed_string);<br> if(timeout || key_pressed )<br> return 1; // cancel processing immediately<br> else<br> return 0; // can continue<br>}</pre>
  495. <p><a name="exif"></a></p>
  496. <h4>User-specified exif tag parser callback</h4>
  497. <pre> typedef void (*exif_parser_callback) (void *context, int tag, int type, int len,unsigned int ord, void *ifp);<br> void LibRaw::set_exifparser_handler( exif_parser_callback cb,void *context);<br> </pre>
  498. <p>Callback to be called on each parsed EXIF/Makernotes tag with parameters:</p>
  499. <ul>
  500. <li>context - pointer to context passed to set_exifparser_handler();</li>
  501. <li>tag - EXIF/Makernotes tag value</li>
  502. <li>type - TIFF(EXIF) tag type</li>
  503. <li>len - tag length</li>
  504. <li>ord - byte order (II or MM)</li>
  505. <li>void *ifp - pointer to LibRaw_abstract_datastream, positioned to tag
  506. data</li>
  507. </ul>
  508. <p><a name="memerror"></a></p>
  509. <h4>Out-of-Memory Notifier</h4>
  510. <pre> typedef void (* memory_callback)(void *callback_data,const char *file, const char *where);<br> void LibRaw::set_memerror_handler(memory_callback func,void *callback_data);<br> </pre>
  511. <p>The user may set his or her own function called in the case of memory
  512. shortage. It is a void function receiving two string parameters:</p>
  513. <ul>
  514. <li><strong>void *callback_data</strong> - void*-pointer, passed as 2nd
  515. argument to set_progress_handler(). This pointer should be used to pass
  516. additional data to callback (i.e. thread local data and so on).</li>
  517. <li><strong>file</strong> is the name of the RAW file whose processing
  518. evoked the out-of-memory error. This name <strong>can be NULL</strong>
  519. if underlying data input layer does not know the name. So, if calling
  520. application sets own callback, this callback should work with NULL file
  521. name.</li>
  522. <li><strong>where</strong> is the name of the function where memory
  523. shortage occurred.</li>
  524. </ul>
  525. <p>The callback function is intended for information purposes: it notifies
  526. the user or the program code that processing is impossible.</p>
  527. <p>If the user does not set his or her own handler, the standard one (output
  528. of error message in stderr) will be used.</p>
  529. <p>One can set the null handler by passing NULL to set_memerror_handler;
  530. then no notifier function will be called. The same effect can be achieved
  531. by creating a LibRaw object with the LIBRAW_OPTIONS_NO_MEMERR_CALLBACK
  532. flag in the contructor.</p>
  533. <p>In the case of memory shortage, processing of the current file is
  534. terminated and a notifier is called; all allocated resources are freed,
  535. and <a href="#recycle">recycle()</a> is performed. The current call will
  536. return LIBRAW_UNSUFFICIENT_MEMORY. <br>
  537. At an attempt to continue data processing, all subsequent calls will
  538. return LIBRAW_OUT_OF_ORDER_CALL. Processing of a new file may be started
  539. in the usual way, by calling LibRaw::open_file().</p>
  540. <p><a name="dataerror"></a></p>
  541. <h4>File Read Error Notifier</h4>
  542. <pre> typedef void (*data_callback)(void *callback_data,const char *file, const int offset);<br> void LibRaw::set_dataerror_handler(data_callback func, void *callback_data); <br> </pre>
  543. <p>The user can define his or her own function to be called in the case of
  544. error in the input data. It is a void function receiving two parameters:</p>
  545. <ul>
  546. <li><strong>void *callback_data</strong> - void*-pointer, passed as 2nd
  547. argument to set_progress_handler(). This pointer should be used to pass
  548. additional data to callback (i.e. thread local data and so on).</li>
  549. <li><strong>file</strong> is the name of the RAW file whose processing
  550. evoked the file read error. This name <strong>can be NULL</strong> if
  551. underlying data input layer does not know the name. So, if calling
  552. application sets own callback, this callback should work with NULL file
  553. name.</li>
  554. <li><strong>offset</strong> is -1 at end-of-file (if LibRaw expects more
  555. data) or a positive number equal to the file position (bytes from file
  556. beginning) where the unpacking error occurred.</li>
  557. </ul>
  558. <p>The callback function is intended for information purposes: it notifies
  559. the user or the program code that processing is impossible.</p>
  560. <p>If the user does not set his or her own handler, the standard one (output
  561. of error message in stderr) will be used.</p>
  562. <p>One can set the null handler by passing NULL to set_memerror_handler;
  563. then no notifier function will be called. The same effect can be achieved
  564. by creating a LibRaw object with the LIBRAW_OPTIONS_NO_DATAERR_CALLBACK
  565. flag in the contructor.</p>
  566. <p>In the case of error in the input data, processing of the current file is
  567. terminated and a notifier is called; all allocated resources are freed,
  568. and <a href="#recycle">recycle()</a> is performed. The current call will
  569. return LIBRAW_IO_ERROR. <br>
  570. At an attempt to continue data processing, all subsequent calls will
  571. return LIBRAW_OUT_OF_ORDER_CALL. Processing of a new file may be started
  572. in the usual way, by calling LibRaw::open_file().</p>
  573. <p><a name="dcrawemu"></a></p>
  574. <h2>Data Postprocessing: Emulation of dcraw Behavior</h2>
  575. <p>Instead of writing one's own Bayer pattern postprocessing, one can use
  576. the dcraw functions, which are called after the calls of open_file() +
  577. unpack() /+ unpack_thumb()/</p>
  578. <p><a name="dcraw_params"></a></p>
  579. <h3>Parameter Setting</h3>
  580. <p>Virtually all parameters that can be set through the dcraw command line
  581. are specified by assigning values to fields of the <strong>LibRaw::imgdata.params</strong>
  582. structure. The type of this structure is <strong>libraw_output_params_t</strong>;
  583. all fields are listed and described in sufficient detail in the <a href="API-datastruct.html#libraw_output_params_t">description
  584. of data structures</a>.</p>
  585. <p><a name="raw2image"></a></p>
  586. <h3>int LibRaw::raw2image</h3>
  587. <p>This function allocates buffer for postprocessing (imgdata.image) and
  588. fills it with data layout compatible with LibRaw 0.13/0.14 and below. If
  589. the buffer is already allocated, it will be free()ed and allocated again.</p>
  590. <p>This function should be called only if your code do postprocessing stage.
  591. If you use LibRaw's postprocessing calls (see below) you don't need to
  592. call raw2image().</p>
  593. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">return
  594. code convention</a>: positive if any system call has returned an error,
  595. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  596. error list</a>) if there has been an error situation within LibRaw.</p>
  597. <p><a name="free_image"></a></p>
  598. <h3>void LibRaw::free_image</h3>
  599. <p>This function releases the imgdata.image buffer allocated by raw2image();</p>
  600. <p>This method should be called if current postprocessing results are not
  601. needed by the program (e.g. already copied somewhere), but new
  602. postprocessing calls (with another settings) are possible, so it is to
  603. early to call <a href="#recycle">recycle()</a>.</p>
  604. <p><a name="adjust_sizes_info_only"></a></p>
  605. <h3>int LibRaw::adjust_sizes_info_only(void)</h3>
  606. <p>The function calculates the correct size of the output image
  607. (imgdata.sizes.iwidth and imgdata.sizes.iheight) for the following cases:</p>
  608. <ul>
  609. <li>Files from Fuji cameras (with a 45-degree rotation)</li>
  610. <li>Files from cameras with non-square pixels</li>
  611. <li>Images shot by a rotated camera.</li>
  612. </ul>
  613. <p>In the aforementioned cases, the function changes the fields of the image
  614. output size; note that this change cannot be repeated again.</p>
  615. <p><a name="dcraw_process"></a></p>
  616. <h3>int LibRaw::dcraw_process(void)</h3>
  617. <p>The function emulates the postprocessing capabilities available in <strong>dcraw</strong>.<br>
  618. Called after calling LibRaw::unpack();</p>
  619. <p>The entire functionality of dcraw (set via the field values in <a href="API-datastruct.html#libraw_output_params_t">imgdata.params</a>)
  620. is supported, except for</p>
  621. <ul>
  622. <li>Dark frame subtraction</li>
  623. <li>Work with bad pixels.</li>
  624. </ul>
  625. <p>The function is intended solely for demonstration and testing purposes;
  626. it is assumed that its source code will be used in most real applications
  627. as the reference material concerning the order of RAW data processing.</p>
  628. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">error
  629. code convention</a>: positive if any system call has returned an error,
  630. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  631. error list</a>) if there has been an error situation within LibRaw.</p>
  632. <p><a name="dcrawrite"></a></p>
  633. <h2>Data Output to Files: Emulation of dcraw Behavior</h2>
  634. <p>In spite of the abundance of libraries for file output in any formats,
  635. LibRaw includes calls that emulate the file output provided by dcraw. This
  636. is done primarily for easier verification of library work: the resultant
  637. files must be binary identical.</p>
  638. <p><a name="dcraw_ppm_tiff_writer"></a></p>
  639. <h3>int LibRaw::dcraw_ppm_tiff_writer(const char *outfile)</h3>
  640. <p>The function outputs the postprocessing results to a file in the PPM/PGM
  641. or TIFF format (the format is set via imgdata.params.output_tiff). The
  642. results are binary identical to those provided by dcraw.</p>
  643. <p>If "-" is passed as outfile, the function will write to standard output
  644. (stdout).</p>
  645. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">error
  646. code convention</a>: positive if any system call has returned an error,
  647. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  648. error list</a>) if there has been an error situation within LibRaw.</p>
  649. <p><a name="dcraw_thumb_writer"></a></p>
  650. <h3>int LibRaw::dcraw_thumb_writer(const char *thumbfile)</h3>
  651. <p>Writes the thumbnail to a file in the PPM format for bitmap thumbnails
  652. and in the JPEG format for JPEG thumbnails, i.e., in the format completely
  653. identical to the results provided by dcraw.</p>
  654. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">error
  655. code convention</a>: positive if any system call has returned an error,
  656. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  657. error list</a>) if there has been an error situation within LibRaw.</p>
  658. <p><a name="memwrite"></a></p>
  659. <h2>Copying unpacked data into memory buffer</h2>
  660. <p>There is several function calls for store unpacked data into memory
  661. buffer (after using dcraw_process() and so on):</p>
  662. <ul>
  663. <li><strong>get_mem_image_format</strong> - get resulting bitmap size and
  664. bit depth.</li>
  665. <li><strong>copy_mem_image</strong> - copy postprocessed data into some
  666. memory buffer with different color order and line stride.</li>
  667. <li><strong>dcraw_make_mem_image</strong> - store processed image data
  668. into allocated buffer;</li>
  669. <li><strong>dcraw_make_mem_thumb</strong> - store extracted thumbnail into
  670. buffer as JPEG-file image (for most cameras) or as RGB-bitmap.</li>
  671. </ul>
  672. <p>For usage primer see samples/mem_image.c sample.</p>
  673. <p>&nbsp;</p>
  674. <p><a name="get_mem_image_format"></a></p>
  675. <h3>void get_mem_image_format(int *widthp, int *heightp, int *colorsp, int
  676. *bpp) const - return processing bitmap size</h3>
  677. <p>This function returns size of postprocessed image:</p>
  678. <ul>
  679. <li>Image width is returned in *widthp;</li>
  680. <li>Bitmap height is returned in *heightp;</li>
  681. <li>Image color count is returned in *colorsp;</li>
  682. <li>Bits per pixel (8 or 16) is returned in *bpp;</li>
  683. </ul>
  684. <p><a name="copy_mem_image"></a></p>
  685. <h3>int LibRaw::copy_mem_image(void* scan0, int stride, int bgr) - copies
  686. postprocessed bitmap data into buffer</h3>
  687. <p>Function parameters:</p>
  688. <ul>
  689. <li>void *scan0 - pointer to buffer to copy data to. The buffer should be
  690. at least stride*image_height bytes;</li>
  691. <li>int stride - stride of each other image line (row) in bytes. Usually
  692. image_width*(bit_per_pixel/8)*image_colors, but may be more if you wish
  693. to align image rows to, for example, 8 or 16 or 32 bytes to make CPU
  694. more happy.</li>
  695. <li>int bgr - pixel copy order. RGB if bgr==0 and BGR overwise.</li>
  696. </ul>
  697. <p>The function returns an integer number in accordance with the <a href="API-notes.html#errors">error
  698. code convention</a>: positive if any system call has returned an error,
  699. negative (from the <a href="API-datastruct.html#LibRaw_errors">LibRaw
  700. error list</a>) if there has been an error situation within LibRaw.</p>
  701. <p><a name="dcraw_make_mem_image"></a></p>
  702. <h3>libraw_processed_image_t *dcraw_make_mem_image(int *errorcode=NULL) -
  703. store unpacked and processed image into memory buffer as RGB-bitmap</h3>
  704. <p>This function allocates memory buffer and stores unpacked-preprocessed
  705. image into this buffer. Function returns allocated structure <a href="API-datastruct.html#libraw_processed_image_t">libraw_processed_image_t</a>
  706. with filled fields. Always returns data as RGB bitmap (i.e. <strong>type</strong>
  707. field is equal to LIBRAW_IMAGE_BITMAP).</p>
  708. <p>dcraw_process() should be called before dcraw_make_mem_image();</p>
  709. <p>Returns NULL in case of an error. If caller has passed not-NULL value as
  710. errorcode parameter, than *errorcode will be set to error code according
  711. to <a href="API-notes.html#errors">error code convention</a>.</p>
  712. <p><strong>NOTE!</strong> Memory, allocated for return value will not be
  713. fried at destructor or <strong>LibRaw::recycle</strong> calls. Caller of
  714. dcraw_make_mem_image should free this memory by call to <a href="#dcraw_clear_mem">LibRaw::dcraw_clear_mem()</a>.</p>
  715. <p><a name="dcraw_make_mem_thumb"></a></p>
  716. <h3>libraw_processed_image_t *dcraw_make_mem_thumb(int *errorcode=NULL) -
  717. store unpacked thumbnail into memory buffer</h3>
  718. <p>This function allocates memory buffer and stores thumbnail data in it.
  719. Function returns allocated structure <a href="API-datastruct.html#libraw_processed_image_t">libraw_processed_image_t</a>
  720. with filled fields. For most RAW images allocated structure will contains
  721. JPEG image (i.e. <strong>type</strong> field is equal to
  722. LIBRAW_IMAGE_JPEG). For some cameras with RGB-bitmap thumbnail (Kodak
  723. SLRs) returned structure contains RGB bitmap (<strong>type</strong> field
  724. is equal to LIBRAW_IMAGE_JPEG, see structure description for details).</p>
  725. <p>unpack_thumb() should be called before dcraw_make_mem_thumb();</p>
  726. <p>Returns NULL in case of an error. If caller has passed not-NULL value as
  727. errorcode parameter, than *errorcode will be set to error code according
  728. to ñ <a href="API-notes.html#errors">error code convention</a>.</p>
  729. <p><strong>NOTE!</strong> Memory, allocated for return value will not be
  730. fried at destructor or <strong>LibRaw::recycle</strong> calls. Caller of
  731. dcraw_make_mem_image should free this memory by call to <a href="#dcraw_clear_mem">LibRaw::dcraw_clear_mem()</a>.</p>
  732. <h3>void LibRaw::dcraw_clear_mem(libraw_processed_image_t *)</h3>
  733. <p>This function will free the memory allocated by <strong>dcraw_make_mem_image</strong>
  734. or <strong>dcraw_make_mem_thumb</strong>.</p>
  735. <p>This is static class member, so call syntax should be
  736. LibRaw::dcraw_clear_mem(...).</p>
  737. <p>This call translates directly to free() system function, but it is better
  738. to use dcraw_clear_mem because LibRaw (DLL) may be compiled with memory
  739. manager other than in calling application.</p>
  740. <p><a name="datastream"></a></p>
  741. <h2>Input layer abstraction</h2>
  742. <p><a name="LibRaw_abstract_datastream"></a></p>
  743. <h3>class LibRaw_abstract_datastream - abstract RAW read interface</h3>
  744. <p>LibRaw reads RAW-data by calling (virtual) methods of C++ object derived
  745. from <strong>LibRaw_abstract_datastream</strong>. This C++ class does not
  746. implement any read, but defines interface to be called. Call to base class
  747. methods always results in error.</p>
  748. <p><a name="datastream_methods"></a></p>
  749. <h4>LibRaw_abstract_datastream class methods</h4>
  750. <p><a name="datastream_methods_utility"></a></p>
  751. <h5>Object verification</h5>
  752. <dl>
  753. <dt><strong> virtual int valid()</strong></dt>
  754. <dd>Checks input datastream validity. Returns 1 on valid stream and 0 if
  755. datastream was created on non-valid input parameters (wrong filename for
  756. file stream and so on).</dd>
  757. </dl>
  758. <p><a name="datastream_methods_read"></a></p>
  759. <h5>Stream read and positioning</h5>
  760. <p>This group of methods implements file object (FILE*) semantics.</p>
  761. <dl>
  762. <dt><strong>virtual int read(void * ptr,size_t size, size_t nmemb)</strong></dt>
  763. <dd>Similar to fread(ptr,size,nmemb,file).</dd>
  764. <dt><strong>virtual int seek(off_t o, int whence)</strong></dt>
  765. <dd>Similar to fseek(file,o,whence).</dd>
  766. <dt><strong>virtual int tell(</strong></dt>
  767. <dd>Similar to ftell(file).</dd>
  768. <dt><strong>virtual int get_char()</strong></dt>
  769. <dd>Similar to getc(file)/fgetc(file).</dd>
  770. <dt><strong>virtual char* gets(char *s, int n)</strong></dt>
  771. <dd>Similar to fgets(s,n,file).</dd>
  772. <dt><strong>virtual int eof()</strong></dt>
  773. <dd>Similar to feof(file).</dd>
  774. <dt><strong>virtual int scanf_one(const char *fmt, void *val)</strong></dt>
  775. <dd>Simplified variant of fscanf(file,fmt,val): format string is always
  776. contains one argument to read. So, variable args call is not needed and
  777. only one pointer to data passed.</dd>
  778. <dt><strong> virtual int jpeg_src(void * p);</strong></dt>
  779. <dd>Initializes read structures in j_decompress_ptr object passed as *p.
  780. This object is used by libjpeg for JPEG data reading from datastream.
  781. <p>Returns -1 on error and 0 on success.</p>
  782. </dd>
  783. <dt><strong> virtual void * make_jas_stream();</strong></dt>
  784. <dd>Creates LibJasper input stream (for JPEG2000 decoding).
  785. <p>returns NULL on error or data pointer on success.</p>
  786. </dd>
  787. </dl>
  788. <p><a name="datastream_methods_other"></a></p>
  789. <h5>Other methods</h5>
  790. <p>This group of methods includes several supplementary calls. These calls
  791. are used to temporary switch to another data stream (file and/or memory
  792. buffer).</p>
  793. <dl>
  794. <dt><strong>virtual const char* fname()</strong></dt>
  795. <dd>Returns name of opened file if datastream object knows it (for
  796. example, <strong>LibRaw_file_datastream</strong> used). Filename used
  797. in:
  798. <ul>
  799. <li>error notification callbacks;</li>
  800. <li>generation of filename of JPEG-file with metadata when needed
  801. (i.e. cameras with 'Diag RAW hack').</li>
  802. </ul>
  803. </dd>
  804. <dt><strong>virtual int subfile_open(const char *fn)</strong></dt>
  805. <dd>This call temporary switches input to file <strong>fn</strong>.
  806. Returns 0 on success and error code on error.<br>
  807. The function used to read metadata from external JPEG file (on cameras
  808. with "Diag RAW hack"). <br>
  809. This call is not implemented for <a href="#buffer_datastream">LibRaw_buffer_datastream</a>,
  810. so external JPEG processing is not possible when buffer datastream used.
  811. <br>
  812. This functon should be implemented in real input class, base class call
  813. always return error. <br>
  814. Working implementation sample can be found in <a href="#file_datastream">LibRaw_file_datastream</a>
  815. implementation in <strong>libraw/libraw_datastream.h</strong> file.</dd>
  816. <dt><strong> virtual void subfile_close()</strong></dt>
  817. <dd>This call switches input stream from temporary open file back to main
  818. data stream.</dd>
  819. <dt><strong> virtual int tempbuffer_open(void *buf, size_t size)</strong></dt>
  820. <dd>This call temporary switches input to <a href="#buffer_datastream">LibRaw_buffer_datastream</a>
  821. object, created from <strong>buf</strong>.<br>
  822. This method is needed for Sony encrypted metadata parser.
  823. <p>This call implemented in base class (<strong>LibRaw_abstract_datastream</strong>),
  824. there is no need to reimplement in in derived classes.<br>
  825. Possible activity of temporary datastream requires very accurate
  826. programming when implementing datastreams derived from base <strong>LibRaw_abstract_datastream</strong>.
  827. See <a href="#substream">below</a> for more details.</p>
  828. </dd>
  829. <dt><strong> virtual void tempbuffer_close()</strong></dt>
  830. <dd>This call switch input back from temporary datastream to main stream.
  831. This call implemented in base <strong>LibRaw_abstract_datastream</strong>
  832. class.</dd>
  833. </dl>
  834. <p><a name="datastream_derived"></a></p>
  835. <h3>Derived input classes included in LibRaw</h3>
  836. <p>There is three "standard" input classes in LibRaw distribution:</p>
  837. <ul>
  838. <li><a href="#file_datastream">LibRaw_file_datastream</a> implements input
  839. from file (in filesystem).</li>
  840. <li><a href="#bigfile_datastream">LibRaw_bigfile_datastream</a> slower
  841. I/O, but files larger than 2Gb are supported.</li>
  842. <li><a href="#buffer_datastream">LibRaw_buffer_datastream</a> implements
  843. input from memory buffer.</li>
  844. </ul>
  845. <p>LibRaw C++ interface users can implement their own input classes and use
  846. them via <a href="#open_datastream">LibRaw::open_datastream</a> call.
  847. Requirements and implementation specifics are described below.</p>
  848. <p><a name="file_datastream"></a></p>
  849. <h4>class LibRaw_file_datastream - file input interface</h4>
  850. <p>This class implements input from file.</p>
  851. <p><strong>Class methods:</strong></p>
  852. <dl>
  853. <dt><strong> LibRaw_file_datastream(const char *fname) </strong></dt>
  854. <dd>This constructor creates <strong>LibRaw_file_datastream</strong>
  855. object from file <strong>fname</strong>.<br>
  856. Unfortunately, C++ constructor cannot return an error. So if bad
  857. filename passed (e.g. nonexistent file) object is created as non-valid
  858. (valid() call returns zero).</dd>
  859. </dl>
  860. <p>All other class methods are <a href="#datastream_methods">described
  861. above</a>.<br>
  862. This class implements all possble methods, including fname() and
  863. subfile_open().</p>
  864. <p><a name="bigfile_datastream"></a></p>
  865. <h4>class LibRaw_bigfile_datastream - file input interface</h4>
  866. <p>This class implements input from file.</p>
  867. <p><strong>Class methods:</strong></p>
  868. <dl>
  869. <dt><strong> LibRaw_bigfile_datastream(const char *fname) </strong></dt>
  870. <dd>This constructor creates <strong>LibRaw_bigfile_datastream</strong>
  871. object from file <strong>fname</strong>.<br>
  872. Unfortunately, C++ constructor cannot return an error. So if bad
  873. filename passed (e.g. nonexistent file) object is created as non-valid
  874. (valid() call returns zero).</dd>
  875. </dl>
  876. <p>The difference between <strong>file</strong> and <strong>bigfile</strong>
  877. datastreams are obvious from class name: bigfile one supports large files
  878. (more than 2Gb) on all supported systems. File one uses streambuf
  879. interface which is limited to 2Gb on many systems.</p>
  880. <p>All other class methods are <a href="#datastream_methods">described
  881. above</a>.<br>
  882. This class implements all possble methods, including fname() and
  883. subfile_open().</p>
  884. <p><a name="buffer_datastream"></a></p>
  885. <h4>class LibRaw_buffer_datastream - memory buffer input interface</h4>
  886. <p>This class implements input from memory buffer.</p>
  887. <p><strong>Class methods:</strong></p>
  888. <dl>
  889. <dt><strong> LibRaw_buffer_datastream(void *buffer, size_t bsize)</strong></dt>
  890. <dd>This constructor creates datastream object from <strong>buffer</strong>
  891. with size <strong>bsize</strong>.<br>
  892. It is not possibly to verify the pointer passed, so buffer address is
  893. checked against 0 and -1 only.</dd>
  894. </dl>
  895. <p>All other class methods are <a href="#datastream_methods">described
  896. above</a>.<br>
  897. This class does not implement fname() and subfile_open() calls, so
  898. external JPEG metadata parsing is not possible.</p>
  899. <p><a name="own_datastreams"></a></p>
  900. <h3>Own datastream derived classes</h3>
  901. <p>To create own read interface LibRaw user should implement C++ class
  902. derived from <strong>LibRaw_abstract_datastream</strong> with all read
  903. methods.<br>
  904. LibRaw standard implementations may be used as reference. See <strong>libraw/libraw_datastream.h</strong>
  905. file for details (all standard LibRaw input classes are implemented using
  906. inline functions only).</p>
  907. <p><a name="substream"></a></p>
  908. <p><a href="index.html">[back to Index]</a></p>
  909. </body>
  910. </html>