• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can open produced DNG in Photoshop but not in LibRaw

New Here ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

I have a few questions regarding the Adobe DNG SDK and if i am using it correctly.

So the flow of my program works as follows: i read a custom binary file containing the raw data.

This will be the buffer of my output DNG. I can open the produced DNG in the windows preview correctly and

also in Adobe Photoshop, but if I want to open it in some other programs like LibRaw or RawTherapee, the image

is just completely black.

I will post my programm and the log of DNGValidate.exe , perhaps you have an idea what went wrong.

Here is a link of my DNG.

See my program below

#include "DNGWriter.h"

namespace Unpacker {

dng_error_code CDNGWriter::writeDNG(byte *pFrame, const std::string &fileName) {

try {

m_pDngImage.Reset(m_dngHost.Make_dng_image(m_imageRect, 1, m_depth == 8 ? ttByte : ttShort));

m_dngBuffer.fArea = m_imageRect;

m_dngBuffer.fPlane = 0;

m_dngBuffer.fPlanes = 1;

m_dngBuffer.fRowStep = m_dngBuffer.fPlanes * m_imageRect.W();

m_dngBuffer.fColStep = m_dngBuffer.fPlanes;

m_dngBuffer.fPlaneStep = 1;

m_dngBuffer.fPixelType = m_depth == 8 ? ttByte : ttShort;

m_dngBuffer.fPixelSize = TagTypeSize(m_depth == 8 ? ttByte : ttShort);

m_dngBuffer.fData = pFrame;

m_pDngImage->Put(m_dngBuffer);

// -------------------------------------------------------------

// Write DNG file

// -------------------------------------------------------------

// Assign Raw image data.

m_pDngNegative->SetStage1Image(m_pDngImage);

// Compute linearized and range mapped image 

m_pDngNegative->BuildStage2Image(m_dngHost);

// Compute demosaiced image (used by preview and thumbnail)

m_pDngNegative->BuildStage3Image(m_dngHost);

// Update XMP / EXIF

m_pDngNegative->SynchronizeMetadata();

// Update IPTC

m_pDngNegative->RebuildIPTC(true);

// Create stream writer for output file

dng_file_stream fstream(fileName.c_str(), true);

// Create thumbnail

dng_image_preview thumbnail;

dng_render render(m_dngHost, *m_pDngNegative);

render.SetFinalSpace(dng_space_sRGB::Get());

render.SetFinalPixelType(m_depth == 8 ? ttByte : ttSShort);

render.SetMaximumSize(1 << m_depth);

thumbnail.fImage.Reset(render.Render());

AutoPtr<dng_image_writer> oWriter(new dng_image_writer());

oWriter->WriteDNG(m_dngHost, fstream, *m_pDngNegative.Get(), NULL, dngVersion_1_3_0_0, ccUncompressed);

} catch (const dng_exception &ex) {

     return ex.ErrorCode();

} catch (...) {

     return dng_error_none;

}

     return dng_error_none;

}

///////////////////////////////////////////////////////////////////////////////////////////////////////

dng_error_code CDNGWriter::setup(int rows, int cols, int depth) {

try {

m_depth = depth;

m_imageRect = dng_rect(cols, rows);

// Set DNG version

// Remarks: Tag [DNGVersion] / [50706]

// dngVersion default is the most recent one with 1.4.0.0

m_dngHost.SetSaveDNGVersion(dngVersion_SaveDefault);

// Set DNG type to RAW DNG

// Remarks: Store Bayer CFA data and not already processed data

m_dngHost.SetSaveLinearDNG(false);

// ---------------------------------------------------------------------------------------------------------------

// DNG Negative Settings

// ---------------------------------------------------------------------------------------------------------------

m_pDngNegative.Reset(m_dngHost.Make_dng_negative());

// Set camera model 

// Remarks: Tag [UniqueCameraModel] / [50708]

m_pDngNegative->SetModelName("MyModel");

// Set localized camera model 

// Remarks: Tag [UniqueCameraModel] / [50709]

m_pDngNegative->SetLocalName("Grass hopper");

// Set colorkey information

// Remarks: Tag

m_pDngNegative->SetColorKeys(colorKeyRed, colorKeyGreen, colorKeyBlue);

// Set bayer pattern information

// Remarks: Tag [CFAPlaneColor] / [50710] and [CFALayout] / [50711]

// bayer pattern depends on the colorkey set by

// dngNegative->SetColorKeys(colorKeyRed, colorKeyGreen, colorKeyBlue);

// In this case: 3 means GBGR bayer pattern

m_pDngNegative->SetBayerMosaic(3);

// Set colorchannel information

m_pDngNegative->SetColorChannels(3);

// Set linearization table

// Remarks: Tag [LinearizationTable] / [50712]

// Calculate bit limit

const uint8 m_unBitLimit = 0x01 << m_depth;

AutoPtr<dng_memory_block> oCurve(m_dngHost.Allocate(sizeof(uint8)*m_unBitLimit));

for (int32 i = 0; i < m_unBitLimit; i++) {

uint8 *pulItem = oCurve->Buffer_uint8() + i;

*pulItem = (uint8)(i);

}

m_pDngNegative->SetLinearization(oCurve);

// Set scale to square pixel

// Remarks: Tag [DefaultScale] / [50718]

m_pDngNegative->SetDefaultScale(dng_urational(1, 1), dng_urational(1, 1));

// Set pixel area

// Remarks: Tag [DefaultCropOrigin] / [50719]

m_pDngNegative->SetDefaultCropOrigin(0, 0);

// Set pixel area

// Remarks: Tag [DefaultCropSize] / [50720]

m_pDngNegative->SetDefaultCropSize(m_imageRect.W(), m_imageRect.H());

// Set active area

m_pDngNegative->SetActiveArea(m_imageRect);

m_pDngNegative->SetOriginalRawFileName("testdummi.bin");

m_pDngNegative->SetColorKeys(colorKeyRed, colorKeyGreen, colorKeyBlue);

// Set white LEVEL, value where the image is supposed to be white

m_pDngNegative->SetWhiteLevel((0x01 << m_depth) - 1); // 2^bpp -1

// Set black LEVEL, value where the image is supposed to be black

//m_pDngNegative->SetBlackLevel(1);

// Set baseline exposure

// Remarks: Tag [BaselineExposure] / [50730]

m_pDngNegative->SetBaselineExposure(0.0);

// Set if noise reduction is already applied on RAW data

// Remarks: Tag [NoiseReductionApplied] / [50935]

m_pDngNegative->SetNoiseReductionApplied(dng_urational(0, 1));

m_pDngNegative->SetAsShotProfileName("");

m_pDngNegative->SetBaselineNoise(1.0);

m_pDngNegative->SetBaselineSharpness(1.0);

m_pDngNegative->SetBaseOrientation(dng_orientation::Normal());

m_pDngNegative->SetLinearResponseLimit(1.0);

// Set camera neutral coordinates

// Remarks: Tag [AsShotNeutral] / [50728]

dng_vector pNeutral;

pNeutral.SetIdentity(3);

m_pDngNegative->SetCameraNeutral(pNeutral);

// ---------------------------------------------------------------------------------------------------------------

// DNG EXIF Settings

// ---------------------------------------------------------------------------------------------------------------

m_pDngExif = m_pDngNegative->GetExif();

// Set Camera Make

// Remarks: Tag [Make] / [EXIF]

m_pDngExif->fMake.Set_ASCII("PointGrey");

// Set Camera Model

// Remarks: Tag [Model] / [EXIF]

m_pDngExif->fModel.Set_ASCII("Grasshopper GS3-U3-41C6C-C");

// Set exposure time - Shutterspeed

// Remarks: Tag [ExposureTime] / [EXIF]

m_pDngExif->SetExposureTime(10.0 / 1000.0); // random exposure time

// Set ISO speed

// Remarks: Tag [ISOSpeed] / [EXIF]

m_pDngExif->fISOSpeedRatings[0] = 400; // ISO should be 400

m_pDngExif->fISOSpeedRatings[1] = 0;

m_pDngExif->fISOSpeedRatings[2] = 0;

// Set focal length

// Remarks: Tag [FocalLength] / [EXIF]

m_pDngExif->fFocalLength.Set_real64(7.0, 1000);

// Set lens info

// Remarks: Tag [LensInfo] / [EXIF]

m_pDngExif->fLensInfo[0].Set_real64(10.0, 10);

m_pDngExif->fLensInfo[1].Set_real64(10.0, 10);

m_pDngExif->fLensInfo[2].Set_real64(4.0, 10);

m_pDngExif->fLensInfo[3].Set_real64(4.0, 10);

m_pDngExif->fBrightnessValue = dng_srational(0, 0);

// Set WB mode

// Remarks: Tag [WhiteBalance] / [EXIF]

m_pDngExif->fWhiteBalance = 0;

// Set metering mode

// Remarks: Tag [MeteringMode] / [EXIF]

m_pDngExif->fMeteringMode = 2;

// Set metering mode

// Remarks: Tag [ExposureBiasValue] / [EXIF]

m_pDngExif->fExposureBiasValue = dng_srational(0, 0);

// Set aperture value

// Remarks: Tag [ApertureValue] / [EXIF]

m_pDngExif->SetFNumber(2.4); // sunex lens apeture

// Set Date time

// poExif->fDateTime();

// Set GPS value [Future]

// -------------------------------------------------------------

// DNG Profile Settings: Simple color calibration

// -------------------------------------------------------------

AutoPtr<dng_camera_profile> profile(new dng_camera_profile);

profile->SetName("MyCompany");

profile->SetCalibrationIlluminant1(lsD50);

// Excerpt from the DNG specification :

// ColorMatrix1 defines a transformation matrix that converts XYZ values to reference camera native color space values,

// under the first calibration illuminant.The matrix values are stored in row scan order.

dng_matrix_3by3 xyzToCam = dng_matrix_3by3(

3.13386, -1.61687, -0.49061,

-0.97877, 1.91614, 0.03345,

0.07195, -0.22899, 1.40524

);

profile->SetColorMatrix1(xyzToCam);

profile->SetCopyright("MyCompany");

profile->SetWasReadFromDNG(false);

m_pDngNegative->AddProfile(profile);

} catch (const dng_exception &except) {

     return except.ErrorCode();

} catch (...) {

     return dng_error_unknown;

}

return dng_error_none;

}

}

