Ocean
Loading...
Searching...
No Matches
Ocean::Platform::Win::Utilities Class Reference

This class implements utilities and helper functions. More...

#include <Utilities.h>

Public Types

enum  AnchorPosition : uint32_t {
  AP_TOP_LEFT , AP_TOP_RIGHT , AP_BOTTOM_LEFT , AP_BOTTOM_RIGHT ,
  AP_CENTER
}
 Definition of anchor positions for text rendering. More...
 

Static Public Member Functions

static void textOutput (HDC dc, const int x, const int y, const std::string &text)
 Prints a text on the given device context.
 
static void textOutput (HDC deviceContext, const std::wstring &text, const std::wstring &font, const unsigned int fontSize, const bool bold, const AnchorPosition anchorPosition, const unsigned int windowWidth, const unsigned int windowHeight, const int32_t foregroundColor, const int32_t backgroundColor=-1, const int32_t shadowColor=-1, const unsigned int shadowOffsetX=2u, const unsigned int shadowOffsetY=2u, const unsigned int marginX=20u, const unsigned int marginY=20u)
 Draws styled text on a device context with customizable font, anchor position, and colors.
 
static void desktopTextOutput (const int x, const int y, const std::string &text)
 Prints a text on the desktop.
 
static void frameOutput (HDC dc, const int x, const int y, const Frame &frame)
 Prints a frame on the given device context.
 
static void frameOutput (HDC dc, const int x, const int y, const unsigned int width, const unsigned int height, const Frame &frame)
 Prints a frame on the given device context.
 
static void desktopFrameOutput (const int x, const int y, const Frame &frame)
 Prints a given frame on the Windows' main desktop at a specified location.
 
static void desktopFrameOutput (const int x, const int y, const unsigned int scale, const Frame &frame)
 Prints a given frame on the Windows' main desktop at a specified location.
 
static void desktopFrameOutput (const int x, const int y, const unsigned int width, const unsigned int height, const Frame &frame)
 Prints a given frame on the Windows' main desktop at a specified location.
 
static void bitmapOutput (HDC dc, const int x, const int y, const Bitmap &bitmap)
 Prints a bitmap on the given device context.
 
static void desktopBitmapOutput (const int x, const int y, const unsigned int scale, const Bitmap &bitmap)
 Prints a bitmap on the desktop.
 
static void bitmapOutput (HDC dc, const int x, const int y, const unsigned int width, const unsigned int height, const Bitmap &bitmap)
 Prints a bitmap on the given device context.
 
static void desktopBitmapOutput (const int x, const int y, const Bitmap &bitmap)
 Prints a bitmap on the desktop.
 
static void desktopBitmapOutput (const int x, const int y, const unsigned int width, const unsigned int height, const Bitmap &bitmap)
 Prints a bitmap on the desktop.
 
static CV::PixelBoundingBox textBoundingBox (const std::string &value, const std::string &font=std::string(), const unsigned int size=0u)
 Determines the bounding box of a given string with specified font and font size.
 
static CV::PixelBoundingBox textBoundingBox (const std::wstring &value, const std::wstring &font=std::wstring(), const unsigned int size=0u)
 Determines the bounding box of a given string with specified font and font size.
 

Detailed Description

This class implements utilities and helper functions.

Member Enumeration Documentation

◆ AnchorPosition

Definition of anchor positions for text rendering.

Enumerator
AP_TOP_LEFT 

Text is anchored at the top-left corner.

AP_TOP_RIGHT 

Text is anchored at the top-right corner.

AP_BOTTOM_LEFT 

Text is anchored at the bottom-left corner.

AP_BOTTOM_RIGHT 

Text is anchored at the bottom-right corner.

AP_CENTER 

Text is centered.

Member Function Documentation

◆ bitmapOutput() [1/2]

static void Ocean::Platform::Win::Utilities::bitmapOutput ( HDC  dc,
const int  x,
const int  y,
const Bitmap bitmap 
)
static

