PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/xbmc/visualizations/Goom/goom2k4-0/sdl-goom/sdl_pixeldoubler.c

https://bitbucket.org/bgiorgini/xbmc
C | 51 lines | 31 code | 10 blank | 10 comment | 2 complexity | dce22fc2db5a039f6be70a14a985fb79 MD5 | raw file
Possible License(s): GPL-3.0, CC-BY-SA-3.0, BSD-3-Clause, GPL-2.0, LGPL-3.0, 0BSD, LGPL-2.0, AGPL-1.0, LGPL-2.1
  1. #include "pixeldoubler.h"
  2. #include <SDL/SDL.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. void sdl_pixel_doubler (Surface *src, SDL_Surface *dest) {
  6. register int *d; // pointeur sur le pixel courant a marquer
  7. register int *s; // pointeur sur le pixel coutant en cours de lecture
  8. int sw; // nombre d'octet de largeur de ligne de la surface source
  9. int sw2,swd;
  10. int fd; // adresse de la fin du buffer destination
  11. int fin; // adresse de fin d'une ligne du buffer source
  12. SDL_LockSurface (dest);
  13. d = dest->pixels;
  14. s = src->buf;
  15. sw = src->width << 2;
  16. sw2 = dest->pitch;
  17. swd = sw2 - sw * 2;
  18. fin = (int)s;
  19. fd = (int)d + (sw2 * src->height * 2);
  20. // tant que tout le buffer source n'est pas remplit
  21. while ((int)d < fd) {
  22. // passer a la ligne suivante du buffer source
  23. fin += sw;
  24. // l'afficher sur une ligne du buffer destination
  25. while ((int)s < fin) {
  26. register int col = *(s++);
  27. // 2 affichage par point du buffer source (doubling horizontal)
  28. *(d++) = col; *(d++) = col;
  29. }
  30. d = (int*)((char*)d + swd);
  31. // puis l'afficher sur une autre ligne (doubling vertical)
  32. memcpy (d, ((char*)d) - sw2, sw2);
  33. /* s = (int*)((int)s - sw); // retour au debut de la ligne src
  34. while ((int)s < fin) {
  35. register int col = *(s++);
  36. *(d++) = col; *(d++) = col; // idem (cf plus haut)
  37. } */
  38. d = (int*)((char*)d + sw2);
  39. }
  40. SDL_UnlockSurface (dest);
  41. }