jhc2SUN
Overview
jhc2SUN converts an 8-bit OMG/JHC raster array file (JHC_header with data_type == 1) into a standard 8-bit Sun Rasterfile (struct rasterfile, RAS_MAGIC = 0x59a66a95), optionally inverting pixel greyscale values (255 - val) and padding odd row widths to 16-bit word boundaries as required by the Sun Rasterfile specification.
Usage
jhc2SUN (-invert) jhc8bitfilename SUNrasterfilename
CLI Options
| Flag | Arguments | Default | Description |
|---|---|---|---|
<jhc8bitfilename> | <path> | required | First positional argument: input 8-bit JHC array file. |
<SUNrasterfilename> | <path> | required | Second positional argument: output Sun Rasterfile (.ras). |
-invert | none | 0 | Invert 8-bit pixel intensities (*(bbuf + x) = 255 - *(bbuf + x)). |
How It Works
- Header Validation: Reads the input
JHC_headerviaget_print_JHC_header(floatfile, 1), extractsdx(width) anddy(height), and verifiesJHChead.data_type == 1(8-bit unsigned byte). - Sun Raster Header Construction: Populates
struct rasterfile(ras_magic = RAS_MAGIC,ras_width = dx,ras_height = dy,ras_depth = 8,ras_length = dx * dy,ras_type = RT_STANDARD,ras_maptype = RMT_NONE,ras_maplength = 0) and writes it to the output file. - Row Conversion & Word Padding: Reads
dyscanlines ofdxbytes, optionally inverts each pixel when-invertis set, and writesdx + 1bytes per row ifdxis odd (dx % 2) ordxbytes ifdxis even.
Practical Examples
Convert an 8-bit JHC mosaic into an inverted Sun Rasterfile
jhc2SUN -invert mr1_mosaic.i1 mr1_mosaic.ras