And this is the log of DNGValidate

Validating "000000.dng"...

Uses little-endian byte order

Magic number = 42

IFD 0: Offset = 8, Entries = 55

NewSubFileType: Main Image

ImageWidth: 2048

ImageLength: 2048

BitsPerSample: 8 8 8

Compression: Uncompressed

PhotometricInterpretation: CFA

Make: "PointGrey"

Model: "Grasshopper GS3-U3-41C6C-C"

StripOffsets: Offset = 6004

Orientation: 1 - 0th row is top, 0th column is left

SamplesPerPixel: 3

RowsPerStrip: 2048

StripByteCounts: Count = 12582912

PlanarConfiguration: 1

DateTime: 2018:03:01 17:53:32

XMP: Count = 4618, Offset = 738

XMP: <?xpacket begin="\357\273\277" id="W5M0MpCehiHzreSzNTczkc9d"?>

XMP: <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.6.0">

XMP:  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

XMP:   <rdf:Description rdf:about=""

XMP:     xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"

XMP:     xmlns:xmp="http://ns.adobe.com/xap/1.0/"

XMP:    aux:LensInfo="100/10 100/10 40/10 40/10"

XMP:    aux:Lens="10.0 mm f/4.0"

XMP:    xmp:ModifyDate="2018-03-01T17:53:32+01:00"

XMP:    xmp:MetadataDate="2018-03-01T17:53:32+01:00"/>

XMP:  </rdf:RDF>

XMP: </x:xmpmeta>

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP:

XMP: <?xpacket end="w"?>

CFARepeatPatternDim: Rows = 2, Cols = 2

CFAPattern:

    Green    Blue

    Red      Green

ExifIFD: 5780

DNGVersion: 1.4.0.0

DNGBackwardVersion: 1.1.0.0

UniqueCameraModel: "Reality 7"

LocalizedCameraModel: "Grass hopper"

CFAPlaneColor: Red Green Blue

CFALayout: Rectangular (or square) layout

LinearizationTable:

BlackLevelRepeatDim: Rows = 1, Cols = 1

BlackLevel: 1.00 1.00 1.00

WhiteLevel: 255 255 255

DefaultScale: H = 1.0000 V = 1.0000

DefaultCropOrigin: H = 0.00 V = 0.00

DefaultCropSize: H = 2048.00 V = 2048.00

ColorMatrix1:

      3.1339  -1.6169  -0.4906

     -0.9788   1.9161   0.0335

      0.0720  -0.2290   1.4052

AnalogBalance: 1.0000 1.0000 1.0000

AsShotNeutral: 1.0000 1.0000 1.0000

