BlitSurface.h 1.6 KB

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