text: /**
    ******************************************************************************
    * This file is part of the TouchGFX 4.10.0 distribution.
    *
    * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
    * All rights reserved.</center></h2>
    *
    * This software component is licensed by ST under Ultimate Liberty license
    * SLA0044, the "License"; You may not use this file except in compliance with
    * the License. You may obtain a copy of the License at:
    *                             www.st.com/SLA0044
    *
    ******************************************************************************
    */
  
  #ifndef PAINTERRGB888BITMAP_HPP
  #define PAINTERRGB888BITMAP_HPP
  
  #include <stdint.h>
  #include <touchgfx/widgets/canvas/AbstractPainterRGB888.hpp>
  #include <touchgfx/Bitmap.hpp>
  #include <touchgfx/transforms/DisplayTransformation.hpp>
  
  namespace touchgfx
  {
  /**
   * @class PainterRGB888Bitmap PainterRGB888Bitmap.hpp touchgfx/widgets/canvas/PainterRGB888Bitmap.hpp
   *
   * @brief A Painter that will paint using a bitmap.
   *
   *        PainterRGB888Bitmap will take the color for a given point in the shape from a bitmap.
   *        Please be aware, the the bitmap is used by the CWR (not Shape), so any rotation you
   *        might specify for a Canvas Widget (e.g. Shape) is not applied to the bitmap as CWR is
   *        not aware of this rotation.
   *
   * @see AbstractPainter
   */
  class PainterRGB888Bitmap : public AbstractPainterRGB888
  {
  public:
  
      /**
       * @fn PainterRGB888Bitmap::PainterRGB888Bitmap(const Bitmap& bmp = Bitmap(BITMAP_INVALID), uint8_t alpha = 255);
       *
       * @brief Constructor.
       *
       *        Constructor.
       *
       * @param bmp   The bitmap.
       * @param alpha the alpha.
       */
      PainterRGB888Bitmap(const Bitmap& bmp = Bitmap(BITMAP_INVALID), uint8_t alpha = 255);
  
      /**
       * @fn void PainterRGB888Bitmap::setBitmap(const Bitmap& bmp);
       *
       * @brief Sets a bitmap to be used when drawing the CanvasWidget.
       *
       *        Sets a bitmap to be used when drawing the CanvasWidget.
       *
       * @param bmp The bitmap.
       */
      void setBitmap(const Bitmap& bmp);
  
      /**
       * @fn void PainterRGB888Bitmap::setAlpha(uint8_t alpha);
       *
       * @brief Sets an alpha value for the bitmap.
       *
       *        Sets an alpha value for the bitmap. If the image contains an alpha channel, this
       *        alpha value is combined with the alpha in the bitmap to produce the final alpha
       *        value.
       *
       * @param alpha The alpha value to use if there is no alpha channel in the bitmap.
       */
      void setAlpha(uint8_t alpha);
  
      /**
       * @fn uint8_t PainterRGB888Bitmap::getAlpha() const;
       *
       * @brief Gets the current alpha value.
       *
       *        Gets the current alpha value.
       *
       * @return The current alpha value.
       *
       * @see setAlpha
       */
      uint8_t getAlpha() const;
  
      virtual void render(uint8_t* ptr, int x, int xAdjust, int y, unsigned count, const uint8_t* covers);
  
  protected:
      virtual bool renderInit();
  
      virtual bool renderNext(uint8_t& red, uint8_t& green, uint8_t& blue, uint8_t& alpha);
  
      const uint32_t* bitmapARGB8888Pointer; ///< Pointer to the bitmap (ARGB8888)
      const uint8_t* bitmapRGB888Pointer;   ///< Pointer to the bitmap (RGB888)
  
      Bitmap bitmap;                  ///< The bitmap to be used when painting
      Rect   bitmapRectToFrameBuffer; ///< Bitmap rectangle translated to frame buffer coordinates
  
      uint8_t painterAlpha; ///< The alpha to use combined with alpha data from the bitmap
  }; // class PainterRGB888Bitmap
  } // namespace touchgfx
  
  #endif // PAINTERRGB888BITMAP_HPP
  