snes_palette improvements
This commit is contained in:
@@ -81,6 +81,10 @@ void SNESColor::setRgb(ImVec4 val) {
|
|||||||
snes = ConvertRGBtoSNES(col);
|
snes = ConvertRGBtoSNES(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SNESColor::setRgb(snes_color val) {
|
||||||
|
snes = ConvertRGBtoSNES(val);
|
||||||
|
}
|
||||||
|
|
||||||
void SNESColor::setSNES(uint16_t val) {
|
void SNESColor::setSNES(uint16_t val) {
|
||||||
snes = val;
|
snes = val;
|
||||||
snes_color col = ConvertSNEStoRGB(val);
|
snes_color col = ConvertSNEStoRGB(val);
|
||||||
@@ -130,6 +134,15 @@ SNESPalette::SNESPalette(const std::vector<ImVec4>& cols) {
|
|||||||
size_ = cols.size();
|
size_ = cols.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SNESPalette::SNESPalette(const std::vector<snes_color>& cols) {
|
||||||
|
for (const auto& each : cols) {
|
||||||
|
SNESColor scol;
|
||||||
|
scol.setRgb(each);
|
||||||
|
colors.push_back(scol);
|
||||||
|
}
|
||||||
|
size_ = cols.size();
|
||||||
|
}
|
||||||
|
|
||||||
char* SNESPalette::encode() {
|
char* SNESPalette::encode() {
|
||||||
auto data = new char[size_ * 2];
|
auto data = new char[size_ * 2];
|
||||||
for (unsigned int i = 0; i < size_; i++) {
|
for (unsigned int i = 0; i < size_; i++) {
|
||||||
@@ -141,7 +154,6 @@ char* SNESPalette::encode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_Palette* SNESPalette::GetSDL_Palette() {
|
SDL_Palette* SNESPalette::GetSDL_Palette() {
|
||||||
std::cout << "Converting SNESPalette to SDL_Palette" << std::endl;
|
|
||||||
auto sdl_palette = std::make_shared<SDL_Palette>();
|
auto sdl_palette = std::make_shared<SDL_Palette>();
|
||||||
sdl_palette->ncolors = size_;
|
sdl_palette->ncolors = size_;
|
||||||
|
|
||||||
@@ -154,8 +166,6 @@ SDL_Palette* SNESPalette::GetSDL_Palette() {
|
|||||||
<< " G:" << color[i].g << " B:" << color[i].b << ")" << std::endl;
|
<< " G:" << color[i].g << " B:" << color[i].b << ")" << std::endl;
|
||||||
}
|
}
|
||||||
sdl_palette->colors = color.data();
|
sdl_palette->colors = color.data();
|
||||||
colors_.push_back(color);
|
|
||||||
|
|
||||||
return sdl_palette.get();
|
return sdl_palette.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ struct SNESColor {
|
|||||||
uint16_t snes = 0;
|
uint16_t snes = 0;
|
||||||
ImVec4 rgb;
|
ImVec4 rgb;
|
||||||
void setRgb(ImVec4);
|
void setRgb(ImVec4);
|
||||||
|
void setRgb(snes_color);
|
||||||
void setSNES(uint16_t);
|
void setSNES(uint16_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,14 +54,13 @@ class SNESPalette {
|
|||||||
explicit SNESPalette(char* snesPal);
|
explicit SNESPalette(char* snesPal);
|
||||||
explicit SNESPalette(const unsigned char* snes_pal);
|
explicit SNESPalette(const unsigned char* snes_pal);
|
||||||
explicit SNESPalette(const std::vector<ImVec4>&);
|
explicit SNESPalette(const std::vector<ImVec4>&);
|
||||||
|
explicit SNESPalette(const std::vector<snes_color>&);
|
||||||
|
|
||||||
char* encode();
|
char* encode();
|
||||||
SDL_Palette* GetSDL_Palette();
|
SDL_Palette* GetSDL_Palette();
|
||||||
|
|
||||||
int size_ = 0;
|
int size_ = 0;
|
||||||
std::vector<SNESColor> colors;
|
std::vector<SNESColor> colors;
|
||||||
std::vector<SDL_Color*> colors_arrays_;
|
|
||||||
std::vector<std::vector<SDL_Color>> colors_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gfx
|
} // namespace gfx
|
||||||
|
|||||||
Reference in New Issue
Block a user