MCPcopy Create free account
hub / github.com/DentonW/DevIL / iJp2ReadStream

Function iJp2ReadStream

DevIL/src-IL/src/il_jp2.cpp:366–429  ·  view source on GitHub ↗

Modified version of jas_stream_fopen and jas_stream_memopen from jas_stream.c of JasPer so that we can use our own file routines.

Source from the content-addressed store, hash-verified

364// Modified version of jas_stream_fopen and jas_stream_memopen from jas_stream.c of JasPer
365// so that we can use our own file routines.
366jas_stream_t *iJp2ReadStream()
367{
368 jas_stream_t *stream;
369 jas_stream_memobj_t *obj;
370
371 if (!(stream = jas_stream_create())) {
372 return 0;
373 }
374
375 /* A stream associated with a memory buffer is always opened
376 for both reading and writing in binary mode. */
377 stream->openmode_ = JAS_STREAM_READ | JAS_STREAM_BINARY;
378
379 /* We use buffering whether it is from memory or a file. */
380 jas_stream_initbuf(stream, JAS_STREAM_FULLBUF);
381
382 /* Select the operations for a memory stream. */
383 stream->ops_ = &jas_stream_devilops;
384
385 /* Allocate memory for the underlying memory stream object. */
386 if (!(obj = (jas_stream_memobj_t*)jas_malloc(sizeof(jas_stream_memobj_t)))) {
387 jas_stream_destroy(stream);
388 return 0;
389 }
390 stream->obj_ = (void *) obj;
391
392 /* Initialize a few important members of the memory stream object. */
393 obj->myalloc_ = 0;
394 obj->buf_ = 0;
395
396 // Shouldn't need any of this.
397
398 ///* If the buffer size specified is nonpositive, then the buffer
399 //is allocated internally and automatically grown as needed. */
400 //if (bufsize <= 0) {
401 // obj->bufsize_ = 1024;
402 // obj->growable_ = 1;
403 //} else {
404 // obj->bufsize_ = bufsize;
405 // obj->growable_ = 0;
406 //}
407 //if (buf) {
408 // obj->buf_ = (unsigned char *) buf;
409 //} else {
410 // obj->buf_ = jas_malloc(obj->bufsize_ * sizeof(char));
411 // obj->myalloc_ = 1;
412 //}
413 //if (!obj->buf_) {
414 // jas_stream_close(stream);
415 // return 0;
416 //}
417
418 //if (bufsize > 0 && buf) {
419 // /* If a buffer was supplied by the caller and its length is positive,
420 // make the associated buffer data appear in the stream initially. */
421 // obj->len_ = bufsize;
422 //} else {
423 // /* The stream is initially empty. */

Callers 1

ilLoadJp2FFunction · 0.85

Calls 3

jas_stream_createFunction · 0.85
jas_stream_initbufFunction · 0.85
jas_stream_destroyFunction · 0.85

Tested by

no test coverage detected