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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/* ============================================================
*
* This file is a part of digiKam project
* http://www.digikam.org
*
* Date : 2004-12-27
* Description : acess pixels method for lens distortion algorithm.
*
* Copyright (C) 2004-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
* Copyright (C) 2006-2007 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
#ifndef PIXEL_ACCESS_H
#define PIXEL_ACCESS_H
#define PixelAccessRegions 20
#define PixelAccessWidth 40
#define PixelAccessHeight 20
#define PixelAccessXOffset 3
#define PixelAccessYOffset 3
// Digikam includes.
#include "dimg.h"
namespace DigikamLensDistortionImagesPlugin
{
/* PixelAcess class: solving the eternal problem: random, cubic-interpolated,
* sub-pixel coordinate access to an image.
* Assuming that accesses are at least slightly coherent,
* PixelAccess keeps PixelAccessRegions buffers, each containing a
* PixelAccessWidth x PixelAccessHeight region of pixels.
* Buffer[0] is always checked first, so move the last accessed
* region into that position.
* When a request arrives which is outside all the regions,
* get a new region.
* The new region is placed so that the requested pixel is positioned
* at [PixelAccessXOffset, PixelAccessYOffset] in the region.
*/
class PixelAccess
{
public:
PixelAccess(Digikam::DImg *srcImage);
~PixelAccess();
void pixelAccessGetCubic(double srcX, double srcY, double brighten, uchar* dst);
private:
Digikam::DImg *m_image;
//uchar* m_buffer[PixelAccessRegions];
Digikam::DImg *m_buffer[PixelAccessRegions];
int m_width;
int m_height;
int m_depth;
int m_imageWidth;
int m_imageHeight;
bool m_sixteenBit;
int m_tileMinX[PixelAccessRegions];
int m_tileMaxX[PixelAccessRegions];
int m_tileMinY[PixelAccessRegions];
int m_tileMaxY[PixelAccessRegions];
protected:
inline uchar* pixelAccessAddress(int i, int j);
void pixelAccessSelectRegion(int n);
void pixelAccessDoEdge(int i, int j);
void pixelAccessReposition(int xInt, int yInt);
void cubicInterpolate(uchar* src, int rowStride, uchar* dst,
bool sixteenBit, double dx, double dy, double brighten);
};
} // NameSpace DigikamLensDistortionImagesPlugin
#endif /* PIXEL_ACCESS_H */
|