Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
28 KB
Referenced Files
None
Subscribers
None
diff --git a/util/ftalleg.cpp b/util/ftalleg.cpp
index 28159f9e..cac19e3f 100644
--- a/util/ftalleg.cpp
+++ b/util/ftalleg.cpp
@@ -1,520 +1,522 @@
/*
--------------
About
--------------
A Freetype wrapper for use with allegro
Feel free to do whatever you like with this, by all means enjoy!
Just add it to your project
--------------
Linking
--------------
on linux:
g++ `freetype-config --cflags` ftalleg.cpp myfiles.cpp `freetype-config --libs` `allegro-config --libs`
on windows (you may need to include the freetype dir location, ie -Ic:/mingw/include):
g++ ftalleg.cpp myfiles.cpp -lfreetype -lalleg
--------------
Disclaimer
--------------
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE
SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef FT_FONT_CPP
#define FT_FONT_CPP
#include "bitmap.h"
/*
#include <allegro.h>
#ifdef _WIN32
#include <winalleg.h>
#endif
*/
#include "ftalleg.h"
#include <iostream>
#include <sstream>
#include <cassert>
#include <exception>
namespace ftalleg{
Exception::Exception():
std::exception(){
}
Exception::Exception(const std::string reason):
std::exception(),
reason(reason){
}
Exception::~Exception() throw(){
}
// typedef void (*pixeler)( BITMAP * bitmap, int x, int y, int color );
static int fixColor(const unsigned char *c,short grays){
// Safety checks
assert(c != 0);
assert(grays != 1);
// invariant: c can be dereferenced safely
// invariant: (grays - 1) != 0, thus it can be used as divisor.
int red = *c * 255 / (grays - 1);
int green = *c * 255 / (grays - 1);
int blue = *c * 255 / (grays - 1);
//alpha = *c * 255 / (grays - 1);
return Bitmap::makeColor(red,green,blue);
}
// Static count of instances of fonts to track library
static int instances=0;
static FT_Library ftLibrary = 0;
character::character() {
}
character::~character() {
// if(line)delete [] line;
}
fontSize::fontSize() {
width = height = italics = angle = 0;
}
fontSize::~fontSize() {
}
bool fontSize::operator<(const fontSize &fs) const {
return (width<fs.width || height<fs.height || italics<fs.italics);
}
/* im not sure this is a very unique key.. */
int fontSize::createKey() const {
return ((width+10) * (height+20) * (italics+250));
}
//! Constructor
freetype::freetype(const Filesystem::AbsolutePath & str, const int x, const int y ){
//Load library
if ( !ftLibrary ){
FT_Init_FreeType(&ftLibrary);
}
instances++;
faceLoaded = kerning = false;
currentIndex=0;
currentFilename="";
faceName="";
currentChar = new character;
systemName="";
internalFix = false;
this->load(str, 0, x, y );
}
//! Destructor
freetype::~freetype(){
//if(face!=NULL)FT_Done_Face(face);
if ( instances > 0 ){
instances--;
}
if ( instances == 0 ){
FT_Done_FreeType( ftLibrary );
}
if ( currentChar ){
delete currentChar;
}
}
// Extract glyph
character freetype::extractGlyph(signed long unicode){
int w, h, ew;
character tempChar;
// Translate it according to the given italics
double italics = (double)(size.italics)*GLYPH_PI/180;
FT_Matrix matrix;
matrix.xx = 0x10000L;
matrix.xy = (FT_Fixed)( sin( italics ) * (GLYPH_SQRT2*0x10000L) );
matrix.yx = 0;
matrix.yy = 0x10000L;
FT_Set_Transform( face, &matrix, 0 );
FT_Load_Char(face, unicode, FT_LOAD_TARGET_NORMAL | FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT);
w = face->glyph->bitmap.width;
h = face->glyph->bitmap.rows;
ew = 0;
if (!w)ew = 1;
if (!h)h = 1;
tempChar.width = (w + ew);
tempChar.height = h;
tempChar.rows = face->glyph->bitmap.rows;
tempChar.grays = face->glyph->bitmap.num_grays;
tempChar.pitch = face->glyph->bitmap.pitch;
tempChar.line = new unsigned char[tempChar.rows * tempChar.pitch];
memcpy(tempChar.line,face->glyph->bitmap.buffer,tempChar.rows * tempChar.pitch);
tempChar.left = face->glyph->bitmap_left;
tempChar.top = face->glyph->bitmap_top;
tempChar.right = face->glyph->advance.x >> 6;
tempChar.unicode = unicode;
tempChar.length = ((w + ew)+face->glyph->advance.x) >> 6;
return tempChar;
}
// Create single index
void freetype::createIndex(){
std::map<int, std::map<signed long, character> >::iterator p;
p = fontTable.find(size.createKey());
if ( p == fontTable.end() ){
FT_Set_Pixel_Sizes(face, size.width, size.height);
FT_UInt g;
FT_ULong unicode = FT_Get_First_Char(face, &g);
std::map<signed long, character>tempMap;
while ( g ){
tempMap.insert(std::make_pair(unicode,extractGlyph(unicode)));
unicode = FT_Get_Next_Char(face, unicode, &g);
}
fontTable.insert(std::make_pair(size.createKey(),tempMap));
}
if (fontTable.find(size.createKey()) == fontTable.end()){
printf("ftalleg: inconsistency error\n");
throw std::exception();
}
}
/*
pixeler getPutPixel(){
switch( get_color_depth() ){
case 8 : return _putpixel;
case 15 : return _putpixel15;
case 16 : return _putpixel16;
case 24 : return _putpixel24;
case 32 : return _putpixel32;
default : return putpixel;
}
}
*/
// Render a character from the lookup table
void freetype::drawCharacter(signed long unicode, int &x1, int &y1, const Bitmap & bitmap, const int &color){
// pixeler putter = getPutPixel();
std::map<int, std::map<signed long, character> >::iterator ft;
ft = fontTable.find(size.createKey());
if ( ft!=fontTable.end() ){
std::map<signed long, character>::iterator p;
p = (ft->second).find(unicode);
- if(p!=(ft->second).end())
- {
+ if(p!=(ft->second).end()){
const character & tempChar = p->second;
unsigned char *line = tempChar.line;
- for (int y = 0; y < tempChar.rows; y++)
- {
+ for (int y = 0; y < tempChar.rows; y++){
unsigned char *buffer = line;
- for (int x = 0; x < tempChar.width; x++)
- {
+ for (int x = 0; x < tempChar.width; x++){
int col = fixColor(buffer++,tempChar.grays);
- if((Bitmap::getRed(col)< 50) || (Bitmap::getGreen(col)< 50) || (Bitmap::getBlue(col)< 50))continue;
+ if ((Bitmap::getRed(col) < 50) ||
+ (Bitmap::getGreen(col) < 50) ||
+ (Bitmap::getBlue(col) < 50)){
+ continue;
+ }
+
int red = Bitmap::getRed(col) * Bitmap::getRed(color) / 255;
int green = Bitmap::getGreen(col) * Bitmap::getGreen(color) / 255;
int blue = Bitmap::getBlue(col) * Bitmap::getBlue(color) / 255;
//col.alpha= col.alpha * color.alpha / 255;
// putpixel(bitmap,x1+tempChar.left+x,y1 - tempChar.top+y + size.height,makecol(red,blue,green));
/* dangerous! putter is probably one of the _putpixel* routines so if x or y are off the bitmap
* you will get a segfault
*/
// putter(bitmap,x1+tempChar.left+x,y1 - tempChar.top+y + size.height,makecol(red,blue,green));
// putter = 0;
bitmap.putPixelNormal(x1+tempChar.left+x,y1 - tempChar.top + y + size.height, Bitmap::makeColor(red,green,blue));
}
line += tempChar.pitch;
}
- x1+=tempChar.right;
+ x1 += tempChar.right;
}
}
}
//! Load font from memory
bool freetype::load(const unsigned char *memoryFont, unsigned int length, int index, unsigned int width, unsigned int height)
{
if(!FT_New_Memory_Face(ftLibrary,memoryFont, length,index,&face))
{
currentFilename = "memoryFont";
currentIndex = index;
faceLoaded = true;
size.italics = 0;
setSize(width, height);
if(FT_HAS_GLYPH_NAMES(face))
{
char buff[1024];
if(!FT_Get_Glyph_Name(face,currentIndex,buff,sizeof(buff)))
{
faceName = currentFilename;
}
else faceName = std::string(buff);
}
else
{
faceName = currentFilename;
}
if(FT_HAS_KERNING(face))kerning=true;
else kerning = false;
}
else
{
faceLoaded=false;
std::cout << "Load system font failed\n";
}
return faceLoaded;
}
//! Load font from file
bool freetype::load(const Filesystem::AbsolutePath & filename, int index, unsigned int width, unsigned int height){
if(!FT_New_Face(ftLibrary,filename.path().c_str(), index, &face)) {
currentFilename = filename.path();
currentIndex = index;
faceLoaded = true;
size.italics = 0;
setSize(width, height);
if(FT_HAS_GLYPH_NAMES(face)){
char buff[1024];
if(!FT_Get_Glyph_Name(face,currentIndex,buff,sizeof(buff))) {
faceName = currentFilename;
}
else faceName = std::string(buff);
} else {
faceName = currentFilename;
}
if(FT_HAS_KERNING(face))kerning=true;
else kerning = false;
} else {
faceLoaded=false;
}
return faceLoaded;
}
//! Get text length
int freetype::getLength(const std::string & text)
{
int length=0;
std::map<int, std::map<signed long, character> >::iterator ft;
ft = fontTable.find(size.createKey());
if(ft!=fontTable.end())
{
for(unsigned int i = 0; i<text.length();++i)
{
std::map<signed long, character>::iterator p;
p = (ft->second).find(text[i]);
if(p!=(ft->second).end())
{
if(p!=fontTable[size.createKey()].end())
{
length+=(p->second).length;
}
}
}
}
return length;
}
//! Render font to a bitmap
void freetype::render(int x, int y, const int & color, const Bitmap & bmp, ftAlign alignment, const std::string & text, int marker ...)
{
if(faceLoaded)
{
int rend_x=0;
int rend_y=0;
std::ostringstream str;
// Get extra arguments
va_list ap;
va_start(ap,marker);
for(unsigned int i = 0; i<text.length();++i)
{
if(text[i]=='%')
{
if(text[i+1]=='s')
{
str << va_arg(ap,char *);
++i;
}
else if(text[i+1]=='d'||text[i+1]=='i')
{
str << va_arg(ap,signed int);
++i;
}
else if(text[i+1]=='c')
{
str << (char)va_arg(ap,int);
++i;
}
else str << text[i];
}
else
{
str << text[i];
}
}
va_end(ap);
std::string fixedText(str.str());
switch(alignment)
{
case ftLeft:
rend_x=x;
rend_y=y;
break;
case ftCenter:
rend_x = x - getLength(fixedText)/2;
rend_y=y;
break;
case ftRight:
rend_x = x - getLength(fixedText);
rend_y=y;
break;
default:
rend_x=x;
rend_y=y;
break;
}
int previous = 0;
int next = 0;
for(unsigned int i = 0; i<fixedText.length();++i){
if(kerning && previous && next){
next = FT_Get_Char_Index( face, fixedText[i] );
FT_Vector delta;
FT_Get_Kerning( face, previous, next, FT_KERNING_DEFAULT, &delta );
rend_x += delta.x >> 6;
previous = next;
}
drawCharacter(fixedText[i],rend_x, rend_y, bmp, color);
}
}
}
int freetype::calculateMaximumHeight(){
std::map<int, std::map<signed long, character> >::iterator ft;
ft = fontTable.find(size.createKey());
int top = 0;
long code = 0;
if ( ft != fontTable.end() ){
std::map<signed long, character>::iterator p;
std::map< signed long, character > & map = ft->second;
for ( p = map.begin(); p != map.end(); p++ ){
const character & ch = p->second;
printf( "%c( %ld ). top = %d. rows = %d. total = %d\n", (char) ch.unicode, ch.unicode, ch.top, ch.rows, ch.top + ch.rows );
if ( ch.top + ch.rows > top ){
code = ch.unicode;
top = ch.top + ch.rows;
}
}
}
printf( "Largest letter = %ld\n", code );
return top;
}
int freetype::height( long code ) const {
std::map<int, std::map<signed long, character> >::const_iterator ft;
ft = fontTable.find( size.createKey() );
if ( ft != fontTable.end() ){
std::map<signed long, character>::const_iterator p;
p = (ft->second).find( code );
if ( p != (ft->second).end() ){
const character & temp = p->second;
// printf( "%c top = %d rows = %d\n", (char) code, temp.top, temp.rows );
return temp.top + temp.rows;
}
} else {
throw Exception("Internal inconsistency");
}
return 0;
}
int freetype::calculateHeight( const std::string & str ) const {
int max = 0;
for ( unsigned int i = 0; i < str.length(); i++ ){
int q = height( str[ i ] );
// printf( "Height of %c is %d\n", str[ i ], q );
if ( q > max ){
max = q;
}
}
return max;
}
//! Set size
void freetype::setSize( unsigned int w, unsigned int h){
if ( w != size.width || h != size.height ){
if (internalFix)return;
if (w<=0 || h<=0)return;
size.width = w;
size.height = h;
createIndex();
// maximumHeight = calculateMaximumHeight();
}
}
//! Set italics
void freetype::setItalics(int i){
if(internalFix)return;
if(i<-45)i=(-45);
else if(i>45)i=45;
size.italics = i;
createIndex();
}
void freetype::getSize(int * w, int * h) const {
*w = size.width;
*h = size.height;
}
//! Get Width
int freetype::getWidth() const {
return size.width;
}
//! Get Height
int freetype::getHeight( const std::string & str ) const {
// return size.height;
return calculateHeight( str );
}
//! Get Italics
int freetype::getItalics()
{
return size.italics;
}
}
#endif /* FONT_BASE_CPP */
diff --git a/util/sdl/bitmap.cpp b/util/sdl/bitmap.cpp
index 782f4b5e..c0105e50 100644
--- a/util/sdl/bitmap.cpp
+++ b/util/sdl/bitmap.cpp
@@ -1,499 +1,551 @@
#include "../bitmap.h"
#include "../lit_bitmap.h"
#include <SDL.h>
#include <SDL_image.h>
#include <exception>
static const int FULLSCREEN = 0;
/* bits per pixel */
static int SCREEN_DEPTH = 16;
static SDL_Surface * screen;
/* TODO: fix MaskColor */
const int Bitmap::MaskColor = 0;
Bitmap * Bitmap::Screen = NULL;
static Bitmap * Scaler = NULL;
static Bitmap * Buffer = NULL;
Bitmap::Bitmap():
own(NULL){
/* TODO */
}
Bitmap::Bitmap(SDL_Surface * who, bool deep_copy):
own(NULL){
getData().setSurface(who);
}
Bitmap::Bitmap(int w, int h){
getData().setSurface(SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, SCREEN_DEPTH, 0, 0, 0, 0));
own = new int;
*own = 1;
}
Bitmap::Bitmap( const char * load_file ):
own(NULL){
internalLoadFile(load_file);
}
Bitmap::Bitmap( const std::string & load_file ):
own(NULL){
internalLoadFile(load_file.c_str());
}
Bitmap::Bitmap( const char * load_file, int sx, int sy ):
own(NULL){
/* TODO */
}
Bitmap::Bitmap( const char * load_file, int sx, int sy, double accuracy ):
own(NULL){
/* TODO */
}
Bitmap::Bitmap( const Bitmap & copy, bool deep_copy):
own(NULL){
/* TODO */
}
Bitmap::Bitmap( const Bitmap & copy, int sx, int sy ):
own(NULL){
/* TODO */
}
Bitmap::Bitmap( const Bitmap & copy, int sx, int sy, double accuracy ):
own(NULL){
/* TODO */
}
Bitmap::Bitmap( const Bitmap & copy, int x, int y, int width, int height ):
own(NULL){
/* TODO */
}
void Bitmap::internalLoadFile(const char * path){
this->path = path;
SDL_Surface * loaded = IMG_Load(path);
if (loaded){
getData().setSurface(SDL_DisplayFormat(loaded));
SDL_FreeSurface(loaded);
} else {
/* FIXME: throw a standard bitmap exception */
throw std::exception();
}
own = new int;
*own = 1;
}
int Bitmap::getWidth() const {
if (getData().getSurface() != NULL){
return getData().getSurface()->w;
}
return 0;
}
int Bitmap::getHeight() const {
if (getData().getSurface() != NULL){
return getData().getSurface()->h;
}
return 0;
}
int Bitmap::getRed(int c){
- /* TODO */
- return 0;
+ Uint8 red = 0;
+ Uint8 green = 0;
+ Uint8 blue = 0;
+ SDL_GetRGB(c, Screen->getData().getSurface()->format, &red, &green, &blue);
+ return red;
}
int Bitmap::getBlue(int c){
- /* TODO */
- return 0;
+ Uint8 red = 0;
+ Uint8 green = 0;
+ Uint8 blue = 0;
+ SDL_GetRGB(c, Screen->getData().getSurface()->format, &red, &green, &blue);
+ return blue;
}
int Bitmap::getGreen(int c){
- /* TODO */
- return 0;
+ Uint8 red = 0;
+ Uint8 green = 0;
+ Uint8 blue = 0;
+ SDL_GetRGB(c, Screen->getData().getSurface()->format, &red, &green, &blue);
+ return green;
}
int Bitmap::makeColor(int red, int blue, int green){
- /* TODO */
- return 0;
+ return SDL_MapRGB(Screen->getData().getSurface()->format, red, blue, green);
}
int Bitmap::setGraphicsMode(int mode, int width, int height){
switch (mode){
default: {
// case WINDOWED : {
screen = SDL_SetVideoMode(width, height, SCREEN_DEPTH, SDL_HWSURFACE | SDL_DOUBLEBUF);
// screen = SDL_SetVideoMode(width, height, SCREEN_DEPTH, SDL_SWSURFACE | SDL_DOUBLEBUF);
if (!screen){
return 1;
}
break;
}
}
if (SCALE_X == 0){
SCALE_X = width;
}
if (SCALE_Y == 0){
SCALE_Y = height;
}
if ( Screen != NULL ){
delete Screen;
Screen = NULL;
}
if ( Scaler != NULL ){
delete Scaler;
Scaler = NULL;
}
if ( Buffer != NULL ){
delete Buffer;
Buffer = NULL;
}
if (width != 0 && height != 0){
Screen = new Bitmap(screen);
if ( width != 0 && height != 0 && (width != SCALE_X || height != SCALE_Y) ){
Scaler = new Bitmap(width, height);
Buffer = new Bitmap(SCALE_X, SCALE_Y);
}
}
return 0;
}
void Bitmap::addBlender( int r, int g, int b, int a ){
/* TODO */
}
void Bitmap::multiplyBlender( int r, int g, int b, int a ){
/* TODO */
}
void Bitmap::differenceBlender( int r, int g, int b, int a ){
/* TODO */
}
Bitmap & Bitmap::operator=(const Bitmap &){
/* TODO */
return *this;
}
int Bitmap::setGfxModeText(){
/* TODO */
return 0;
}
int Bitmap::setGfxModeFullscreen(int x, int y){
return setGraphicsMode(FULLSCREEN, x, y);
}
void Bitmap::drawingMode(int type){
/* TODO */
}
void Bitmap::transBlender( int r, int g, int b, int a ){
/* TODO */
}
void Bitmap::setClipRect( int x1, int y1, int x2, int y2 ) const{
/* TODO */
}
void Bitmap::destroyPrivateData(){
SDL_FreeSurface(getData().surface);
}
-void Bitmap::putPixel( int x, int y, int col ) const {
- /* TODO */
+void Bitmap::putPixel(int x, int y, int pixel) const {
+ SDL_Surface * surface = getData().getSurface();
+
+ /* clip it */
+ if (x < 0 || y < 0 ||
+ x >= surface->w ||
+ y >= surface->h){
+ return;
+ }
+
+ if (SDL_MUSTLOCK(surface)){
+ SDL_LockSurface(surface);
+ }
+
+ int bpp = surface->format->BytesPerPixel;
+ /* Here p is the address to the pixel we want to set */
+ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
+
+ switch(bpp) {
+ case 1:
+ *p = pixel;
+ break;
+
+ case 2:
+ *(Uint16 *)p = pixel;
+ break;
+
+ case 3:
+ if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
+ p[0] = (pixel >> 16) & 0xff;
+ p[1] = (pixel >> 8) & 0xff;
+ p[2] = pixel & 0xff;
+ } else {
+ p[0] = pixel & 0xff;
+ p[1] = (pixel >> 8) & 0xff;
+ p[2] = (pixel >> 16) & 0xff;
+ }
+ break;
+ case 4:
+ *(Uint32 *)p = pixel;
+ break;
+ }
+
+ if (SDL_MUSTLOCK(surface)){
+ SDL_UnlockSurface(surface);
+ }
}
void Bitmap::putPixelNormal(int x, int y, int col) const {
- /* TODO */
+ putPixel(x, y, col);
}
bool Bitmap::getError(){
/* TODO */
return false;
}
void Bitmap::border( int min, int max, int color ) const {
/* TODO */
}
void Bitmap::rectangle( int x1, int y1, int x2, int y2, int color ) const {
/* TODO */
}
void Bitmap::rectangleFill( int x1, int y1, int x2, int y2, int color ) const {
/* TODO */
}
void Bitmap::circleFill( int x, int y, int radius, int color ) const {
/* TODO */
}
void Bitmap::circle( int x, int y, int radius, int color ) const {
/* TODO */
}
void Bitmap::line( const int x1, const int y1, const int x2, const int y2, const int color ) const {
/* TODO */
}
void Bitmap::draw(const int x, const int y, const Bitmap & where) const {
/* TODO */
}
void Bitmap::draw(const int x, const int y, const int startWidth, const int startHeight, const int width, const int height, const Bitmap & where) const {
/* TODO */
}
void Bitmap::drawHFlip(const int x, const int y, const Bitmap & where) const {
/* TODO */
}
void Bitmap::drawHFlip(const int x, const int y, const int startWidth, const int startHeight, const int width, const int height, const Bitmap & where) const {
/* TODO */
}
void Bitmap::drawVFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::drawHVFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::drawTrans( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::drawTransHFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::drawTransVFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::drawTransHVFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::drawMask( const int x, const int y, const Bitmap & where ){
/* TODO */
}
void Bitmap::drawStretched( const int x, const int y, const int new_width, const int new_height, const Bitmap & who ){
/* TODO */
}
void Bitmap::Blit( const std::string & xpath ) const {
/* TODO */
}
void Bitmap::Blit( const Bitmap & where ) const {
Blit(0, 0, where);
}
void Bitmap::Blit( const int x, const int y, const Bitmap & where ) const {
Blit(x, y, 0, 0, where);
}
void Bitmap::Blit( const int mx, const int my, const int wx, const int wy, const Bitmap & where ) const {
Blit(mx, my, getWidth(), getHeight(), wx, wy, where);
}
void Bitmap::Blit( const int mx, const int my, const int width, const int height, const int wx, const int wy, const Bitmap & where ) const {
SDL_Rect source;
SDL_Rect destination;
source.w = width;
source.h = height;
source.x = mx;
source.y = my;
destination.w = width;
destination.h = height;
destination.x = wx;
destination.y = wy;
SDL_BlitSurface(getData().getSurface(), &source, where.getData().getSurface(), &destination);
}
void Bitmap::BlitMasked( const int mx, const int my, const int width, const int height, const int wx, const int wy, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::BlitToScreen(const int upper_left_x, const int upper_left_y) const {
if ( Scaler == NULL ){
this->Blit( upper_left_x, upper_left_y, *Screen );
} else {
this->Blit( upper_left_x, upper_left_y, *Buffer );
Buffer->Stretch(*Scaler);
Scaler->Blit(0, 0, 0, 0, *Screen);
}
SDL_Flip(Screen->getData().getSurface());
// SDL_UpdateRect(Screen->getData().getSurface(), 0, 0, Screen->getWidth(), Screen->getHeight());
}
void Bitmap::BlitAreaToScreen(const int upper_left_x, const int upper_left_y) const {
/* TODO */
}
void Bitmap::BlitFromScreen(const int x, const int y) const {
/* TODO */
}
void Bitmap::Stretch( const Bitmap & where ) const {
/* TODO */
if (getWidth() == where.getWidth() && getHeight() == where.getHeight()){
Blit(where);
} else {
SDL_Rect area;
area.x = 0;
area.y = 0;
area.w = 100;
area.h = 100;
SDL_FillRect(where.getData().getSurface(), &area, SDL_MapRGB(where.getData().getSurface()->format, 255, 0, 0));
}
}
void Bitmap::Stretch( const Bitmap & where, const int sourceX, const int sourceY, const int sourceWidth, const int sourceHeight, const int destX, const int destY, const int destWidth, const int destHeight ) const {
/* TODO */
}
void Bitmap::save( const std::string & str ){
/* TODO */
}
void Bitmap::triangle( int x1, int y1, int x2, int y2, int x3, int y3, int color ) const {
/* TODO */
}
void Bitmap::ellipse( int x, int y, int rx, int ry, int color ) const {
/* TODO */
}
void Bitmap::ellipseFill( int x, int y, int rx, int ry, int color ) const {
/* TODO */
}
void Bitmap::light(int x, int y, int width, int height, int start_y, int focus_alpha, int edge_alpha, int focus_color, int edge_color) const {
/* TODO */
}
void Bitmap::applyTrans(const int color){
/* TODO */
}
void Bitmap::floodfill( const int x, const int y, const int color ) const {
/* TODO */
}
void Bitmap::horizontalLine( const int x1, const int y, const int x2, const int color ) const {
/* TODO */
}
void Bitmap::hLine( const int x1, const int y, const int x2, const int color ) const {
/* TODO */
}
void Bitmap::vLine( const int y1, const int x, const int y2, const int color ) const {
/* TODO */
}
void Bitmap::polygon( const int * verts, const int nverts, const int color ) const {
/* TODO */
}
void Bitmap::arc(const int x, const int y, const double ang1, const double ang2, const int radius, const int color ) const {
/* TODO */
}
void Bitmap::fill( int color ) const {
/* TODO */
}
int Bitmap::darken( int color, double factor ){
/* TODO */
return color;
}
Bitmap Bitmap::greyScale(){
/* TODO */
return *this;
}
void Bitmap::drawCharacter( const int x, const int y, const int color, const int background, const Bitmap & where ) const {
/* TODO */
}
void Bitmap::drawRotate( const int x, const int y, const int angle, const Bitmap & where ){
/* TODO */
}
void Bitmap::drawPivot( const int centerX, const int centerY, const int x, const int y, const int angle, const Bitmap & where ){
/* TODO */
}
void Bitmap::drawPivot( const int centerX, const int centerY, const int x, const int y, const int angle, const double scale, const Bitmap & where ){
/* TODO */
}
Bitmap Bitmap::memoryPCX(unsigned char * const data, const int length, const bool mask){
/* TODO */
return Bitmap();
}
int Bitmap::getPixel( const int x, const int y ) const {
/* TODO */
return 0;
}
void Bitmap::readLine( std::vector< int > & vec, int y ){
/* TODO */
}
void Bitmap::StretchBy2( const Bitmap & where ){
/* TODO */
}
void Bitmap::StretchBy4( const Bitmap & where ){
/* TODO */
}
LitBitmap::LitBitmap( const Bitmap & b ){
/* TODO */
}
LitBitmap::LitBitmap(){
/* TODO */
}
LitBitmap::~LitBitmap(){
/* TODO */
}
void LitBitmap::draw( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void LitBitmap::drawHFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void LitBitmap::drawVFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}
void LitBitmap::drawHVFlip( const int x, const int y, const Bitmap & where ) const {
/* TODO */
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 1:09 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69177
Default Alt Text
(28 KB)

Event Timeline