예제 #1
0
ImageObject* SDLImageObject::themeSDLImageObjectLoader( const string fname, InifileSection* iniSec, const ThemeLoadOptions& op )
{
  SDLImageObject* im = new SDLImageObject;
  im->loadImage( fname );
  if ( im->isLoaded() ) {
    int sw = iniSec->keyIntValue( "sectionwidth", 0 );
    int sh = iniSec->keyIntValue( "sectionheight", 0 );
		int a = iniSec->keyIntValue( "alpha", 255 );
    if ( (sw != 0) && (sh != 0) ) {
      im->setSectionWidht( sw );
      im->setSectionHeight( sh );
    }
		if ( iniSec->keyIndex( "colorkey" ) >= 0 ) {
			Color c;
			Utils::fromString( iniSec->keyStringValue( "colorkey", "" ), c );
			SDL_SetColorKey( im->getSurface(), SDL_SRCCOLORKEY, SDL_MapRGB( im->getSurface()->format, c.getR(), c.getG(), c.getB() ) );
			if ( (c.getA() != 255) && ( a == 255 ) )
				a = c.getA();
			else
				im->setAlpha( 255 );
		}
		if ( a != 255 )
			im->setAlpha( a );

    return (ImageObject*)im;
  } else {
    delete im;
    return NULL;
  }
}
예제 #2
0
void SDLImageObject::drawImageStreched( ImageObject &image, const Rect& dr, const Rect &sr )
{
  Rect dr2 = dr;
  dr2.left += pRelX;
  dr2.top += pRelY;
  visDebug( dr2 );
  updated = true;
  SDLImageObject *i = (SDLImageObject*)ℑ

//  cout << "* Ui::SDLDrawInterface::drawImageTiled(  )" << endl;
  pushClipRect( dr2 );
  if ( clipRect().area() <= 0 ) {
    popClipRect();
    return;
  }

  SDL_Rect *sdldr = new SDL_Rect;

  //clipRect().debug( "drawImage" );

  double fnumx, fnumy;
  int numx, numy;

  fnumx = (double)dr.width / (double)i->width();
  fnumy = (double)dr.height / (double)i->height();

  numx = (int)ceil( fnumx );
  numy = (int)ceil( fnumy );

  sdldr->w = i->width();
  sdldr->h = i->height();

  SDL_Rect *sdlsr = NULL;
  if ( sr != NULL_RECT ) {
    sdlsr = new SDL_Rect;
    sdlsr->x = sr.left;
    sdlsr->y = sr.top;
    sdlsr->w = sr.width;
    sdlsr->h = sr.height;
  }

  int x, y;
  for( y = 0; y < numy; y++ ) {
    for( x = 0; x < numx; x++ ) {
      sdldr->x = dr2.left + x * i->width();
      sdldr->y = dr2.top + y * i->height();

      SDL_BlitSurface( i->getSurface(), sdlsr, s, sdldr );
    }
  }

  popClipRect();
  delete sdldr;

}
예제 #3
0
void SDLImageObject::drawImage( ImageObject &image, const Rect& dr, const Rect &sr )
{
  Rect dr2 = dr;
  dr2.left += pRelX;
  dr2.top += pRelY;
  visDebug( dr2 );
  updated = true;
  SDLImageObject *i = (SDLImageObject*)&image;

//  cout << "* Ui::SDLDrawInterface::drawImage(  )" << endl;
  pushClipRect( dr2 );
  if ( clipRect().area() <= 0 ) {
    popClipRect();
    return;
  }

  SDL_Rect *sdldr = new SDL_Rect;

  sdldr->x = dr2.left;
  sdldr->y = dr2.top;
  if ( dr2.width == 0 ) {
    sdldr->w = image.width();
  } else {
    sdldr->w = dr2.width;
  }
  if ( dr2.height == 0 ) {
    sdldr->h = image.height();
  } else {
    sdldr->h = dr2.height;
  }

  SDL_Rect *sdlsr = NULL;
  if ( sr != NULL_RECT ) {
    sdlsr = new SDL_Rect;
    sdlsr->x = sr.left;
    sdlsr->y = sr.top;
    sdlsr->w = sr.width;
    sdlsr->h = sr.height;
  }

  SDL_BlitSurface( i->getSurface(), sdlsr, s, sdldr );

  popClipRect();
  delete sdldr;

}