mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 17:34:40 +02:00
Implemented stream output for RGBAColor
In commit 950518f3
I changed the component type of RGBAColor from
16-bit to 8-bit integers. Unfortunately, in C++ 8-bit integers are
identical to characters, so this broke the writing of colors to
output streams.
This commit is contained in:
parent
69d6c0006c
commit
79dcc8a146
@ -549,15 +549,8 @@ void GMenu2X::writeSkinConfig() {
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < NUM_COLORS; ++i) {
|
for (i = 0; i < NUM_COLORS; ++i) {
|
||||||
inf << colorToString((enum color)i) << "=#";
|
inf << colorToString((enum color)i) << "=#"
|
||||||
inf.width(2); inf.fill('0');
|
<< skinConfColors[i] << endl;
|
||||||
inf << right << hex << skinConfColors[i].r;
|
|
||||||
inf.width(2); inf.fill('0');
|
|
||||||
inf << right << hex << skinConfColors[i].g;
|
|
||||||
inf.width(2); inf.fill('0');
|
|
||||||
inf << right << hex << skinConfColors[i].b;
|
|
||||||
inf.width(2); inf.fill('0');
|
|
||||||
inf << right << hex << skinConfColors[i].a << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inf.close();
|
inf.close();
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iomanip>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -44,6 +44,19 @@ RGBAColor RGBAColor::fromString(const string &strColor) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ostream& operator<<(ostream& os, RGBAColor const& color) {
|
||||||
|
auto oldfill = os.fill('0');
|
||||||
|
auto oldflags = os.setf(ios::hex | ios::right,
|
||||||
|
ios::basefield | ios::adjustfield);
|
||||||
|
os << setw(2) << uint32_t(color.r)
|
||||||
|
<< setw(2) << uint32_t(color.g)
|
||||||
|
<< setw(2) << uint32_t(color.b)
|
||||||
|
<< setw(2) << uint32_t(color.a);
|
||||||
|
os.fill(oldfill);
|
||||||
|
os.setf(oldflags);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
Surface *Surface::openOutputSurface(int width, int height, int bitsperpixel) {
|
Surface *Surface::openOutputSurface(int width, int height, int bitsperpixel) {
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
SDL_Surface *raw = SDL_SetVideoMode(
|
SDL_Surface *raw = SDL_SetVideoMode(
|
||||||
|
@ -24,8 +24,10 @@
|
|||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <string>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <ostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
struct RGBAColor {
|
struct RGBAColor {
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
@ -33,10 +35,11 @@ struct RGBAColor {
|
|||||||
RGBAColor() : r(0), g(0), b(0), a(0) {}
|
RGBAColor() : r(0), g(0), b(0), a(0) {}
|
||||||
RGBAColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
|
RGBAColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
|
||||||
: r(r), g(g), b(b), a(a) {}
|
: r(r), g(g), b(b), a(a) {}
|
||||||
Uint32 pixelValue(SDL_PixelFormat *fmt) {
|
Uint32 pixelValue(SDL_PixelFormat *fmt) const {
|
||||||
return SDL_MapRGBA(fmt, r, g, b, a);
|
return SDL_MapRGBA(fmt, r, g, b, a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
std::ostream& operator<<(std::ostream& os, RGBAColor const& color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Wrapper around SDL_Surface
|
Wrapper around SDL_Surface
|
||||||
|
Loading…
Reference in New Issue
Block a user