25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.3 KiB

  1. /*
  2. * libpipi Proper image processing implementation library
  3. * Copyright (c) 2004-2008 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. /*
  15. * tile.c: Tiling function
  16. */
  17. #include "config.h"
  18. #include "common.h"
  19. #include <strings.h>
  20. #include "pipi.h"
  21. #include "pipi_internals.h"
  22. pipi_image_t *pipi_tile(pipi_image_t *tile, int w, int h)
  23. {
  24. pipi_image_t *dst;
  25. pipi_pixels_t *tilep, *dstp;
  26. float *tiledata, *dstdata;
  27. int x, y, tw, th, todo;
  28. tw = tile->w;
  29. th = tile->h;
  30. dst = pipi_new(w, h);
  31. dstp = pipi_getpixels(dst, PIPI_PIXELS_RGBA_F);
  32. dstdata = (float *)dstp->pixels;
  33. tilep = pipi_getpixels(tile, PIPI_PIXELS_RGBA_F);
  34. tiledata = (float *)tilep->pixels;
  35. for(y = 0; y < h; y++)
  36. {
  37. for(x = 0; x < w; x += todo)
  38. {
  39. todo = (x + tw > w) ? w - x : tw;
  40. memcpy(dstdata + 4 * (y * w + x),
  41. tiledata + 4 * (y % th) * tw,
  42. 4 * todo * sizeof(float));
  43. }
  44. }
  45. return dst;
  46. }