Syntax
Border = CreateBorderImg(Img, ImgMask, LeftEdgeOffset, TopEdgeOffset, RightEdgeOffset, BottomEdgeOffset, Flags=#Null)
Description
Creates an image border object using one or two source images (one for the border appearance, one optional for masking). The source image(s) are divided into nine regions (slices) based on the provided edge offsets, allowing the border to scale intelligently like CSS border-images.
Parameters
Img
The handle of the ProGUI image to use for the border's visual appearance. Can
be #Null if only a mask is used (#PG_BorderImg_MaskOnly flag).
ImgMask
The handle of the ProGUI image to use as a mask for the border.
Transparency in the mask defines the visible shape of the border. Can be #Null if no
mask is needed or if #PG_BorderImg_NoMask is specified.
LeftEdgeOffset
The offset from the left edge of the source image(s) in pixels.
Defines the width of the left corners and edge. Must be >= 1.
TopEdgeOffset
The offset from the top edge of the source image(s) in pixels.
Defines the height of the top corners and edge. Must be >= 1.
RightEdgeOffset
The offset from the right edge of the source image(s) in pixels.
Defines the width of the right corners and edge. Must be >= 1.
BottomEdgeOffset
The offset from the bottom edge of the source image(s) in
pixels. Defines the height of the bottom corners and edge. Must be >= 1.
Flags (optional)
A combination of flags specifying rendering behavior. Default is
#Null (stretch edges). See BorderImgSetFlags() for
details on flags like #PG_BorderImg_Repeat, #PG_BorderImg_Round,
#PG_BorderImg_Space, #PG_BorderImg_NoMask, etc.
Return Value
Returns a handle to the newly created image border object if successful, or #Null if
creation failed (e.g., invalid image handles, invalid offsets, mask/image dimension mismatch).
Remarks
This function creates an 'image' border type (#BorderType_Img). It requires valid image
handles (unless only a mask or no mask is used) and valid slice offsets. The sum of left/right offsets
must be less than the image width minus 1, and top/bottom offsets less than image height minus 1. If
both `Img` and `ImgMask` are provided, they must have the same dimensions. Remember to free the border
using FreeBorder() when no longer needed.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyImage = CreateImg(90, 90, RGB(200, 200, 200)) ; Placeholder 90x90 image
; Assume MyMask is a 90x90 mask image loaded or created elsewhere
MyMask = CreateImg(90, 90, #PG_Img_Transparent)
BeginDraw(OutputImg(MyMask))
DrawClear(RGBA(0,0,0,255))
DrawRoundBox(0,0,90,90,30,30,RGBA(0,0,0,0))
EndDraw()
If MyImage And MyMask
; Create border using image and mask, slices define 30x30 corners
MyBorder = CreateBorderImg(MyImage, MyMask, 30, 30, 30, 30, #PG_BorderImg_Repeat)
If MyBorder
Debug "Image border created successfully."
; Use the border...
; DrawBorder(MyBorder, 50, 50, 200, 150)
FreeBorder(MyBorder)
Else
Debug "Failed to create image border."
EndIf
FreeImg(MyImage)
FreeImg(MyMask)
EndIf
StopProGUI()
See Also
CreateBorder, DrawBorder, BorderImgSetSlices, BorderImgSetFlags, BorderImgSetWidth, FreeBorder, LoadImg, CreateImg
Supported OS
Windows, Linux