VisioForge (c) 2025

Search Results for

    Class BitmapHelper

    Inheritance
    object
    BitmapHelper
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: VisioForge.Core.Helpers
    Assembly: VisioForge.Core.dll
    Syntax
    public static class BitmapHelper

    Methods

    ARGBBitmapToVideoFrameX(Bitmap)

    Converts Bitmap to VideoFrame.

    Declaration
    public static VideoFrameX ARGBBitmapToVideoFrameX(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The bitmap.

    Returns
    Type Description
    VideoFrameX

    VideoFrame.

    BitmapToIntPtr(Bitmap, nint, bool)

    Converts Bitmap to RAW byte array.

    Declaration
    public static void BitmapToIntPtr(Bitmap sourceBmp, nint destArray, bool flip = false)
    Parameters
    Type Name Description
    Bitmap sourceBmp

    The source bitmap.

    nint destArray

    The destination array.

    bool flip

    if set to true flip.

    BitmapToIntPtr(Bitmap, nint, int, int, PixelFormat)

    Converts Bitmap to RAW byte array.

    Declaration
    public static void BitmapToIntPtr(Bitmap sourceBmp, nint destArray, int width, int height, PixelFormat pixelFormat)
    Parameters
    Type Name Description
    Bitmap sourceBmp

    The source bitmap.

    nint destArray

    The destination array.

    int width

    The width.

    int height

    The height.

    PixelFormat pixelFormat

    The pixel format.

    BitmapToIntPtrFlip(ref Bitmap, int, int, PixelFormat, nint, int)

    Converts Bitmap to byte array with flip.

    Declaration
    public static void BitmapToIntPtrFlip(ref Bitmap sourceBitmap, int width, int height, PixelFormat pixelFormat, nint destPtr, int destLen)
    Parameters
    Type Name Description
    Bitmap sourceBitmap

    The source bitmap.

    int width

    The width.

    int height

    The height.

    PixelFormat pixelFormat

    The pixel format.

    nint destPtr

    The destination pointer.

    int destLen

    Length of the dest.

    ByteArrayToBitmap(byte[], int, int, PixelFormat, ref Bitmap, bool)

    Converts byte array to bitmap.

    Declaration
    public static void ByteArrayToBitmap(byte[] source, int width, int height, PixelFormat pixelFormat, ref Bitmap preDefinedOutput, bool flip = false)
    Parameters
    Type Name Description
    byte[] source

    Source data.

    int width

    Width.

    int height

    Height.

    PixelFormat pixelFormat

    Pixel format.

    Bitmap preDefinedOutput

    Pre-defined output bitmap.

    bool flip

    Flip.

    ByteArrayToBitmap(nint, int, int, PixelFormat, ref Bitmap)

    Converts byte array to Bitmap.

    Declaration
    public static void ByteArrayToBitmap(nint srcArray, int srcWidth, int srcHeight, PixelFormat pixelFormat, ref Bitmap destBmp)
    Parameters
    Type Name Description
    nint srcArray

    The source array.

    int srcWidth

    Width of the source.

    int srcHeight

    Height of the source.

    PixelFormat pixelFormat

    The pixel format.

    Bitmap destBmp

    The destination Bitmap.

    ByteArrayToBitmapFlip(byte[], int, int, PixelFormat, ref Bitmap)

    Converts byte array to bitmap with horizontal flip.

    Declaration
    public static void ByteArrayToBitmapFlip(byte[] source, int width, int height, PixelFormat pixelFormat, ref Bitmap preDefinedOutput)
    Parameters
    Type Name Description
    byte[] source

    Source data.

    int width

    Width.

    int height

    Height.

    PixelFormat pixelFormat

    Pixel format.

    Bitmap preDefinedOutput

    Pre-defined output bitmap.

    ByteArrayToJpeg(byte[], int, int, PixelFormat, out byte[], bool)

    Converts byte array to Jpeg.

    Declaration
    public static void ByteArrayToJpeg(byte[] source, int width, int height, PixelFormat pixelFormat, out byte[] jpeg, bool flip = false)
    Parameters
    Type Name Description
    byte[] source

    Source data.

    int width

    Width.

    int height

    Height.

    PixelFormat pixelFormat

    Pixel format.

    byte[] jpeg

    JPEG byte array.

    bool flip

    Flip.

    Convert(Bitmap, PixelFormat)

    Converts the specified source to the new pixelformat.

    Declaration
    public static Bitmap Convert(Bitmap source, PixelFormat px)
    Parameters
    Type Name Description
    Bitmap source

    The source.

    PixelFormat px

    The px.

    Returns
    Type Description
    Bitmap

    Bitmap.

    Crop(Bitmap, Rectangle)

    Crops the specified source.

    Declaration
    public static Bitmap Crop(Bitmap source, Rectangle cropRect)
    Parameters
    Type Name Description
    Bitmap source

    The source.

    Rectangle cropRect

    The crop rectangle.

    Returns
    Type Description
    Bitmap

    Bitmap.

    GenerateImageWithText(string)

    Generates the image with text.

    Declaration
    public static Bitmap GenerateImageWithText(string text)
    Parameters
    Type Name Description
    string text

    The text.

    Returns
    Type Description
    Bitmap

    Bitmap.

    GetEncoderInfo(string)

    Gets encoder info.

    Declaration
    public static ImageCodecInfo GetEncoderInfo(string mimeType)
    Parameters
    Type Name Description
    string mimeType

    Mime type.

    Returns
    Type Description
    ImageCodecInfo

    Returns image info structure.

    IntPtrToBitmap(nint, int, int, PixelFormat, bool)

    Converts IntPtr to Bitmap.

    Declaration
    public static Bitmap IntPtrToBitmap(nint source, int width, int height, PixelFormat pixelFormat, bool horizontalFlip = false)
    Parameters
    Type Name Description
    nint source

    Source.

    int width

    Width.

    int height

    Height.

    PixelFormat pixelFormat

    Pixel format.

    bool horizontalFlip

    Horizontal flip.

    Returns
    Type Description
    Bitmap

    Bitmap.

    Exceptions
    Type Condition
    Exception

    Unsupported pixel format.

    IntPtrToJpeg(nint, int, int, int, PixelFormat, out byte[], bool)

    Converts byte array to Jpeg.

    Declaration
    public static void IntPtrToJpeg(nint source, int sourceLen, int width, int height, PixelFormat pixelFormat, out byte[] jpeg, bool flip = false)
    Parameters
    Type Name Description
    nint source

    Source data.

    int sourceLen

    Source length.

    int width

    Width.

    int height

    Height.

    PixelFormat pixelFormat

    Pixel format.

    byte[] jpeg

    JPEG byte array.

    bool flip

    Flip.

    IsBitmapDisposed(Bitmap)

    Determines whether is bitmap was disposed.

    Declaration
    public static bool IsBitmapDisposed(this Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The bitmap.

    Returns
    Type Description
    bool

    true if bitmap was disposed; otherwise, false.

    JpegToByteArray(byte[], int, int, PixelFormat, out nint, out int, bool)

    Converts Jpeg to byte array.

    Declaration
    public static void JpegToByteArray(byte[] jpeg, int width, int height, PixelFormat pixelFormat, out nint output, out int outputSize, bool flip = false)
    Parameters
    Type Name Description
    byte[] jpeg

    JPEG byte array.

    int width

    Width.

    int height

    Height.

    PixelFormat pixelFormat

    Pixel format.

    nint output

    Output data.

    int outputSize

    Output size.

    bool flip

    Flip.

    JpegToByteArray(nint, int, int, int, PixelFormat, out nint, out int, bool)

    Converts Jpeg to byte array.

    Declaration
    public static void JpegToByteArray(nint source, int sourceSize, int width, int height, PixelFormat pixelFormat, out nint output, out int outputSize, bool flip = false)
    Parameters
    Type Name Description
    nint source

    The source.

    int sourceSize

    The source size.

    int width

    Width.

    int height

    Height.

    PixelFormat pixelFormat

    Pixel format.

    nint output

    Output data.

    int outputSize

    Output size.

    bool flip

    Flip.

    MeasureTextFake(string, Font)

    Measures the text (fake).

    Declaration
    public static Size MeasureTextFake(string text, Font font)
    Parameters
    Type Name Description
    string text

    The text.

    Font font

    The font.

    Returns
    Type Description
    Size

    System.Drawing.Size.

    RAWImageToBitmap(RAWImage, bool)

    Converts RAWImage to Bitmap.

    Declaration
    public static Bitmap RAWImageToBitmap(RAWImage frame, bool horizontalFlip = false)
    Parameters
    Type Name Description
    RAWImage frame

    The frame.

    bool horizontalFlip

    Horizontal flip.

    Returns
    Type Description
    Bitmap

    Bitmap.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    RAWVideoFrameToBitmap(RAWVideoFrame, bool)

    Converts RAWVideoFrame to Bitmap.

    Declaration
    public static Bitmap RAWVideoFrameToBitmap(RAWVideoFrame frame, bool horizontalFlip = false)
    Parameters
    Type Name Description
    RAWVideoFrame frame

    The frame.

    bool horizontalFlip

    Horizontal flip.

    Returns
    Type Description
    Bitmap

    Bitmap.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    RGBABitmapToRAWImage(Bitmap)

    Converts Bitmap to RAWImageRGBA.

    Declaration
    public static RAWVideoFrame RGBABitmapToRAWImage(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The bitmap.

    Returns
    Type Description
    RAWVideoFrame

    RAWVideoFrame.

    RGBBitmapToRAWImage(Bitmap)

    Converts Bitmap to RAWImage.

    Declaration
    public static RAWImage RGBBitmapToRAWImage(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The bitmap.

    Returns
    Type Description
    RAWImage

    RAWImage.

    RGBBitmapToRAWVideoFrame(Bitmap)

    Converts Bitmap to RAWVideoFrame.

    Declaration
    public static RAWVideoFrame RGBBitmapToRAWVideoFrame(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The bitmap.

    Returns
    Type Description
    RAWVideoFrame

    RAWVideoFrame.

    RGBBitmapToVideoFrame(Bitmap)

    Converts Bitmap to VideoFrame.

    Declaration
    public static VideoFrame RGBBitmapToVideoFrame(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The bitmap.

    Returns
    Type Description
    VideoFrame

    VideoFrame.

    RGBBitmapToVideoFrameX(Bitmap)

    Converts Bitmap to VideoFrame.

    Declaration
    public static VideoFrameX RGBBitmapToVideoFrameX(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap

    The bitmap.

    Returns
    Type Description
    VideoFrameX

    VideoFrame.

    ResizeImage(Image, int, int, bool)

    Resize the image to the specified width and height.

    Declaration
    public static Bitmap ResizeImage(this Image image, int width, int height, bool fast = false)
    Parameters
    Type Name Description
    Image image

    The image to resize.

    int width

    The width to resize to.

    int height

    The height to resize to.

    bool fast

    Fast but low quality resize.

    Returns
    Type Description
    Bitmap

    The resized image.

    SaveFrame(nint, int, int, PixelFormat, string)

    Saves the frame.

    Declaration
    public static void SaveFrame(nint data, int width, int height, PixelFormat pf, string filename)
    Parameters
    Type Name Description
    nint data

    The data.

    int width

    The width.

    int height

    The height.

    PixelFormat pf

    The pf.

    string filename

    The filename.

    ToBitmap(VideoFrame, bool)

    Converts VideoFrame to Bitmap.

    Declaration
    public static Bitmap ToBitmap(this VideoFrame frame, bool horizontalFlip = false)
    Parameters
    Type Name Description
    VideoFrame frame

    The frame.

    bool horizontalFlip

    if set to true [horizontal flip].

    Returns
    Type Description
    Bitmap

    Bitmap.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    ToBitmap(VideoFrameX, bool)

    Converts VideoFrameX to Bitmap.

    Declaration
    public static Bitmap ToBitmap(this VideoFrameX frame, bool horizontalFlip = false)
    Parameters
    Type Name Description
    VideoFrameX frame

    The frame.

    bool horizontalFlip

    if set to true [horizontal flip].

    Returns
    Type Description
    Bitmap

    Bitmap.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    VideoFrameToBitmap(VideoFrame, bool)

    Converts VideoFrame to Bitmap.

    Declaration
    public static Bitmap VideoFrameToBitmap(VideoFrame frame, bool horizontalFlip = false)
    Parameters
    Type Name Description
    VideoFrame frame

    The frame.

    bool horizontalFlip

    if set to true [horizontal flip].

    Returns
    Type Description
    Bitmap

    Bitmap.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    VideoFrameToBitmap(VideoFrameX, bool)

    Converts VideoFrameX to Bitmap.

    Declaration
    public static Bitmap VideoFrameToBitmap(VideoFrameX frame, bool horizontalFlip = false)
    Parameters
    Type Name Description
    VideoFrameX frame

    The frame.

    bool horizontalFlip

    if set to true horizontal flip.

    Returns
    Type Description
    Bitmap

    Bitmap.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException