OutputImg

Syntax

Output = OutputImg(Img, DPI_X=#Null, DPI_Y=#Null)

Description

Returns a drawing output handle associated with the specified ProGUI image object. This output handle is then used with BeginDraw() to enable drawing operations directly onto the image using ProGUI's graphics commands.

Parameters

Img
The handle of the ProGUI image object to be used as the drawing target.

DPI_X (optional)
The horizontal DPI to assume for the drawing context. If #Null or 0, defaults to the system's standard DPI (usually 96). Affects how DIP-based drawing commands (like text point sizes) are interpreted when drawing onto this image.

DPI_Y (optional)
The vertical DPI to assume for the drawing context. If #Null or omitted, defaults to the value of DPI_X.

Return Value

Returns an output handle (specific to the internal graphics subsystem) that can be passed to BeginDraw(). Returns #Null or #False if the image handle is invalid.

Remarks

This function is the necessary first step to draw onto an existing image. After obtaining the output handle, you must call BeginDraw() with this handle, perform your drawing operations, and then call EndDraw(). The DPI settings provided here establish the context for how DIPs are converted to pixels within the drawing commands used on this image target. Usually, setting DPI to 96 (or leaving it as default) is appropriate unless you specifically need to simulate drawing at a different resolution onto the image.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

; Create an image to draw on
MyImage = CreateImg(200, 100, RGB(255, 255, 255)) ; White background

If MyImage
    ; Get the drawing output for the image (using default 96 DPI)
    ImageOutput = OutputImg(MyImage)

    If ImageOutput
        ; Start drawing on the image
        If BeginDraw(ImageOutput)

            ; Draw a red rectangle onto the image
            DrawBox(10, 10, 180, 80, RGB(255, 0, 0), 1.0)

            ; Draw some text (size interpreted based on output DPI, here 96)
            MyText = CreateText("On Image", "Arial", 12)
            If MyText
                DrawTxt(MyText, 20, 20, RGB(0,0,0), 1.0)
                FreeText(MyText)
            EndIf

            ; Finish drawing on the image
            EndDraw()
            Debug "Drew onto image."

            ; Now MyImage contains the red box and text
            ; You could save it, use it in a brush, or draw it to a window

        Else
            Debug "Failed to BeginDraw on image output."
        EndIf
    Else
        Debug "Failed to get image output handle."
    EndIf

    FreeImg(MyImage)
EndIf

StopProGUI()

See Also

BeginDraw, EndDraw, CreateImg, DrawDPI

Supported OS

Windows, Linux