Some files 'astylized' + slight cleanup

This commit is contained in:
Hombre57
2017-08-22 00:15:56 +02:00
parent f75bed1bfa
commit 81932ba2d6
4 changed files with 53 additions and 38 deletions

View File

@@ -27,7 +27,7 @@ Alpha::Alpha () {}
Alpha::Alpha (int width, int height)
{
if (width > 0 && height > 0) {
surface = Cairo::ImageSurface::create(Cairo::FORMAT_A8, width, height);
surface = Cairo::ImageSurface::create (Cairo::FORMAT_A8, width, height);
}
}
@@ -37,7 +37,7 @@ Alpha::~Alpha () {
}
*/
void Alpha::setSize(int width, int height)
void Alpha::setSize (int width, int height)
{
if (width > 0 && height > 0) {
if (surface) {
@@ -48,7 +48,7 @@ void Alpha::setSize(int width, int height)
}
}
surface = Cairo::ImageSurface::create(Cairo::FORMAT_A8, width, height);
surface = Cairo::ImageSurface::create (Cairo::FORMAT_A8, width, height);
} else if (surface) {
surface.clear();
}
@@ -72,4 +72,25 @@ int Alpha::getHeight()
return -1;
}
Cairo::RefPtr<Cairo::ImageSurface> Alpha::getSurface ()
{
return surface; // to be used in bitmap edition
}
unsigned char Alpha::operator () (unsigned row, unsigned col) const
{
return * (surface->get_data () + row * surface->get_width () + col);
}
unsigned char& Alpha::operator () (unsigned row, unsigned col)
{
return * (surface->get_data () + row * surface->get_width () + col);
}
unsigned char* Alpha::operator () (unsigned row) const
{
return surface->get_data () + row * surface->get_width ();
}
}

View File

@@ -38,11 +38,11 @@ public:
Alpha (int width, int height);
//~Alpha ();
void setSize(int width, int height);
void setSize (int width, int height);
int getWidth();
int getHeight();
const Cairo::RefPtr<Cairo::ImageSurface> getSurface ();
Cairo::RefPtr<Cairo::ImageSurface> getSurface ();
// TODO: to make the editing faster, we should add an iterator class
@@ -50,28 +50,9 @@ public:
unsigned char* operator () (unsigned row) const;
// Will send back a value at a given row, col position
unsigned char& operator () (unsigned row, unsigned col);
const unsigned char operator () (unsigned row, unsigned col) const;
unsigned char operator () (unsigned row, unsigned col) const;
};
inline const Cairo::RefPtr<Cairo::ImageSurface> Alpha::getSurface () {
return surface; // to be used in bitmap edition
}
inline const unsigned char Alpha::operator () (unsigned row,
unsigned col) const {
return *(surface->get_data () + row * surface->get_width () + col);
}
inline unsigned char& Alpha::operator () (unsigned row, unsigned col) {
return *(surface->get_data () + row * surface->get_width () + col);
}
inline unsigned char* Alpha::operator () (unsigned row) const {
return surface->get_data () + row * surface->get_width ();
}
}
#endif

View File

@@ -79,9 +79,11 @@ void ImProcFunctions::removeSpots (Imagefloat* img, const std::vector<SpotEntry>
// scaled spot is too small, we do not preview it
if (scaledFeatherRadius < 2 && pp.getSkip() != 1) {
#ifndef NDEBUG
if (options.rtSettings.verbose) {
printf ("Skipping spot located at %d x %d, too small for the preview zoom rate\n", entry.sourcePos.x, entry.sourcePos.y);
}
#endif
continue;
}
@@ -89,9 +91,11 @@ void ImProcFunctions::removeSpots (Imagefloat* img, const std::vector<SpotEntry>
// skipping entries totally transparent
if (entry.opacity == 0.) {
#ifndef NDEBUG
if (options.rtSettings.verbose) {
printf ("Skipping spot located at %d x %d: opacity=%.3f\n", entry.sourcePos.x, entry.sourcePos.y, entry.opacity);
}
continue;
#endif
}
@@ -99,11 +103,13 @@ void ImProcFunctions::removeSpots (Imagefloat* img, const std::vector<SpotEntry>
// skipping entries where the source circle isn't completely inside the image bounds
if (src_XMin < 0 || src_XMax >= img->getWidth() || src_YMin < 0 || src_YMax >= img->getHeight()) {
#ifndef NDEBUG
if (options.rtSettings.verbose) {
printf ("Skipping spot located at %d x %d, from the data at %d x %d, radius=%d, feather=%.3f, opacity=%.3f: source out of bounds\n", entry.sourcePos.x, entry.sourcePos.y, entry.targetPos.x, entry.targetPos.y, entry.radius, entry.feather, entry.opacity);
printf ("%d < 0 || %d >= %d || %d < 0 || %d >= %d\n",
src_XMin, src_XMax, img->getWidth(), src_YMin, src_YMax, img->getHeight());
}
#endif
continue;
}
@@ -111,11 +117,13 @@ void ImProcFunctions::removeSpots (Imagefloat* img, const std::vector<SpotEntry>
// skipping entries where the dest circle is completely outside the image bounds
if (dst_XMin >= img->getWidth() || dst_XMax <= 0 || dst_YMin >= img->getHeight() || dst_YMax <= 0) {
#ifndef NDEBUG
if (options.rtSettings.verbose) {
printf ("Skipping spot located at %d x %d, from the data at %d x %d, radius=%d, feather=%.3f, opacity=%.3f: source out of bounds\n", entry.sourcePos.x, entry.sourcePos.y, entry.targetPos.x, entry.targetPos.y, entry.radius, entry.feather, entry.opacity);
printf ("%d >= %d || %d <= 0 || %d >= %d || %d <= 0\n",
dst_XMin, img->getWidth(), dst_XMax, dst_YMin, img->getHeight(), dst_YMax);
}
#endif
continue;
}
@@ -343,10 +351,12 @@ void ImProcFunctions::removeSpots (Imagefloat* img, const std::vector<SpotEntry>
if (i2 < 0 || i2 >= img->getHeight()) {
continue;
}
for (int j = 0, j2 = dst_XMin; j2 < dst_XMax - 1; ++j, ++j2) {
if (j2 < 0 || j2 >= img->getWidth()) {
continue;
}
//float c2 = float (mask (i, j)) / 255.f;
//float c1 = 1.f - c2;
//resultPR->r(i,j) = (unsigned char) CLAMP0255 ( ROUND( double(first->r(i,j)) + double(secondPR->r(i,j)) ) );