MCPcopy Create free account
hub / github.com/davisking/dlib / load_dng

Function load_dng

dlib/image_loader/image_loader.h:516–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514 typename image_type
515 >
516 void load_dng (
517 image_type& image_,
518 std::istream& in
519 )
520 {
521 image_view<image_type> image(image_);
522 using namespace dng_helpers_namespace;
523 try
524 {
525 if (in.get() != 'D' || in.get() != 'N' || in.get() != 'G')
526 throw image_load_error("the stream does not contain a dng image file");
527
528 unsigned long version;
529 deserialize(version,in);
530 if (version != 1)
531 throw image_load_error("You need the new version of the dlib library to read this dng file");
532
533 unsigned long type;
534 deserialize(type,in);
535
536 long width, height;
537 deserialize(width,in);
538 deserialize(height,in);
539
540 if (width > 0 && height > 0)
541 image.set_size(height,width);
542 else
543 image.clear();
544
545 if (type != grayscale_float)
546 {
547 typedef entropy_decoder::kernel_2a decoder_type;
548 decoder_type decoder;
549 decoder.set_stream(in);
550
551 entropy_decoder_model<256,decoder_type>::kernel_5a edm(decoder);
552 unsigned long symbol;
553 rgb_pixel p_rgb;
554 rgb_alpha_pixel p_rgba;
555 hsi_pixel p_hsi;
556 switch (type)
557 {
558 case rgb_alpha_paeth:
559
560 for (long r = 0; r < image.nr(); ++r)
561 {
562 for (long c = 0; c < image.nc(); ++c)
563 {
564 p_rgba = predictor_rgb_alpha_paeth(image,r,c);
565 edm.decode(symbol);
566 p_rgba.red += static_cast<unsigned char>(symbol);
567
568 edm.decode(symbol);
569 p_rgba.green += static_cast<unsigned char>(symbol);
570
571 edm.decode(symbol);
572 p_rgba.blue += static_cast<unsigned char>(symbol);
573

Callers 6

load_imageFunction · 0.85
image_testFunction · 0.85
test_dng_floatsFunction · 0.85
test_dng_float_intFunction · 0.85
perform_testMethod · 0.85

Calls 15

assign_pixelFunction · 0.85
predictor_rgb_alphaFunction · 0.85
predictor_rgb_paethFunction · 0.85
predictor_rgbFunction · 0.85
predictor_hsiFunction · 0.85
predictor_grayscaleFunction · 0.85
predictor_grayscale_16Function · 0.85
image_load_errorClass · 0.70
deserializeFunction · 0.50
getMethod · 0.45
set_sizeMethod · 0.45

Tested by 5

image_testFunction · 0.68
test_dng_floatsFunction · 0.68
test_dng_float_intFunction · 0.68
perform_testMethod · 0.68