summaryrefslogtreecommitdiff
path: root/gpr/source/lib/gpr_sdk/private/gpr_utils.cpp
blob: 7672fdeb2026e46cdf3e63d41d90538562ba9df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

#include "gpr_utils.h"

#include "dng_camera_profile.h"
#include "dng_color_space.h"
#include "dng_date_time.h"
#include "dng_exceptions.h"
#include "dng_file_stream.h"
#include "dng_globals.h"
#include "dng_host.h"
#include "dng_ifd.h"
#include "dng_image_writer.h"
#include "dng_info.h"
#include "dng_linearization_info.h"
#include "dng_mosaic_info.h"
#include "dng_negative.h"
#include "dng_preview.h"
#include "dng_render.h"
#include "dng_simple_image.h"
#include "dng_tag_codes.h"
#include "dng_tag_types.h"
#include "dng_tag_values.h"
#include "dng_xmp.h"
#include "dng_xmp_sdk.h"
#include "dng_memory_stream.h"
#include "dng_bottlenecks.h"

#include "gpr_platform.h"
#include "gpr_buffer_auto.h"

void CopyRawImageToBuffer( const dng_image& raw_image, gpr_buffer_auto& buffer )
{
    dng_point size = raw_image.Bounds().Size();
    
    const int raw_image_size = size.h * size.v * 2;
    
    buffer.allocate( raw_image_size );
    
    dng_pixel_buffer pixel_buffer;
    
    pixel_buffer.fArea        = dng_rect(size.v, size.h);
    pixel_buffer.fPlane       = 0;
    pixel_buffer.fPlanes      = 1;
    pixel_buffer.fRowStep     = size.h;
    pixel_buffer.fColStep     = pixel_buffer.fPlanes;
    pixel_buffer.fPlaneStep   = 1;
    pixel_buffer.fPixelType   = ttShort;
    pixel_buffer.fPixelSize   = TagTypeSize(ttShort);
    
    pixel_buffer.fData        = buffer.get_buffer();
    
    raw_image.Get(pixel_buffer);
}

void CopyBufferToRawImage( const gpr_buffer_auto& buffer, size_t stride, dng_image& raw_image )
{
    dng_pixel_buffer pixel_buffer;
    
    dng_point size = raw_image.Bounds().Size();
    
    pixel_buffer.fArea        = dng_rect(size.v, size.h);
    pixel_buffer.fPlane       = 0;
    pixel_buffer.fPlanes      = 1;
    pixel_buffer.fRowStep     = stride;
    pixel_buffer.fColStep     = pixel_buffer.fPlanes;
    pixel_buffer.fPlaneStep   = 1;
    pixel_buffer.fPixelType   = ttShort;
    pixel_buffer.fPixelSize   = TagTypeSize(ttShort);
    
    pixel_buffer.fData        = buffer.get_buffer();
    
    raw_image.Put(pixel_buffer);
}