Coverage Report

Created: 2025-07-11 06:42

/src/dng_sdk/source/dng_simple_image.cpp
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************/
2
// Copyright 2006-2008 Adobe Systems Incorporated
3
// All Rights Reserved.
4
//
5
// NOTICE:  Adobe permits you to use, modify, and distribute this file in
6
// accordance with the terms of the Adobe license agreement accompanying it.
7
/*****************************************************************************/
8
9
/* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_simple_image.cpp#1 $ */ 
10
/* $DateTime: 2012/05/30 13:28:51 $ */
11
/* $Change: 832332 $ */
12
/* $Author: tknoll $ */
13
14
/*****************************************************************************/
15
16
#include "dng_simple_image.h"
17
18
#include "dng_memory.h"
19
#include "dng_orientation.h"
20
#include "dng_tag_types.h"
21
#include "dng_tag_values.h"
22
23
/*****************************************************************************/
24
25
dng_simple_image::dng_simple_image (const dng_rect &bounds,
26
                  uint32 planes,
27
                    uint32 pixelType,
28
                    dng_memory_allocator &allocator)
29
                    
30
76.0k
  : dng_image (bounds,
31
76.0k
           planes,
32
76.0k
           pixelType)
33
           
34
76.0k
  , fMemory    ()
35
76.0k
  , fAllocator (allocator)
36
           
37
76.0k
  {
38
  
39
76.0k
  uint32 bytes =
40
76.0k
    ComputeBufferSize (pixelType, bounds.Size (), planes, pad16Bytes);
41
           
42
76.0k
  fMemory.Reset (allocator.Allocate (bytes));
43
  
44
76.0k
  fBuffer = dng_pixel_buffer (bounds, 0, planes, pixelType, pcInterleaved, fMemory->Buffer ());
45
  
46
76.0k
  }
47
48
/*****************************************************************************/
49
50
dng_simple_image::~dng_simple_image ()
51
75.3k
  {
52
  
53
75.3k
  }
54
55
/*****************************************************************************/
56
57
dng_image * dng_simple_image::Clone () const
58
11.8k
  {
59
  
60
11.8k
  AutoPtr<dng_simple_image> result (new dng_simple_image (Bounds (),
61
11.8k
                              Planes (),
62
11.8k
                              PixelType (),
63
11.8k
                              fAllocator));
64
                              
65
11.8k
  result->fBuffer.CopyArea (fBuffer,
66
11.8k
                Bounds (),
67
11.8k
                0,
68
11.8k
                Planes ());
69
                              
70
11.8k
  return result.Release ();
71
  
72
11.8k
  }
73
74
/*****************************************************************************/
75
76
void dng_simple_image::SetPixelType (uint32 pixelType)
77
0
  {
78
  
79
0
  dng_image::SetPixelType (pixelType);
80
  
81
0
  fBuffer.fPixelType = pixelType;
82
  
83
0
  }
84
85
/*****************************************************************************/
86
87
void dng_simple_image::Trim (const dng_rect &r)
88
290
  {
89
  
90
290
  fBounds.t = 0;
91
290
  fBounds.l = 0;
92
  
93
290
  fBounds.b = r.H ();
94
290
  fBounds.r = r.W ();
95
  
96
290
  fBuffer.fData = fBuffer.DirtyPixel (r.t, r.l);
97
                   
98
290
  fBuffer.fArea = fBounds;
99
  
100
290
  }
101
    
102
/*****************************************************************************/
103
104
void dng_simple_image::Rotate (const dng_orientation &orientation)
105
2.90k
  {
106
  
107
2.90k
  int32 originH = fBounds.l;
108
2.90k
  int32 originV = fBounds.t;
109
  
110
2.90k
  int32 colStep = fBuffer.fColStep;
111
2.90k
  int32 rowStep = fBuffer.fRowStep;
112
  
113
2.90k
  uint32 width  = fBounds.W ();
114
2.90k
  uint32 height = fBounds.H ();
115
  
116
2.90k
  if (orientation.FlipH ())
117
65
    {
118
    
119
65
    originH += width - 1;
120
    
121
65
    colStep = -colStep;
122
    
123
65
    }
124
125
2.90k
  if (orientation.FlipV ())
126
40
    {
127
    
128
40
    originV += height - 1;
129
    
130
40
    rowStep = -rowStep;
131
    
132
40
    }
133
    
134
2.90k
  if (orientation.FlipD ())
135
95
    {
136
    
137
95
    int32 temp = colStep;
138
    
139
95
    colStep = rowStep;
140
95
    rowStep = temp;
141
    
142
95
    width  = fBounds.H ();
143
95
    height = fBounds.W ();
144
    
145
95
    }
146
    
147
2.90k
  fBuffer.fData = fBuffer.DirtyPixel (originV, originH);
148
  
149
2.90k
  fBuffer.fColStep = colStep;
150
2.90k
  fBuffer.fRowStep = rowStep;
151
    
152
2.90k
  fBounds.r = fBounds.l + width;
153
2.90k
  fBounds.b = fBounds.t + height;
154
  
155
2.90k
  fBuffer.fArea = fBounds;
156
                
157
2.90k
  }
158
    
159
/*****************************************************************************/
160
161
void dng_simple_image::AcquireTileBuffer (dng_tile_buffer &buffer,
162
                      const dng_rect &area,
163
                      bool dirty) const
164
6.12M
  {
165
  
166
6.12M
  buffer.fArea = area;
167
  
168
6.12M
  buffer.fPlane      = fBuffer.fPlane;
169
6.12M
  buffer.fPlanes     = fBuffer.fPlanes;
170
6.12M
  buffer.fRowStep    = fBuffer.fRowStep;
171
6.12M
  buffer.fColStep    = fBuffer.fColStep;
172
6.12M
  buffer.fPlaneStep  = fBuffer.fPlaneStep;
173
6.12M
  buffer.fPixelType  = fBuffer.fPixelType;
174
6.12M
  buffer.fPixelSize  = fBuffer.fPixelSize;
175
176
6.12M
  buffer.fData = (void *) fBuffer.ConstPixel (buffer.fArea.t,
177
6.12M
                          buffer.fArea.l,
178
6.12M
                          buffer.fPlane);
179
                      
180
6.12M
  buffer.fDirty = dirty;
181
                  
182
6.12M
  }
183
    
184
/*****************************************************************************/
185