Reference Guide > D Routines > DC_WRITE_24_BIT Function
  

DC_WRITE_24_BIT Function
Writes 24-bit image data to a file.
Usage
status = DC_WRITE_24_BIT(filename, imgarr)
Input Parameters
filename — A string containing the pathname and filename of the file where the 24-bit image data is to be stored.
imgarr — The 3D byte array from which the 24-bit image data is transferred. Either the first or last dimension of imgarr must be 3; see the Discussion section for more details.
Returned Value
status — The value returned by DC_WRITE_24_BIT; expected values are:
*< 0 — Indicates an error, such as an invalid filename.
*0 — Indicates a successful write.
Keywords
Org — Organization of the 24-bit image data. Allowed values are:
*0 — Pixel interleaving (RGB triplets).
*1 — Image interleaving (separate planes).
*If not provided, 0 (pixel interleaving) is assumed.
Discussion
DC_WRITE_24_BIT handles many steps that you have to do yourself when using other PV-WAVE functions and procedures. These steps include: 1) opening the file, 2) assigning it a logical unit number (LUN), and 3) closing the file when you are done writing the data.
 
note
Only one 24-bit image can be stored at a time when using DC_WRITE_24_BIT.
If imgarr is not a 3D byte array, DC_WRITE_24_BIT returns an error status and no data is written to the output file. Either the first or last dimension of imgarr must be equal to 3, as shown in the following list:
*Pixel (RGB triplets) — Dimension imgarr as 3 × w × h, where w and h are the width and length of the image in pixels.
*Image (separate planes) — Dimension imgarr as w × h × 3, where w and h are the width and length of the image in pixels.
The difference between pixel-interleaved and image-interleaved data is discussed in the PV‑WAVE Programmer’s Guide.
Example
If raw_data is a 450-by-273-by-3 byte array containing 24-bit image data, the commands:
; Read a 24-bit image
img = IMAGE_READ(!Dir + '/demo/gallery3/data/planetarium24.pcx')
; Retrieve the 24-bit pixel data
raw_data = img('pixels') 
; Write the raw binary data
status = DC_WRITE_24_BIT('planetarium24.img', raw_data, Org=1)
create the file planetarium24.img and use it to store the image data contained in the variable raw_data, using image interleaving. The file that is created contains raw binary data, and is easily read with DC_READ_24_BIT.
See Also
DC_ERROR_MSG,    DC_READ_24_BIT,    DC_WRITE_8_BIT
See the PV‑WAVE Programmer’s Guide for or more information about 24-bit (binary) data.

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.