Table of Contents

Constructor Attachment

Namespace
LMKit.Data
Assembly
LM-Kit.NET.dll

Attachment(string)

Initializes a new instance of the Attachment class by loading the content from the specified file path. The file must be one of the supported image formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
public Attachment(string path)

Parameters

path string

The file system path to the attachment file.

Exceptions

FileNotFoundException

Thrown when the specified file does not exist.

UnsupportedFileTypeException

Thrown when the file format is not supported (see above for supported formats).

Attachment(byte[], string)

Initializes a new instance of the Attachment class with the provided data and name. The data must represent one of the supported image formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
public Attachment(byte[] data, string name)

Parameters

data byte[]

The byte array representing the content of the attachment.

name string

The name of the attachment file.

Exceptions

ArgumentNullException

Thrown when data or name is null.

UnsupportedFileTypeException

Thrown when the file format is not supported (see above for supported formats).

Attachment(Stream, string)

Initializes a new instance of the Attachment class by reading the content from the provided stream and using the given file name. The stream must contain data representing one of the supported image formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
public Attachment(Stream data, string name)

Parameters

data Stream

A readable Stream containing the attachment's data. This stream is fully read and not disposed by the constructor.

name string

The name to assign to the attachment file.

Exceptions

ArgumentNullException

Thrown when data or name is null.

ArgumentException

Thrown when the provided stream is not readable.

UnsupportedFileTypeException

Thrown if the file format is not among the supported image formats.

Attachment(ImageBuffer, bool, string)

Initializes a new Attachment instance from an existing image buffer, assigning it a name and optionally taking ownership of its lifetime.

public Attachment(ImageBuffer image, bool ownsImage = true, string name = "image")

Parameters

image ImageBuffer

The ImageBuffer containing the pixel data for this attachment. Cannot be null.

ownsImage bool

If true, the attachment takes ownership of image and will dispose it when the attachment is disposed;
if false, the caller remains responsible for disposing the image.

name string

The name to assign to the attachment.
Defaults to "image" if not specified.

Exceptions

ArgumentNullException

Thrown if image is null.