BlitSurface.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Image/ZoomImage.h>
  6. #include <Jolt/Core/Color.h>
  7. /// Settings for blitting one surface to another with possibly different formats and dimensions. The blit
  8. /// routine can use filtering or blurring on the fly. Also it can perform some other
  9. /// basic opertions like converting an image to grayscale or alpha only surfaces.
  10. class BlitSettings
  11. {
  12. public:
  13. /// Constructor
  14. BlitSettings();
  15. /// Comparison operators
  16. bool operator == (const BlitSettings &inRHS) const;
  17. /// Default settings
  18. static const BlitSettings sDefault;
  19. /// Special operations that can be applied during the blit
  20. bool mConvertRGBToAlpha; ///< Convert RGB values to alpha values (RGB values remain untouched)
  21. bool mConvertAlphaToRGB; ///< Convert alpha values to grayscale RGB values (Alpha values remain untouched)
  22. bool mConvertToGrayScale; ///< Convert RGB values to grayscale values (Alpha values remain untouched)
  23. bool mInvertAlpha; ///< Invert alpha values
  24. bool mColorKeyAlpha; ///< If true, colors in the range mColorKeyStart..mColorKeyEnd will get an alpha of 0, other colors will get an alpha of 255
  25. Color mColorKeyStart;
  26. Color mColorKeyEnd;
  27. ZoomSettings mZoomSettings; ///< Settings for resizing the image
  28. };
  29. /// Copies an image from inSrc to inDst, converting it on the fly as defined by inBlitSettings
  30. bool BlitSurface(RefConst<Surface> inSrc, Ref<Surface> ioDst, const BlitSettings &inBlitSettings = BlitSettings::sDefault);