Search Results for

    Show / Hide Table of Contents

    Class QrStyleOptions

    Creates the styling options for a QR code, including dimensions, margins, color, background color, annotations, and logo.

    Inheritance
    System.Object
    QrStyleOptions
    Namespace: IronQr
    Assembly: IronQr.dll
    Syntax
    public sealed class QrStyleOptions : ValueType

    The visual styling of a generated QR code, covering size, margins, colors, and an embedded logo, is set through QrStyleOptions. It is passed to QrCode.Save, so a code produced by QrWriter is styled at the moment it becomes an image. Construct one with the object initializer or the parameterized constructor that takes dimensions, margins, and colors.

    The properties group by concern. Size is Dimensions, the pixel width and height of the square image. Spacing is the convenience Margins, which sets every side at once, or the per-side MarginTop, MarginRight, MarginBottom, and MarginLeft for asymmetric quiet zones. Color is Color for the modules and BackgroundColor for the field behind them, both System.Drawing.Color values. Branding is Logo, a Nullable<QrLogo> that embeds an image in the center of the code.

    The parameterless constructor starts from sensible defaults, a 300-pixel code with a small uniform margin, so only the properties that differ from the default need to be set. The per-side margins are useful when a code sits in a layout that needs a wider quiet zone on one edge, for instance against a page border or next to other content.

    Two pairings matter in practice. A logo covers part of the symbol, so raise the QrErrorCorrectionLevel on the QrOptions used to write the code, which keeps it scannable. Custom colors need enough contrast between Color and BackgroundColor for scanners to read reliably, so avoid light-on-light combinations.

    var style = new QrStyleOptions
    {
        Dimensions = 400,
        Color = Color.DarkBlue,
        Logo = new QrLogo(logoBitmap, 80, 80)
    };
    qr.Save(style);

    The styled QR example applies a full style, the custom logo how-to embeds a logo, and the custom colors how-to covers contrast.

    Constructors

    QrStyleOptions()

    Initializes a new instance of the QrStyleOptions struct with default values.

    Declaration
    public QrStyleOptions()

    QrStyleOptions(Int32, Int32, Color, Color, Nullable<QrLogo>)

    Initializes a new instance of the QrStyleOptions struct with specified values.

    Declaration
    public QrStyleOptions(int dimensions = 300, int margins = 10, Color color = null, Color backgroundColor = null, Nullable<QrLogo> logo = null)
    Parameters
    Type Name Description
    System.Int32 dimensions

    The width and height of the QR code in pixels. Defaults to 300.

    System.Int32 margins

    The whitespace margins around the QR code. Defaults to 10.

    IronSoftware.Drawing.Color color

    The color of the QR code's content. Defaults to black.

    IronSoftware.Drawing.Color backgroundColor

    The background color of the QR code. Defaults to white.

    System.Nullable<QrLogo> logo

    An optional logo to be embedded within the QR code.

    Properties

    BackgroundColor

    Specifies the background color of the QR code.

    Declaration
    public Color BackgroundColor { get; set; }
    Property Value
    Type Description
    IronSoftware.Drawing.Color

    Color

    Specifies the color of the QR code's content.

    Declaration
    public Color Color { get; set; }
    Property Value
    Type Description
    IronSoftware.Drawing.Color

    Dimensions

    The width and height of the QR code in pixels.

    Declaration
    public int Dimensions { get; set; }
    Property Value
    Type Description
    System.Int32

    Logo

    Specifies an optional logo to be embedded within the QR code.

    Declaration
    public Nullable<QrLogo> Logo { get; set; }
    Property Value
    Type Description
    System.Nullable<QrLogo>

    MarginBottom

    Specifies the amount of whitespace or padding at the bottom of the QR code.

    Declaration
    public int MarginBottom { get; set; }
    Property Value
    Type Description
    System.Int32

    MarginLeft

    Specifies the amount of whitespace or padding at the left of the QR code.

    Declaration
    public int MarginLeft { get; set; }
    Property Value
    Type Description
    System.Int32

    MarginRight

    Specifies the amount of whitespace or padding at the right of the QR code.

    Declaration
    public int MarginRight { get; set; }
    Property Value
    Type Description
    System.Int32

    Margins

    Sets the whitespace margins around the QR code, applying the same value to the top, bottom, left, and right.

    Declaration
    public int Margins { set; }
    Property Value
    Type Description
    System.Int32

    MarginTop

    Specifies the amount of whitespace or padding at the top of the QR code.

    Declaration
    public int MarginTop { get; set; }
    Property Value
    Type Description
    System.Int32
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with NuGet