Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*!
  2.   \file Draw_Pixel.c
  3.   \author Mario Palomo <mpalomo@ihman.com>
  4.   \author Jose M. de la Huerga Fernández
  5.   \author Pepe González Mora
  6.   \date 05-2002
  7.  
  8.   This library is free software; you can redistribute it and/or
  9.   modify it under the terms of the GNU Library General Public
  10.   License as published by the Free Software Foundation; either
  11.   version 2 of the License, or (at your option) any later version.
  12.  
  13.   This library is distributed in the hope that it will be useful,
  14.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.   Library General Public License for more details.
  17.  
  18.   You should have received a copy of the GNU Library General Public
  19.   License along with this library; if not, write to the Free Foundation,
  20.   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #define SDL_DRAW_PUTPIXEL_BPP(A, B, C)  \
  23. *(##A##(##B##(Uint8*)super->pixels + y*super->pitch + x*SDL_DRAW_BPP))=##C##;
  24.  
  25. #if SDL_DRAW_BPP == 1
  26. #define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP(0+,0+,(Uint8)color)
  27.  
  28. #elif SDL_DRAW_BPP == 2
  29. #define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint16*),0+,(Uint16)color)
  30.  
  31. #elif SDL_DRAW_BPP == 3
  32. #define SDL_DRAW_PUTPIXEL \
  33.   SDL_DRAW_PUTPIXEL_BPP(0+,1+,colorbyte1)   \
  34.   if (SDL_BYTEORDER == SDL_BIG_ENDIAN) {         \
  35.     SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte2)   \
  36.     SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte0) \
  37.   }else{                                         \
  38.     SDL_DRAW_PUTPIXEL_BPP(0+,0+,colorbyte0)   \
  39.     SDL_DRAW_PUTPIXEL_BPP(0+,2+,colorbyte2) \
  40.   }
  41.  
  42. #elif SDL_DRAW_BPP == 4
  43. #define SDL_DRAW_PUTPIXEL SDL_DRAW_PUTPIXEL_BPP((Uint32*),0+,color)
  44.  
  45. #endif /*SDL_DRAW_BPP*/
  46.  
  47.  
  48. void SDL_DRAWFUNCTION(SDL_Surface *super,
  49.                       Sint16 x, Sint16 y, Uint32 color)
  50. {
  51. #if SDL_DRAW_BPP == 3
  52.   Uint8 colorbyte0 = (Uint8) (color & 0xff);
  53.   Uint8 colorbyte1 = (Uint8) ((color >> 8) & 0xff);
  54.   Uint8 colorbyte2 = (Uint8) ((color >> 16) & 0xff);
  55. #endif
  56.  
  57.   SDL_DRAW_PUTPIXEL
  58.  
  59. }/*Draw_Pixel*/
  60.  
  61.  
  62. #undef SDL_DRAW_PUTPIXEL
  63. #undef SDL_DRAW_PUTPIXEL_BPP
  64.  
  65.