Skip to content

Instantly share code, notes, and snippets.

@573
Created March 22, 2011 15:23
Show Gist options
  • Save 573/881402 to your computer and use it in GitHub Desktop.
Save 573/881402 to your computer and use it in GitHub Desktop.
Changes applied to dng_validate.cpp to prepare for csv output of r-, g- and b-values. Applies to dng_sdk version 1.3 from Adobe.
--- E:\temp\dng_sdk_1_3\dng_sdk\source\dng_validate.cpp_original 2009-06-22 13:07:00 +0000
+++ E:\temp\dng_sdk_1_3\dng_sdk\source\dng_validate.cpp 2011-03-22 15:25:46 +0000
@@ -63,6 +63,7 @@
static dng_string gDumpStage3;
static dng_string gDumpTIF;
static dng_string gDumpDNG;
+static dng_string gDumpTXT;
/*****************************************************************************/
@@ -298,6 +299,61 @@
}
+ // TODO TXT output. Next TODO Output RGB values to PPM ("Netpbm color image format", "magic number" P3, ASCII) file if requested.
+
+ if (gDumpTXT.NotEmpty ())
+ {
+
+ dng_render render (host, *negative);
+
+ render.SetFinalSpace (*gFinalSpace );
+ render.SetFinalPixelType (gFinalPixelType);
+
+ if (host.MinimumSize ())
+ {
+
+ dng_point stage3Size = negative->Stage3Image ()->Size ();
+
+ render.SetMaximumSize (Max_uint32 (stage3Size.v,
+ stage3Size.h));
+
+ }
+
+ AutoPtr<dng_image> finalImage;
+
+ {
+
+ dng_timer timer("Render time");
+
+ finalImage.Reset(render.Render());
+
+ }
+
+ dng_const_tile_buffer buffer(*finalImage, finalImage->Size());
+
+ // See forum, unanswered at the moment, how to exactly
+ const int8 * wantedpx = buffer.ConstPixel_int8 (0,0);
+ fprintf(stderr, "constpixel[0,0]: %s\n", &wantedpx);
+
+
+
+ dng_file_stream stream2 (gDumpTXT.Get (), true);
+
+ dng_image_writer writer;
+
+ {
+
+ dng_timer timer ("Write TXT time");
+ // TODO write txt/csv file. For later TODO write raw ppm (P3) or even both, raw and plain (P6), see TIFF writer
+ writer.WriteTXT (host,
+ stream2,
+ *finalImage.Get ());
+ }
+
+ gDumpTXT.Clear ();
+
+ }
+
// Output TIF file if requested.
if (gDumpTIF.NotEmpty ())
@@ -436,6 +492,7 @@
"-3 <file> Write stage 3 image to \"<file>.tif\"\n"
"-tif <file> Write TIF image to \"<file>.tif\"\n"
"-dng <file> Write DNG image to \"<file>.dng\"\n"
+ "-ppm <file> (Not impl. yet) Write PPM (P3) image to \"<file>.ppm\"\n"
"\n",
argv [0]);
@@ -715,6 +772,30 @@
}
+ /**Experimental, currently outputs a pixel value only as text */
+ else if (option.Matches ("ppm", true))
+ {
+
+ gDumpTXT.Clear ();
+
+ if (index + 1 < argc)
+ {
+ gDumpTXT.Set (argv [++index]);
+ }
+
+ if (gDumpTXT.IsEmpty () || gDumpTXT.StartsWith ("-"))
+ {
+ fprintf (stderr, "*** Missing file name after -ppm\n");
+ return 1;
+ }
+
+ if (!gDumpTXT.EndsWith (".ppm"))
+ {
+ gDumpTXT.Append (".ppm");
+ }
+
+ }
+
else
{
fprintf (stderr, "*** Unknown option \"-%s\"\n", option.Get ());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment