Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "ByteMap.h"
- #include "ColorPalette256.h"
- class ColorIndexMap : public ByteMap, public Mipmapable<ColorIndexMap>
- {
- public:
- ColorIndexMap::ColorIndexMap(int width, int height) : ByteMap(width, height) {
- }
- ColorIndexMap::ColorIndexMap(int width, int height, ColorPalette256 & palette) : ByteMap(width, height) {
- setColorPalette(palette);
- }
- ColorIndexMap::~ColorIndexMap(void) {
- }
- void setColorPalette(ColorPalette256 & palette) {
- for (int i = 0; i < 256; i++) {
- mapPalette.setPaletteColor(i, palette.getPaletteColor(i));
- }
- }
- ColorPalette256* getColorPalette() {
- return &mapPalette;
- }
- Color getColorAt(int x, int y) {
- return mapPalette.getPaletteColor(getByte(x, y));
- }
- ColorIndexMap* makeMipMap(void) {
- int width = getWidth() / 2;
- int height = getHeight() / 2;
- ColorIndexMap* mipMap = new ColorIndexMap(width, height);
- for (int x = 0; x < width; x++) {
- for (int y = 0; y < height; y++) {
- mipMap->setByte(x, y, getByte(2 * x, 2 * y));
- }
- }
- return mipMap;
- }
- private:
- ColorPalette256 mapPalette;
- };
Advertisement
Add Comment
Please, Sign In to add comment