/src/dng_sdk/source/dng_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_image.cpp#1 $ */ |
10 | | /* $DateTime: 2012/05/30 13:28:51 $ */ |
11 | | /* $Change: 832332 $ */ |
12 | | /* $Author: tknoll $ */ |
13 | | |
14 | | /*****************************************************************************/ |
15 | | |
16 | | #include "dng_image.h" |
17 | | |
18 | | #include "dng_assertions.h" |
19 | | #include "dng_exceptions.h" |
20 | | #include "dng_orientation.h" |
21 | | #include "dng_pixel_buffer.h" |
22 | | #include "dng_tag_types.h" |
23 | | #include "dng_tile_iterator.h" |
24 | | #include "dng_utils.h" |
25 | | |
26 | | /*****************************************************************************/ |
27 | | |
28 | | dng_tile_buffer::dng_tile_buffer (const dng_image &image, |
29 | | const dng_rect &tile, |
30 | | bool dirty) |
31 | | |
32 | 5.23M | : fImage (image) |
33 | 5.23M | , fRefData (NULL) |
34 | | |
35 | 5.23M | { |
36 | | |
37 | 5.23M | fImage.AcquireTileBuffer (*this, |
38 | 5.23M | tile, |
39 | 5.23M | dirty); |
40 | | |
41 | 5.23M | } |
42 | | |
43 | | /*****************************************************************************/ |
44 | | |
45 | | dng_tile_buffer::~dng_tile_buffer () |
46 | 5.23M | { |
47 | | |
48 | 5.23M | fImage.ReleaseTileBuffer (*this); |
49 | | |
50 | 5.23M | } |
51 | | |
52 | | /*****************************************************************************/ |
53 | | |
54 | | dng_const_tile_buffer::dng_const_tile_buffer (const dng_image &image, |
55 | | const dng_rect &tile) |
56 | | |
57 | 3.45M | : dng_tile_buffer (image, tile, false) |
58 | | |
59 | 3.45M | { |
60 | | |
61 | 3.45M | } |
62 | | |
63 | | /*****************************************************************************/ |
64 | | |
65 | | dng_const_tile_buffer::~dng_const_tile_buffer () |
66 | | { |
67 | | |
68 | | } |
69 | | |
70 | | /*****************************************************************************/ |
71 | | |
72 | | dng_dirty_tile_buffer::dng_dirty_tile_buffer (dng_image &image, |
73 | | const dng_rect &tile) |
74 | | |
75 | 1.78M | : dng_tile_buffer (image, tile, true) |
76 | | |
77 | 1.78M | { |
78 | | |
79 | 1.78M | } |
80 | | |
81 | | /*****************************************************************************/ |
82 | | |
83 | | dng_dirty_tile_buffer::~dng_dirty_tile_buffer () |
84 | | { |
85 | | |
86 | | } |
87 | | |
88 | | /*****************************************************************************/ |
89 | | |
90 | | dng_image::dng_image (const dng_rect &bounds, |
91 | | uint32 planes, |
92 | | uint32 pixelType) |
93 | | |
94 | 86.7k | : fBounds (bounds) |
95 | 86.7k | , fPlanes (planes) |
96 | 86.7k | , fPixelType (pixelType) |
97 | | |
98 | 86.7k | { |
99 | | |
100 | 86.7k | if (bounds.IsEmpty () || planes == 0 || PixelSize () == 0) |
101 | 685 | { |
102 | | |
103 | | #if qDNGValidate |
104 | | |
105 | | ReportError ("Fuzz: Attempt to create zero size image"); |
106 | | |
107 | | #endif |
108 | | |
109 | 685 | ThrowBadFormat (); |
110 | | |
111 | 685 | } |
112 | | |
113 | 86.7k | } |
114 | | |
115 | | /*****************************************************************************/ |
116 | | |
117 | | dng_image::~dng_image () |
118 | 86.1k | { |
119 | | |
120 | 86.1k | } |
121 | | |
122 | | /*****************************************************************************/ |
123 | | |
124 | | dng_image * dng_image::Clone () const |
125 | 0 | { |
126 | | |
127 | 0 | ThrowProgramError ("Clone is not supported by this dng_image subclass"); |
128 | |
|
129 | 0 | return NULL; |
130 | | |
131 | 0 | } |
132 | | |
133 | | /*****************************************************************************/ |
134 | | |
135 | | void dng_image::SetPixelType (uint32 pixelType) |
136 | 0 | { |
137 | | |
138 | 0 | if (TagTypeSize (pixelType) != PixelSize ()) |
139 | 0 | { |
140 | | |
141 | 0 | ThrowProgramError ("Cannot change pixel size for existing image"); |
142 | | |
143 | 0 | } |
144 | | |
145 | 0 | fPixelType = pixelType; |
146 | | |
147 | 0 | } |
148 | | |
149 | | /*****************************************************************************/ |
150 | | |
151 | | uint32 dng_image::PixelSize () const |
152 | 95.7k | { |
153 | | |
154 | 95.7k | return TagTypeSize (PixelType ()); |
155 | | |
156 | 95.7k | } |
157 | | |
158 | | /*****************************************************************************/ |
159 | | |
160 | | uint32 dng_image::PixelRange () const |
161 | 335k | { |
162 | | |
163 | 335k | switch (fPixelType) |
164 | 335k | { |
165 | | |
166 | 0 | case ttByte: |
167 | 0 | case ttSByte: |
168 | 0 | { |
169 | 0 | return 0x0FF; |
170 | 0 | } |
171 | | |
172 | 335k | case ttShort: |
173 | 335k | case ttSShort: |
174 | 335k | { |
175 | 335k | return 0x0FFFF; |
176 | 335k | } |
177 | | |
178 | 0 | case ttLong: |
179 | 0 | case ttSLong: |
180 | 0 | { |
181 | 0 | return 0xFFFFFFFF; |
182 | 0 | } |
183 | | |
184 | 0 | default: |
185 | 0 | break; |
186 | | |
187 | 335k | } |
188 | | |
189 | 0 | return 0; |
190 | | |
191 | 335k | } |
192 | | |
193 | | /*****************************************************************************/ |
194 | | |
195 | | dng_rect dng_image::RepeatingTile () const |
196 | 5.07M | { |
197 | | |
198 | 5.07M | return fBounds; |
199 | | |
200 | 5.07M | } |
201 | | |
202 | | /*****************************************************************************/ |
203 | | |
204 | | void dng_image::AcquireTileBuffer (dng_tile_buffer & /* buffer */, |
205 | | const dng_rect & /* area */, |
206 | | bool /* dirty */) const |
207 | 0 | { |
208 | | |
209 | 0 | ThrowProgramError (); |
210 | | |
211 | 0 | } |
212 | | |
213 | | /*****************************************************************************/ |
214 | | |
215 | | void dng_image::ReleaseTileBuffer (dng_tile_buffer & /* buffer */) const |
216 | 5.23M | { |
217 | | |
218 | 5.23M | } |
219 | | |
220 | | /*****************************************************************************/ |
221 | | |
222 | | void dng_image::DoGet (dng_pixel_buffer &buffer) const |
223 | 3.31M | { |
224 | | |
225 | 3.31M | dng_rect tile; |
226 | | |
227 | 3.31M | dng_tile_iterator iter (*this, buffer.fArea); |
228 | | |
229 | 6.63M | while (iter.GetOneTile (tile)) |
230 | 3.31M | { |
231 | | |
232 | 3.31M | dng_const_tile_buffer tileBuffer (*this, tile); |
233 | | |
234 | 3.31M | buffer.CopyArea (tileBuffer, |
235 | 3.31M | tile, |
236 | 3.31M | buffer.fPlane, |
237 | 3.31M | buffer.fPlanes); |
238 | | |
239 | 3.31M | } |
240 | | |
241 | 3.31M | } |
242 | | |
243 | | /*****************************************************************************/ |
244 | | |
245 | | void dng_image::DoPut (const dng_pixel_buffer &buffer) |
246 | 1.65M | { |
247 | | |
248 | 1.65M | dng_rect tile; |
249 | | |
250 | 1.65M | dng_tile_iterator iter (*this, buffer.fArea); |
251 | | |
252 | 3.30M | while (iter.GetOneTile (tile)) |
253 | 1.65M | { |
254 | | |
255 | 1.65M | dng_dirty_tile_buffer tileBuffer (*this, tile); |
256 | | |
257 | 1.65M | tileBuffer.CopyArea (buffer, |
258 | 1.65M | tile, |
259 | 1.65M | buffer.fPlane, |
260 | 1.65M | buffer.fPlanes); |
261 | | |
262 | 1.65M | } |
263 | | |
264 | 1.65M | } |
265 | | |
266 | | /*****************************************************************************/ |
267 | | |
268 | | void dng_image::GetRepeat (dng_pixel_buffer &buffer, |
269 | | const dng_rect &srcArea, |
270 | | const dng_rect &dstArea) const |
271 | 2.21M | { |
272 | | |
273 | | // If we already have the entire srcArea in the |
274 | | // buffer, we can just repeat that. |
275 | | |
276 | 2.21M | if ((srcArea & buffer.fArea) == srcArea) |
277 | 2.21M | { |
278 | | |
279 | 2.21M | buffer.RepeatArea (srcArea, |
280 | 2.21M | dstArea); |
281 | | |
282 | 2.21M | } |
283 | | |
284 | | // Else we first need to get the srcArea into the buffer area. |
285 | | |
286 | 972 | else |
287 | 972 | { |
288 | | |
289 | | // Find repeating pattern size. |
290 | | |
291 | 972 | dng_point repeat = srcArea.Size (); |
292 | | |
293 | | // Find pattern phase at top-left corner of destination area. |
294 | | |
295 | 972 | dng_point phase = dng_pixel_buffer::RepeatPhase (srcArea, |
296 | 972 | dstArea); |
297 | | |
298 | | // Find new source area at top-left of dstArea. |
299 | | |
300 | 972 | dng_rect newArea = srcArea + (dstArea.TL () - |
301 | 972 | srcArea.TL ()); |
302 | | |
303 | | // Find quadrant split coordinates. |
304 | | |
305 | 972 | int32 splitV = newArea.t + repeat.v - phase.v; |
306 | 972 | int32 splitH = newArea.l + repeat.h - phase.h; |
307 | | |
308 | | // Top-left quadrant. |
309 | | |
310 | 972 | dng_rect dst1 (dng_rect (newArea.t, |
311 | 972 | newArea.l, |
312 | 972 | splitV, |
313 | 972 | splitH) & dstArea); |
314 | | |
315 | 972 | if (dst1.NotEmpty ()) |
316 | 972 | { |
317 | | |
318 | 972 | dng_pixel_buffer temp (buffer); |
319 | | |
320 | 972 | temp.fArea = dst1 + (srcArea.TL () - |
321 | 972 | dstArea.TL () + |
322 | 972 | dng_point (phase.v, phase.h)); |
323 | | |
324 | 972 | temp.fData = buffer.DirtyPixel (dst1.t, |
325 | 972 | dst1.l, |
326 | 972 | buffer.fPlane); |
327 | | |
328 | 972 | DoGet (temp); |
329 | | |
330 | 972 | } |
331 | | |
332 | | // Top-right quadrant. |
333 | | |
334 | 972 | dng_rect dst2 (dng_rect (newArea.t, |
335 | 972 | splitH, |
336 | 972 | splitV, |
337 | 972 | newArea.r) & dstArea); |
338 | | |
339 | 972 | if (dst2.NotEmpty ()) |
340 | 0 | { |
341 | | |
342 | 0 | dng_pixel_buffer temp (buffer); |
343 | | |
344 | 0 | temp.fArea = dst2 + (srcArea.TL () - |
345 | 0 | dstArea.TL () + |
346 | 0 | dng_point (phase.v, -phase.h)); |
347 | | |
348 | 0 | temp.fData = buffer.DirtyPixel (dst2.t, |
349 | 0 | dst2.l, |
350 | 0 | buffer.fPlane); |
351 | | |
352 | 0 | DoGet (temp); |
353 | | |
354 | 0 | } |
355 | | |
356 | | // Bottom-left quadrant. |
357 | | |
358 | 972 | dng_rect dst3 (dng_rect (splitV, |
359 | 972 | newArea.l, |
360 | 972 | newArea.b, |
361 | 972 | splitH) & dstArea); |
362 | | |
363 | 972 | if (dst3.NotEmpty ()) |
364 | 0 | { |
365 | | |
366 | 0 | dng_pixel_buffer temp (buffer); |
367 | | |
368 | 0 | temp.fArea = dst3 + (srcArea.TL () - |
369 | 0 | dstArea.TL () + |
370 | 0 | dng_point (-phase.v, phase.h)); |
371 | | |
372 | 0 | temp.fData = buffer.DirtyPixel (dst3.t, |
373 | 0 | dst3.l, |
374 | 0 | buffer.fPlane); |
375 | | |
376 | 0 | DoGet (temp); |
377 | | |
378 | 0 | } |
379 | | |
380 | | // Bottom-right quadrant. |
381 | | |
382 | 972 | dng_rect dst4 (dng_rect (splitV, |
383 | 972 | splitH, |
384 | 972 | newArea.b, |
385 | 972 | newArea.r) & dstArea); |
386 | | |
387 | 972 | if (dst4.NotEmpty ()) |
388 | 0 | { |
389 | | |
390 | 0 | dng_pixel_buffer temp (buffer); |
391 | | |
392 | 0 | temp.fArea = dst4 + (srcArea.TL () - |
393 | 0 | dstArea.TL () + |
394 | 0 | dng_point (-phase.v, -phase.h)); |
395 | | |
396 | 0 | temp.fData = buffer.DirtyPixel (dst4.t, |
397 | 0 | dst4.l, |
398 | 0 | buffer.fPlane); |
399 | | |
400 | 0 | DoGet (temp); |
401 | | |
402 | 0 | } |
403 | | |
404 | | // Replicate this new source area. |
405 | | |
406 | 972 | buffer.RepeatArea (newArea, |
407 | 972 | dstArea); |
408 | | |
409 | 972 | } |
410 | | |
411 | 2.21M | } |
412 | | |
413 | | /*****************************************************************************/ |
414 | | |
415 | | void dng_image::GetEdge (dng_pixel_buffer &buffer, |
416 | | edge_option edgeOption, |
417 | | const dng_rect &srcArea, |
418 | | const dng_rect &dstArea) const |
419 | 2.35M | { |
420 | | |
421 | 2.35M | switch (edgeOption) |
422 | 2.35M | { |
423 | | |
424 | 145k | case edge_zero: |
425 | 145k | { |
426 | | |
427 | 145k | buffer.SetZero (dstArea, |
428 | 145k | buffer.fPlane, |
429 | 145k | buffer.fPlanes); |
430 | | |
431 | 145k | break; |
432 | | |
433 | 0 | } |
434 | | |
435 | 2.21M | case edge_repeat: |
436 | 2.21M | { |
437 | | |
438 | 2.21M | GetRepeat (buffer, |
439 | 2.21M | srcArea, |
440 | 2.21M | dstArea); |
441 | | |
442 | 2.21M | break; |
443 | | |
444 | 0 | } |
445 | | |
446 | 0 | case edge_repeat_zero_last: |
447 | 0 | { |
448 | | |
449 | 0 | if (buffer.fPlanes > 1) |
450 | 0 | { |
451 | | |
452 | 0 | dng_pixel_buffer buffer1 (buffer); |
453 | | |
454 | 0 | buffer1.fPlanes--; |
455 | | |
456 | 0 | GetEdge (buffer1, |
457 | 0 | edge_repeat, |
458 | 0 | srcArea, |
459 | 0 | dstArea); |
460 | | |
461 | 0 | } |
462 | | |
463 | 0 | dng_pixel_buffer buffer2 (buffer); |
464 | | |
465 | 0 | buffer2.fPlane = buffer.fPlanes - 1; |
466 | 0 | buffer2.fPlanes = 1; |
467 | | |
468 | 0 | buffer2.fData = buffer.DirtyPixel (buffer2.fArea.t, |
469 | 0 | buffer2.fArea.l, |
470 | 0 | buffer2.fPlane); |
471 | | |
472 | 0 | GetEdge (buffer2, |
473 | 0 | edge_zero, |
474 | 0 | srcArea, |
475 | 0 | dstArea); |
476 | | |
477 | 0 | break; |
478 | | |
479 | 0 | } |
480 | | |
481 | 0 | default: |
482 | 0 | { |
483 | | |
484 | 0 | ThrowProgramError (); |
485 | | |
486 | 0 | } |
487 | | |
488 | 2.35M | } |
489 | | |
490 | 2.35M | } |
491 | | |
492 | | /*****************************************************************************/ |
493 | | |
494 | | void dng_image::Get (dng_pixel_buffer &buffer, |
495 | | edge_option edgeOption, |
496 | | uint32 repeatV, |
497 | | uint32 repeatH) const |
498 | 3.31M | { |
499 | | |
500 | | // Find the overlap with the image bounds. |
501 | | |
502 | 3.31M | dng_rect overlap = buffer.fArea & fBounds; |
503 | | |
504 | | // Move the overlapping pixels. |
505 | | |
506 | 3.31M | if (overlap.NotEmpty ()) |
507 | 3.31M | { |
508 | | |
509 | 3.31M | dng_pixel_buffer temp (buffer); |
510 | | |
511 | 3.31M | temp.fArea = overlap; |
512 | | |
513 | 3.31M | temp.fData = buffer.DirtyPixel (overlap.t, |
514 | 3.31M | overlap.l, |
515 | 3.31M | buffer.fPlane); |
516 | | |
517 | 3.31M | DoGet (temp); |
518 | | |
519 | 3.31M | } |
520 | | |
521 | | // See if we need to pad the edge values. |
522 | | |
523 | 3.31M | if ((edgeOption != edge_none) && (overlap != buffer.fArea)) |
524 | 863k | { |
525 | | |
526 | 863k | dng_rect areaT (buffer.fArea); |
527 | 863k | dng_rect areaL (buffer.fArea); |
528 | 863k | dng_rect areaB (buffer.fArea); |
529 | 863k | dng_rect areaR (buffer.fArea); |
530 | | |
531 | 863k | areaT.b = Min_int32 (areaT.b, fBounds.t); |
532 | 863k | areaL.r = Min_int32 (areaL.r, fBounds.l); |
533 | 863k | areaB.t = Max_int32 (areaB.t, fBounds.b); |
534 | 863k | areaR.l = Max_int32 (areaR.l, fBounds.r); |
535 | | |
536 | 863k | dng_rect areaH (buffer.fArea); |
537 | 863k | dng_rect areaV (buffer.fArea); |
538 | | |
539 | 863k | areaH.l = Max_int32 (areaH.l, fBounds.l); |
540 | 863k | areaH.r = Min_int32 (areaH.r, fBounds.r); |
541 | | |
542 | 863k | areaV.t = Max_int32 (areaV.t, fBounds.t); |
543 | 863k | areaV.b = Min_int32 (areaV.b, fBounds.b); |
544 | | |
545 | | // Top left. |
546 | | |
547 | 863k | dng_rect areaTL = areaT & areaL; |
548 | | |
549 | 863k | if (areaTL.NotEmpty ()) |
550 | 120k | { |
551 | | |
552 | 120k | GetEdge (buffer, |
553 | 120k | edgeOption, |
554 | 120k | dng_rect (fBounds.t, |
555 | 120k | fBounds.l, |
556 | 120k | fBounds.t + (int32)repeatV, |
557 | 120k | fBounds.l + (int32)repeatH), |
558 | 120k | areaTL); |
559 | | |
560 | 120k | } |
561 | | |
562 | | // Top middle. |
563 | | |
564 | 863k | dng_rect areaTM = areaT & areaH; |
565 | | |
566 | 863k | if (areaTM.NotEmpty ()) |
567 | 687k | { |
568 | | |
569 | 687k | GetEdge (buffer, |
570 | 687k | edgeOption, |
571 | 687k | dng_rect (fBounds.t, |
572 | 687k | areaTM.l, |
573 | 687k | fBounds.t + (int32)repeatV, |
574 | 687k | areaTM.r), |
575 | 687k | areaTM); |
576 | | |
577 | 687k | } |
578 | | |
579 | | // Top right. |
580 | | |
581 | 863k | dng_rect areaTR = areaT & areaR; |
582 | | |
583 | 863k | if (areaTR.NotEmpty ()) |
584 | 121k | { |
585 | | |
586 | 121k | GetEdge (buffer, |
587 | 121k | edgeOption, |
588 | 121k | dng_rect (fBounds.t, |
589 | 121k | fBounds.r - (int32)repeatH, |
590 | 121k | fBounds.t + (int32)repeatV, |
591 | 121k | fBounds.r), |
592 | 121k | areaTR); |
593 | | |
594 | 121k | } |
595 | | |
596 | | // Left middle. |
597 | | |
598 | 863k | dng_rect areaLM = areaL & areaV; |
599 | | |
600 | 863k | if (areaLM.NotEmpty ()) |
601 | 175k | { |
602 | | |
603 | 175k | GetEdge (buffer, |
604 | 175k | edgeOption, |
605 | 175k | dng_rect (areaLM.t, |
606 | 175k | fBounds.l, |
607 | 175k | areaLM.b, |
608 | 175k | fBounds.l + (int32)repeatH), |
609 | 175k | areaLM); |
610 | | |
611 | 175k | } |
612 | | |
613 | | // Right middle. |
614 | | |
615 | 863k | dng_rect areaRM = areaR & areaV; |
616 | | |
617 | 863k | if (areaRM.NotEmpty ()) |
618 | 197k | { |
619 | | |
620 | 197k | GetEdge (buffer, |
621 | 197k | edgeOption, |
622 | 197k | dng_rect (areaRM.t, |
623 | 197k | fBounds.r - (int32)repeatH, |
624 | 197k | areaRM.b, |
625 | 197k | fBounds.r), |
626 | 197k | areaRM); |
627 | | |
628 | 197k | } |
629 | | |
630 | | // Bottom left. |
631 | | |
632 | 863k | dng_rect areaBL = areaB & areaL; |
633 | | |
634 | 863k | if (areaBL.NotEmpty ()) |
635 | 121k | { |
636 | | |
637 | 121k | GetEdge (buffer, |
638 | 121k | edgeOption, |
639 | 121k | dng_rect (fBounds.b - (int32)repeatV, |
640 | 121k | fBounds.l, |
641 | 121k | fBounds.b, |
642 | 121k | fBounds.l + (int32)repeatH), |
643 | 121k | areaBL); |
644 | | |
645 | 121k | } |
646 | | |
647 | | // Bottom middle. |
648 | | |
649 | 863k | dng_rect areaBM = areaB & areaH; |
650 | | |
651 | 863k | if (areaBM.NotEmpty ()) |
652 | 798k | { |
653 | | |
654 | 798k | GetEdge (buffer, |
655 | 798k | edgeOption, |
656 | 798k | dng_rect (fBounds.b - (int32)repeatV, |
657 | 798k | areaBM.l, |
658 | 798k | fBounds.b, |
659 | 798k | areaBM.r), |
660 | 798k | areaBM); |
661 | | |
662 | 798k | } |
663 | | |
664 | | // Bottom right. |
665 | | |
666 | 863k | dng_rect areaBR = areaB & areaR; |
667 | | |
668 | 863k | if (areaBR.NotEmpty ()) |
669 | 135k | { |
670 | | |
671 | 135k | GetEdge (buffer, |
672 | 135k | edgeOption, |
673 | 135k | dng_rect (fBounds.b - (int32)repeatV, |
674 | 135k | fBounds.r - (int32)repeatH, |
675 | 135k | fBounds.b, |
676 | 135k | fBounds.r), |
677 | 135k | areaBR); |
678 | | |
679 | 135k | } |
680 | | |
681 | 863k | } |
682 | | |
683 | 3.31M | } |
684 | | |
685 | | /*****************************************************************************/ |
686 | | |
687 | | void dng_image::Put (const dng_pixel_buffer &buffer) |
688 | 1.65M | { |
689 | | |
690 | | // Move the overlapping pixels. |
691 | | |
692 | 1.65M | dng_rect overlap = buffer.fArea & fBounds; |
693 | | |
694 | 1.65M | if (overlap.NotEmpty ()) |
695 | 1.65M | { |
696 | | |
697 | 1.65M | dng_pixel_buffer temp (buffer); |
698 | | |
699 | 1.65M | temp.fArea = overlap; |
700 | | |
701 | 1.65M | temp.fData = (void *) buffer.ConstPixel (overlap.t, |
702 | 1.65M | overlap.l, |
703 | 1.65M | buffer.fPlane); |
704 | | |
705 | | // Move the overlapping planes. |
706 | | |
707 | 1.65M | if (temp.fPlane < Planes ()) |
708 | 1.65M | { |
709 | | |
710 | 1.65M | temp.fPlanes = Min_uint32 (temp.fPlanes, |
711 | 1.65M | Planes () - temp.fPlane); |
712 | | |
713 | 1.65M | DoPut (temp); |
714 | | |
715 | 1.65M | } |
716 | | |
717 | 1.65M | } |
718 | | |
719 | 1.65M | } |
720 | | |
721 | | /*****************************************************************************/ |
722 | | |
723 | | void dng_image::Trim (const dng_rect &r) |
724 | 0 | { |
725 | | |
726 | 0 | if (r != Bounds ()) |
727 | 0 | { |
728 | | |
729 | 0 | ThrowProgramError ("Trim is not support by this dng_image subclass"); |
730 | | |
731 | 0 | } |
732 | | |
733 | 0 | } |
734 | | |
735 | | /*****************************************************************************/ |
736 | | |
737 | | void dng_image::Rotate (const dng_orientation &orientation) |
738 | 0 | { |
739 | | |
740 | 0 | if (orientation != dng_orientation::Normal ()) |
741 | 0 | { |
742 | | |
743 | 0 | ThrowProgramError ("Rotate is not support by this dng_image subclass"); |
744 | | |
745 | 0 | } |
746 | | |
747 | 0 | } |
748 | | |
749 | | /*****************************************************************************/ |
750 | | |
751 | | void dng_image::CopyArea (const dng_image &src, |
752 | | const dng_rect &area, |
753 | | uint32 srcPlane, |
754 | | uint32 dstPlane, |
755 | | uint32 planes) |
756 | 0 | { |
757 | |
|
758 | 0 | if (&src == this) |
759 | 0 | return; |
760 | | |
761 | 0 | dng_tile_iterator destIter(*this, area); |
762 | 0 | dng_rect destTileArea; |
763 | |
|
764 | 0 | while (destIter.GetOneTile(destTileArea)) |
765 | 0 | { |
766 | 0 | dng_tile_iterator srcIter(src, destTileArea); |
767 | 0 | dng_rect srcTileArea; |
768 | |
|
769 | 0 | while (srcIter.GetOneTile(srcTileArea)) |
770 | 0 | { |
771 | |
|
772 | 0 | dng_dirty_tile_buffer destTile(*this, srcTileArea); |
773 | 0 | dng_const_tile_buffer srcTile(src, srcTileArea); |
774 | |
|
775 | 0 | destTile.CopyArea (srcTile, srcTileArea, srcPlane, dstPlane, planes); |
776 | |
|
777 | 0 | } |
778 | |
|
779 | 0 | } |
780 | |
|
781 | 0 | } |
782 | | |
783 | | /*****************************************************************************/ |
784 | | |
785 | | bool dng_image::EqualArea (const dng_image &src, |
786 | | const dng_rect &area, |
787 | | uint32 plane, |
788 | | uint32 planes) const |
789 | 0 | { |
790 | |
|
791 | 0 | if (&src == this) |
792 | 0 | return true; |
793 | | |
794 | 0 | dng_tile_iterator destIter (*this, area); |
795 | | |
796 | 0 | dng_rect destTileArea; |
797 | |
|
798 | 0 | while (destIter.GetOneTile (destTileArea)) |
799 | 0 | { |
800 | | |
801 | 0 | dng_tile_iterator srcIter (src, destTileArea); |
802 | | |
803 | 0 | dng_rect srcTileArea; |
804 | |
|
805 | 0 | while (srcIter.GetOneTile (srcTileArea)) |
806 | 0 | { |
807 | |
|
808 | 0 | dng_const_tile_buffer destTile (*this, srcTileArea); |
809 | 0 | dng_const_tile_buffer srcTile (src , srcTileArea); |
810 | |
|
811 | 0 | if (!destTile.EqualArea (srcTile, srcTileArea, plane, planes)) |
812 | 0 | { |
813 | 0 | return false; |
814 | 0 | } |
815 | |
|
816 | 0 | } |
817 | |
|
818 | 0 | } |
819 | | |
820 | 0 | return true; |
821 | |
|
822 | 0 | } |
823 | | |
824 | | /*****************************************************************************/ |
825 | | |
826 | | void dng_image::SetConstant (uint32 value, |
827 | | const dng_rect &area) |
828 | 0 | { |
829 | | |
830 | 0 | dng_tile_iterator iter (*this, area); |
831 | | |
832 | 0 | dng_rect tileArea; |
833 | | |
834 | 0 | while (iter.GetOneTile (tileArea)) |
835 | 0 | { |
836 | | |
837 | 0 | dng_dirty_tile_buffer buffer (*this, tileArea); |
838 | | |
839 | 0 | buffer.SetConstant (tileArea, |
840 | 0 | 0, |
841 | 0 | fPlanes, |
842 | 0 | value); |
843 | | |
844 | 0 | } |
845 | |
|
846 | 0 | } |
847 | | |
848 | | /*****************************************************************************/ |