Coverage Report

Created: 2026-07-25 06:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dng_sdk/source/dng_simple_image.cpp
Line
Count
Source
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
105k
  : dng_image (bounds,
31
105k
           planes,
32
105k
           pixelType)
33
           
34
105k
  , fMemory    ()
35
105k
  , fAllocator (allocator)
36
           
37
105k
  {
38
  
39
105k
  uint32 bytes =
40
105k
    ComputeBufferSize (pixelType, bounds.Size (), planes, pad16Bytes);
41
           
42
105k
  fMemory.Reset (allocator.Allocate (bytes));
43
  
44
105k
  fBuffer = dng_pixel_buffer (bounds, 0, planes, pixelType, pcInterleaved, fMemory->Buffer ());
45
  
46
105k
  }
47
48
/*****************************************************************************/
49
50
dng_simple_image::~dng_simple_image ()
51
104k
  {
52
  
53
104k
  }
54
55
/*****************************************************************************/
56
57
dng_image * dng_simple_image::Clone () const
58
14.9k
  {
59
  
60
14.9k
  AutoPtr<dng_simple_image> result (new dng_simple_image (Bounds (),
61
14.9k
                              Planes (),
62
14.9k
                              PixelType (),
63
14.9k
                              fAllocator));
64
                              
65
14.9k
  result->fBuffer.CopyArea (fBuffer,
66
14.9k
                Bounds (),
67
14.9k
                0,
68
14.9k
                Planes ());
69
                              
70
14.9k
  return result.Release ();
71
  
72
14.9k
  }
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
514
  {
89
  
90
514
  fBounds.t = 0;
91
514
  fBounds.l = 0;
92
  
93
514
  fBounds.b = r.H ();
94
514
  fBounds.r = r.W ();
95
  
96
514
  fBuffer.fData = fBuffer.DirtyPixel (r.t, r.l);
97
                   
98
514
  fBuffer.fArea = fBounds;
99
  
100
514
  }
101
    
102
/*****************************************************************************/
103
104
void dng_simple_image::Rotate (const dng_orientation &orientation)
105
3.98k
  {
106
  
107
3.98k
  int32 originH = fBounds.l;
108
3.98k
  int32 originV = fBounds.t;
109
  
110
3.98k
  int32 colStep = fBuffer.fColStep;
111
3.98k
  int32 rowStep = fBuffer.fRowStep;
112
  
113
3.98k
  uint32 width  = fBounds.W ();
114
3.98k
  uint32 height = fBounds.H ();
115
  
116
3.98k
  if (orientation.FlipH ())
117
133
    {
118
    
119
133
    originH += width - 1;
120
    
121
133
    colStep = -colStep;
122
    
123
133
    }
124
125
3.98k
  if (orientation.FlipV ())
126
56
    {
127
    
128
56
    originV += height - 1;
129
    
130
56
    rowStep = -rowStep;
131
    
132
56
    }
133
    
134
3.98k
  if (orientation.FlipD ())
135
122
    {
136
    
137
122
    int32 temp = colStep;
138
    
139
122
    colStep = rowStep;
140
122
    rowStep = temp;
141
    
142
122
    width  = fBounds.H ();
143
122
    height = fBounds.W ();
144
    
145
122
    }
146
    
147
3.98k
  fBuffer.fData = fBuffer.DirtyPixel (originV, originH);
148
  
149
3.98k
  fBuffer.fColStep = colStep;
150
3.98k
  fBuffer.fRowStep = rowStep;
151
    
152
3.98k
  fBounds.r = fBounds.l + width;
153
3.98k
  fBounds.b = fBounds.t + height;
154
  
155
3.98k
  fBuffer.fArea = fBounds;
156
                
157
3.98k
  }
158
    
159
/*****************************************************************************/
160
161
void dng_simple_image::AcquireTileBuffer (dng_tile_buffer &buffer,
162
                      const dng_rect &area,
163
                      bool dirty) const
164
7.00M
  {
165
  
166
7.00M
  buffer.fArea = area;
167
  
168
7.00M
  buffer.fPlane      = fBuffer.fPlane;
169
7.00M
  buffer.fPlanes     = fBuffer.fPlanes;
170
7.00M
  buffer.fRowStep    = fBuffer.fRowStep;
171
7.00M
  buffer.fColStep    = fBuffer.fColStep;
172
7.00M
  buffer.fPlaneStep  = fBuffer.fPlaneStep;
173
7.00M
  buffer.fPixelType  = fBuffer.fPixelType;
174
7.00M
  buffer.fPixelSize  = fBuffer.fPixelSize;
175
176
7.00M
  buffer.fData = (void *) fBuffer.ConstPixel (buffer.fArea.t,
177
7.00M
                          buffer.fArea.l,
178
7.00M
                          buffer.fPlane);
179
                      
180
7.00M
  buffer.fDirty = dirty;
181
                  
182
7.00M
  }
183
    
184
/*****************************************************************************/
185