imagefilters.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Copyright (C) 2015 Aaron Suen <warr1024@gmail.com>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License along
  12. with this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  14. */
  15. #pragma once
  16. #include "irrlichttypes_extrabloated.h"
  17. /* Fill in RGB values for transparent pixels, to correct for odd colors
  18. * appearing at borders when blending. This is because many PNG optimizers
  19. * like to discard RGB values of transparent pixels, but when blending then
  20. * with non-transparent neighbors, their RGB values will shpw up nonetheless.
  21. *
  22. * This function modifies the original image in-place.
  23. *
  24. * Parameter "threshold" is the alpha level below which pixels are considered
  25. * transparent. Should be 127 for 3d where alpha is threshold, but 0 for
  26. * 2d where alpha is blended.
  27. */
  28. void imageCleanTransparent(video::IImage *src, u32 threshold);
  29. /* Scale a region of an image into another image, using nearest-neighbor with
  30. * anti-aliasing; treat pixels as crisp rectangles, but blend them at boundaries
  31. * to prevent non-integer scaling ratio artifacts. Note that this may cause
  32. * some blending at the edges where pixels don't line up perfectly, but this
  33. * filter is designed to produce the most accurate results for both upscaling
  34. * and downscaling.
  35. */
  36. void imageScaleNNAA(video::IImage *src, const core::rect<s32> &srcrect, video::IImage *dest);