BaselineExposure: +0.00

BaselineNoise: 1.00

BaselineSharpness: 1.00

BayerGreenSplit: 0

LinearResponseLimit: 1.00

LensInfo: 10.0 mm f/4.0

AntiAliasStrength: 1.00

ShadowScale: 1.0000

CalibrationIlluminant1: D50

BestQualityScale: 1.0000

RawDataUniqueID: <000000000000000050068b0e9fed9be2>

OriginalRawFileName: "testdummi.bin"

ActiveArea: T = 0 L = 0 B = 2048 R = 2048

NoiseReductionApplied: 0/1

ProfileName: "Reality7"

ProfileEmbedPolicy: Allow copying

ProfileCopyright: "Reality7"

RawImageDigest: <da1dde5cd511616e7cec7ba6d70138b5>

OriginalDefaultFinalSize: H = 0 V = 0

OriginalDefaultCropSize: H = 0.00 V = 0.00

NextIFD = 0

Exif IFD: Offset = 5780, Entries = 11

ExposureTime: 1/100.0 sec

FNumber: f/2.40

ISOSpeedRatings: 400

ExifVersion: 2.30

ShutterSpeedValue: 1/100.0 sec

ApertureValue: f/2.40

MeteringMode: CenterWeightedAverage

FocalLength: 7.0 mm

WhiteBalance: Auto white balance

LensSpecificationExif: 10.0 mm f/4.0

LensModelExif: "10.0 mm f/4.0"

NextIFD = 0

*** Warning: Too little padding on left edge of CFA image (possible interpolation artifacts) ***

*** Warning: Too little padding on top edge of CFA image (possible interpolation artifacts) ***

*** Warning: Too little padding on right edge of CFA image (possible interpolation artifacts) ***

*** Warning: Too little padding on bottom edge of CFA image (possible interpolation artifacts) ***

Raw image read time: 0.013 sec

FindRawImageDigest time: 0.066 sec

Linearization time: 0.032 sec

Interpolate time: 0.067 sec

Validation complete

Thank you in advance!

Views

861

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

Well, one thing I do notice is that there's no thumbnail/preview image. Technically, that's illegal and may be causing trouble.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 02, 2018 Mar 02, 2018

Copy link to clipboard

Copied

LATEST

Hi sandy_mc, thank you for the answer. How to set the preview/thumnnail? I think I have it since Windows 10 can show me the a preview, right before "oWriter->WriteDNG(m_dngHost, fstream, *m_pDngNegative.Get(), NULL, dngVersion_1_3_0_0, ccUncompressed);"

Sorry for the bad formatting, i would like to edit my question with code syntax, but i did not find it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines