I'm starting a new thread for this.
AFAICT the difference between dcraw -d and dcraw -D isn't just black subraction. It would seem the dcraw-d calls scale_colors() on the image.
This appears to operates on an (internal?) 4 component image array rather than on the single component raw_image and the code is (to say the least) somewhat complex.
I'm not an expert on image processing - just trying to convert some existing code to use libraw instead of the orphaned dcraw, so can you recommend how best to scale the raw image in this case.
Sorry if I'm being a pain.