aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Platform.h6
-rw-r--r--src/XPM.cxx14
-rw-r--r--src/XPM.h2
3 files changed, 11 insertions, 11 deletions
diff --git a/include/Platform.h b/include/Platform.h
index 92180b354..773ae2439 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -217,15 +217,15 @@ public:
return co;
}
- unsigned int GetRed() const {
+ unsigned char GetRed() const {
return co & 0xff;
}
- unsigned int GetGreen() const {
+ unsigned char GetGreen() const {
return (co >> 8) & 0xff;
}
- unsigned int GetBlue() const {
+ unsigned char GetBlue() const {
return (co >> 16) & 0xff;
}
};
diff --git a/src/XPM.cxx b/src/XPM.cxx
index f83c3d6a8..04dc530bf 100644
--- a/src/XPM.cxx
+++ b/src/XPM.cxx
@@ -105,15 +105,15 @@ void XPM::Init(const char *const *linesForm) {
for (int c=0; c<nColours; c++) {
const char *colourDef = linesForm[c+1];
- int code = static_cast<unsigned char>(colourDef[0]);
+ const char code = colourDef[0];
colourDef += 4;
ColourDesired colour(0xff, 0xff, 0xff);
if (*colourDef == '#') {
colour.Set(colourDef);
} else {
- codeTransparent = static_cast<char>(code);
+ codeTransparent = code;
}
- colourCodeTable[code] = colour;
+ colourCodeTable[static_cast<unsigned char>(code)] = colour;
}
for (int y=0; y<height; y++) {
@@ -152,7 +152,7 @@ void XPM::PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const
transparent = true;
return;
}
- int code = pixels[y * width + x];
+ const int code = pixels[y * width + x];
transparent = code == codeTransparent;
if (transparent) {
colour = ColourDesired(0);
@@ -234,9 +234,9 @@ const unsigned char *RGBAImage::Pixels() const {
void RGBAImage::SetPixel(int x, int y, ColourDesired colour, int alpha) {
unsigned char *pixel = &pixelBytes[0] + (y*width+x) * 4;
// RGBA
- pixel[0] = static_cast<unsigned char>(colour.GetRed());
- pixel[1] = static_cast<unsigned char>(colour.GetGreen());
- pixel[2] = static_cast<unsigned char>(colour.GetBlue());
+ pixel[0] = colour.GetRed();
+ pixel[1] = colour.GetGreen();
+ pixel[2] = colour.GetBlue();
pixel[3] = static_cast<unsigned char>(alpha);
}
diff --git a/src/XPM.h b/src/XPM.h
index a2bd6cb91..2af0ae84e 100644
--- a/src/XPM.h
+++ b/src/XPM.h
@@ -59,7 +59,7 @@ public:
float GetScaledWidth() const { return width / scale; }
int CountBytes() const;
const unsigned char *Pixels() const;
- void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff);
+ void SetPixel(int x, int y, ColourDesired colour, int alpha);
};
/**