Prints a bitmap on the given device context.

Parameters
dcDevice context receiving the bitmap
xHorizontal output position
yVertical output position
bitmapbitmap to be printed

◆ bitmapOutput() [2/2]

static void Ocean::Platform::Win::Utilities::bitmapOutput ( HDC  dc,
const int  x,
const int  y,
const unsigned int  width,
const unsigned int  height,
const Bitmap bitmap 
)
static

Prints a bitmap on the given device context.

Parameters
dcDevice context receiving the text
xHorizontal output position
yVertical output position
widthOutput width in pixel
heightOutput height in pixel
bitmapbitmap to be printed

◆ desktopBitmapOutput() [1/3]

static void Ocean::Platform::Win::Utilities::desktopBitmapOutput ( const int  x,
const int  y,
const Bitmap bitmap 
)
static

Prints a bitmap on the desktop.

Parameters
xHorizontal output position
yVertical output position
bitmapbitmap to be printed

◆ desktopBitmapOutput() [2/3]

void Ocean::Platform::Win::Utilities::desktopBitmapOutput ( const int  x,
const int  y,
const unsigned int  scale,
const Bitmap bitmap 
)
inlinestatic

Prints a bitmap on the desktop.

Parameters
xHorizontal output position
yVertical output position
scaleScale of the output bitmap
bitmapBitmap to be printed

◆ desktopBitmapOutput() [3/3]

static void Ocean::Platform::Win::Utilities::desktopBitmapOutput ( const int  x,
const int  y,
const unsigned int  width,
const unsigned int  height,
const Bitmap bitmap 
)
static

Prints a bitmap on the desktop.

Parameters
xHorizontal output position
yVertical output position
widthOutput width in pixel
heightOutput height in pixel
bitmapbitmap to be printed

◆ desktopFrameOutput() [1/3]

static void Ocean::Platform::Win::Utilities::desktopFrameOutput ( const int  x,
const int  y,
const Frame frame 
)
static

Prints a given frame on the Windows' main desktop at a specified location.

You do not need to have a GUI application to use this function.
Call this function from any application and from any thread.
The painted frame will disappear immediately when Windows receives any repaint event.
This function is intended for debugging purposes only.

Parameters
xHorizontal output position, with range (-infinity, infinity)
yVertical output position, with range (-infinity, infinity)
frameThe frame to be printed

◆ desktopFrameOutput() [2/3]

void Ocean::Platform::Win::Utilities::desktopFrameOutput ( const int  x,
const int  y,
const unsigned int  scale,
const Frame frame 
)
inlinestatic

Prints a given frame on the Windows' main desktop at a specified location.

You do not need to have a GUI application to use this function.
Call this function from any application and from any thread.
The painted frame will disappear immediately when Windows receives any repaint event.
This function is intended for debugging purposes only.

Parameters
xHorizontal output position, with range (-infinity, infinity)
yVertical output position, with range (-infinity, infinity)
scaleThe scale that is applied to the frame, a factor of 2 will increase the painted frame by two, with range [1, infinity)
frameThe frame to be printed

◆ desktopFrameOutput() [3/3]

static void Ocean::Platform::Win::Utilities::desktopFrameOutput ( const int  x,
const int  y,
const unsigned int  width,
const unsigned int  height,
const Frame frame 
)
static

Prints a given frame on the Windows' main desktop at a specified location.

You do not need to have a GUI application to use this function.
Call this function from any application and from any thread.
The painted frame will disappear immediately when Windows receives any repaint event.
This function is intended for debugging purposes only.

Parameters
xHorizontal output position, with range (-infinity, infinity)
yVertical output position, with range (-infinity, infinity)
widthThe width of the painted frame in the domain of the desktop, in pixel, with range [1, infinity)
heightThe height of the painted frame in the domain of the desktop, in pixel, with range [1, infinity)
frameThe frame to be printed

◆ desktopTextOutput()

