Back to Ccv

lib/ccv_io.c

site/0.6/lib/ccv-io/index.html

latest2.9 KB
Original Source

lib/ccv_io.c

ccv_read

int ccv_read(const char* in, ccv_dense_matrix_t** x, int type)

Read image from a file. This function has soft dependencies on LibJPEG and LibPNG. No these libraries, no JPEG nor PNG read support. However, ccv does support BMP read natively (it is a simple format after all).

  • in : the file name.
  • x : the output image.
  • type : CCV_IO_ANY_FILE, accept any file format. CCV_IO_GRAY, convert to grayscale image. CCV_IO_COLOR, convert to color image.

ccv_read

int ccv_read(const void* data, ccv_dense_matrix_t** x, int type, int size)

Read image from a a region of memory that conforms a specific image format. This function has soft dependencies on LibJPEG and LibPNG. No these libraries, no JPEG nor PNG read support. However, ccv does support BMP read natively (it is a simple format after all).

  • data : the data memory.
  • x : the output image.
  • type : CCV_IO_ANY_STREAM, accept any file format. CCV_IO_GRAY, convert to grayscale image. CCV_IO_COLOR, convert to color image.
  • size : the size of that data memory region.

ccv_read

int ccv_read(const void* data, ccv_dense_matrix_t** x, int type, int rows, int cols, int scanline)

Read image from a region of memory that assumes specific layout (RGB, GRAY, BGR, RGBA, ARGB, RGBA, ABGR, BGRA). By default, this method will create a matrix and copy data over to that matrix. With CCV_IO_NO_COPY, it will create a matrix that has data block pointing to the original data memory region. It is your responsibility to release that data memory at an appropriate time after release the matrix.

  • data : the data memory.
  • x : the output image.
  • type : CCV_IO_ANY_RAW, CCV_IO_RGB_RAW, CCV_IO_BGR_RAW, CCV_IO_RGBA_RAW, CCV_IO_ARGB_RAW, CCV_IO_BGRA_RAW, CCV_IO_ABGR_RAW, CCV_IO_GRAY_RAW. These in conjunction can be used with CCV_IO_NO_COPY.
  • rows : how many rows in the given data memory region.
  • cols : how many columns in the given data memory region.
  • scanline : the size of a single column in the given data memory region (or known as “bytes per row”).

ccv_write

int ccv_write(ccv_dense_matrix_t* mat, char* out, int* len, int type, void* conf)

Write image to a file. This function has soft dependencies on LibJPEG and LibPNG. No these libraries, no JPEG nor PNG write support.

  • mat : the input image.
  • out : the file name.
  • len : the output bytes.
  • type : CCV_IO_PNG_FILE, save to PNG format. CCV_IO_JPEG_FILE, save to JPEG format.
  • conf : configuration.

‹ back

comments powered by Disqus