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 ();
}
}