Advertisement
Vchavauty

Surface.cpp

Jul 26th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include "Surface.h"
  2.  
  3.  
  4. SDL_Surface * MySurface::OnLoad(char *File)
  5. {
  6.     SDL_Surface *Temp = NULL;
  7.     SDL_Surface *Res = NULL;
  8.     if((Temp = SDL_LoadBMP(File)) == NULL)
  9.     {
  10.         return NULL;
  11.     }
  12.     Res = SDL_DisplayFormat(Temp);
  13.     SDL_FreeSurface(Temp);
  14.     return Res;
  15. }
  16.  
  17. bool MySurface::OnDraw(SDL_Surface *Main, SDL_Surface *Src, int X, int Y)
  18. {
  19.     if(Main == NULL || Src == NULL)
  20.     {
  21.         return false;
  22.     }
  23.     SDL_Rect MainR;
  24.     MainR.x = X;
  25.     MainR.y = Y;
  26.     SDL_BlitSurface(Src, NULL, Main, &MainR);
  27.     return true;
  28. }
  29. bool MySurface::OnDraw(SDL_Surface *Main, SDL_Surface *Src, int X, int Y, int X2, int Y2, int W, int H)
  30. {
  31.     if(Main == NULL || Src == NULL)
  32.     {
  33.         return false;
  34.     }
  35.     SDL_Rect MainR;
  36.     MainR.x = X;
  37.     MainR.y = Y;
  38.     SDL_Rect SrcR;
  39.     SrcR.x = X2;
  40.     SrcR.y = Y2;
  41.     SrcR.h = H;
  42.     SrcR.w = W;
  43.     SDL_BlitSurface(Src, &SrcR, Main, &MainR);
  44.     return true;
  45. }
  46.  
  47. bool MySurface::Transparent(SDL_Surface *Surface, int R, int G, int B)
  48. {
  49.     if(Surface == NULL)
  50.     {
  51.         return false;
  52.     }
  53.     SDL_SetColorKey(Surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(Surface->format, R, G, B));
  54.     return true;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement