Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members   Examples  

ImageCanvasExample.cpp

This example shows how to use ImageCanvas to easily load images and blit them onto an SDL_Srface.

#include "SDL_Tools.h"
#include "ImageCanvas.h"

void testImageCanvas(SDL_Surface* dest) {
  SDL_Rect rctDst;
  rctDst.x = 320;
  rctDst.y = 240;

  //Create an Image canvas object:
  ImageCanvas ic;
  //Load the image to display:
  ic.loadImage("Caveman.bmp");

  //Blit the image onto the screen using SDL:
  SDL_BlitSurface(ic, ic.getImageRect(), dest, &rctDst);
}

int main(int argc, char* args[]) {
  /* Initialize SDL */
  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    return 1;
  }

  SDL_Surface* screen = createScreen(640, 480, "ImageCanvas test", SDL_HWSURFACE | SDL_DOUBLEBUF);

  testImageCanvas(screen);

  SDL_Quit();

  return 0;
}

Generated on Mon May 26 22:13:18 2003 for SDL Isometric Engine by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002