You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Code/Editor/Util/GdiUtil.h

65 lines
2.5 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
// Description : Utilitarian classes for double buffer GDI rendering and 32bit bitmaps
#ifndef CRYINCLUDE_EDITOR_UTIL_GDIUTIL_H
#define CRYINCLUDE_EDITOR_UTIL_GDIUTIL_H
#pragma once
//! function used to compute thumbs per row and spacing, used in asset browser and other tools where thumb layout is needed and maybe GDI canvas used
//! \param aContainerWidth the thumbs' container width
//! \param aThumbWidth the thumb image width
//! \param aMargin the thumb default minimum horizontal margin
//! \param aThumbCount the thumb count
//! \param rThumbsPerRow returned thumb count per single row
//! \param rNewMargin returned new computed margin between thumbs
//! \note The margin between thumbs will grow/shrink dynamically to keep up with the thumb count per row
bool ComputeThumbsLayoutInfo(float aContainerWidth, float aThumbWidth, float aMargin, UINT aThumbCount, UINT& rThumbsPerRow, float& rNewMargin);
QColor ScaleColor(const QColor& coor, float aScale);
//! This class loads alpha-channel bitmaps and holds a DC for use with AlphaBlend function
class CRYEDIT_API CAlphaBitmap
{
public:
CAlphaBitmap();
~CAlphaBitmap();
//! creates the bitmap from raw 32bpp data
//! \param pData the 32bpp raw image data, RGBA, can be NULL and it would create just an empty bitmap
//! \param aWidth the bitmap width
//! \param aHeight the bitmap height
bool Create(void* pData, UINT aWidth, UINT aHeight, bool bVerticalFlip = false, bool bPremultiplyAlpha = false);
//! \return the actual bitmap
QImage& GetBitmap();
//! free the bitmap and DC
void Free();
//! \return bitmap width
UINT GetWidth();
//! \return bitmap height
UINT GetHeight();
protected:
QImage m_bmp;
UINT m_width, m_height;
};
//! Fill a rectangle with a checkerboard pattern.
//! \param pGraphics The Graphics object used for drawing
//! \param rRect The rectangle to be filled
//! \param checkDiameter the diameter of the check squares
//! \param aColor1 the color that starts in the top left corner check square
//! \param aColor2 the second color used for check squares
void CheckerboardFillRect(QPainter* pGraphics, const QRect& rRect, int checkDiameter, const QColor& aColor1, const QColor& aColor2);
#endif // CRYINCLUDE_EDITOR_UTIL_GDIUTIL_H