static void Ocean::Platform::Win::Utilities::desktopTextOutput ( const int  x,
const int  y,
const std::string &  text 
)
static

Prints a text on the desktop.

Parameters
xHorizontal output position
yVertical output position
textText to be printed

◆ frameOutput() [1/2]

static void Ocean::Platform::Win::Utilities::frameOutput ( HDC  dc,
const int  x,
const int  y,
const Frame frame 
)
static

Prints a frame on the given device context.

Parameters
dcDevice context receiving the frame
xHorizontal output position
yVertical output position
frameThe frame to be printed

◆ frameOutput() [2/2]

static void Ocean::Platform::Win::Utilities::frameOutput ( HDC  dc,
const int  x,
const int  y,
const unsigned int  width,
const unsigned int  height,
const Frame frame 
)
static

Prints a frame on the given device context.

Parameters
dcDevice context receiving the text
xHorizontal output position
yVertical output position
widthOutput width in pixel
heightOutput height in pixel
frameThe frame to be printed

◆ textBoundingBox() [1/2]

static CV::PixelBoundingBox Ocean::Platform::Win::Utilities::textBoundingBox ( const std::string &  value,
const std::string &  font = std::string(),
const unsigned int  size = 0u 
)
static

Determines the bounding box of a given string with specified font and font size.

Parameters
valueThe string for which the bounding box will be determined
fontThe name of the font which will be applied
sizeThe size of the font
Returns
The bounding box of the given string

◆ textBoundingBox() [2/2]

static CV::PixelBoundingBox Ocean::Platform::Win::Utilities::textBoundingBox ( const std::wstring &  value,
const std::wstring &  font = std::wstring(),
const unsigned int  size = 0u 
)
static

Determines the bounding box of a given string with specified font and font size.

Parameters
valueThe string for which the bounding box will be determined
fontThe name of the font which will be applied
sizeThe size of the font
Returns
The bounding box of the given string

◆ textOutput() [1/2]

static void Ocean::Platform::Win::Utilities::textOutput ( HDC  dc,
const int  x,
const int  y,
const std::string &  text 
)
static

Prints a text on the given device context.

Parameters
dcThe device context on which the text will be drawn
xHorizontal output position
yVertical output position
textText to be printed

◆ textOutput() [2/2]

static void Ocean::Platform::Win::Utilities::textOutput ( HDC  deviceContext,
const std::wstring &  text,
const std::wstring &  font,
const unsigned int  fontSize,
const bool  bold,
const AnchorPosition  anchorPosition,
const unsigned int  windowWidth,
const unsigned int  windowHeight,
const int32_t  foregroundColor,
const int32_t  backgroundColor = -1,
const int32_t  shadowColor = -1,
const unsigned int  shadowOffsetX = 2u,
const unsigned int  shadowOffsetY = 2u,
const unsigned int  marginX = 20u,
const unsigned int  marginY = 20u 
)
static

Draws styled text on a device context with customizable font, anchor position, and colors.

The text can be positioned using anchor points relative to the window dimensions, with optional shadow for better visibility.

Parameters
dcThe device context on which the text will be drawn
textThe text to be drawn
fontThe name of the font to use (e.g., "Arial")
fontSizeThe height of the font in pixels
boldTrue to use bold font weight; False for normal weight
anchorPositionThe anchor position for the text
windowWidthThe width of the window, used for anchor calculations
windowHeightThe height of the window, used for anchor calculations
foregroundColorThe color of the text (RGB value)
backgroundColorThe background color of the text, or -1 for transparent background
shadowColorThe color of the shadow, or -1 to disable shadow
shadowOffsetXThe horizontal offset of the shadow in pixels, with range [0, infinity)
shadowOffsetYThe vertical offset of the shadow in pixels, with range [0, infinity)
marginXThe horizontal margin from the window edge in pixels, with range [0, infinity)
marginYThe vertical margin from the window edge in pixels, with range [0, infinity)

The documentation for this class was generated from the following file: