/* Copyright (c) 2013 "LliureX" Framebuffer boot splash This file is part of Bootcookie. Bootcookie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "gfx.hpp" #include "framebuffer.hpp" #include #include #include #include using namespace net::lliurex::bootcookie; using namespace std; Palette::Palette() { /* default palette is a linear grey shading*/ for(int n=0;n<256;n++) { red[n]=n; green[n]=n; blue[n]=n; } } void Palette::Load(const char * filename) { ifstream pfile (filename); int r,g,b; int index = 0; while(pfile.good() && index<256) { pfile>>r>>g>>b; //cout<<"color("<red[n]; g = green - this->green[n]; b = blue - this->blue[n]; value = (r*r) + (g*g) + (b*b); value=sqrt(value); if(valuepalette; f=fopen(filename,"rb"); fread(buffer,1,18,f); xorig=buffer[8]+(buffer[9]<<8); yorig=buffer[10]+(buffer[11]<<8); width=buffer[12]+(buffer[13]<<8); height=buffer[14]+(buffer[15]<<8); /* ToDo: TGA may contain a variable length meta data before image */ /* 8-BIT RLE Encoded*/ if(buffer[1]==1 && buffer[2]==TGA_TYPE_8BPP_RLE) { } /* RGB RLE Encoded */ if(buffer[2]==TGA_TYPE_RGB_RLE) { } /* Uncompressed RGB*/ if(buffer[2]==TGA_TYPE_RGB) { //cout<<"Surface: Uncompressed RGB"<MatchColor(r,g,b); } } break; case 32: //cout<<"Surface: RGB 32-bit"<MatchColor(r,g,b); } } break; } } fclose(f); } Surface::~Surface() { delete [] pixels; }