File

projects/wms-framework/src/lib/models/controls/BitmapImage.ts

Description

The BitmapImage used to reference images.

Extends

BitmapSource

Index

Properties
Methods
Accessors

Constructor

constructor(uriSource?: Uri)

Creates an instance of BitmapImage.

Parameters :
Name Type Optional
uriSource Uri Yes

Properties

Private uriSource
Type : Uri

Stores the source URI.

Methods

Public SetSource
SetSource(src: SmStream)
Inherited from BitmapSource
Defined in BitmapSource:72

Sets the source for this BitmapImage.

Parameters :
Name Type Optional
src SmStream No
Returns : void

Accessors

UriSource
getUriSource()

Gets or sets the URI of the image source file that generated this BitmapImage.

Returns : Uri
setUriSource(value: Uri)
Parameters :
Name Type Optional
value Uri No
Returns : void
import { LoadedResourceImageStream } from '../../basecomponentmodel/Resources';
import { Uri, UriKind } from '../../baseframework/Uri';
import { Debugger } from '../../diagnostics/Debugger';
import { MemoryStream, SmStream } from '../../helpers/StreamsSupport';
import { BitmapSource } from './BitmapSource';

/**
 * The BitmapImage used to reference images.
 *
 * @export
 * @class BitmapImage
 * @extends {BitmapSource}
 * @wType System.Windows.Media.Imaging.BitmapImage
 */
export class BitmapImage extends BitmapSource {
  /**
   * Stores the source URI.
   *
   * @type {Uri}
   * @memberof BitmapImage
   */
  private uriSource: Uri;

  /**
   * Creates an instance of `BitmapImage`.
   *
   * @param {Uri} [uriSource]
   * @memberof BitmapImage
   */
  constructor(uriSource?: Uri) {
    super();
    this.UriSource = uriSource;
  }

  /**
   * Gets or sets the URI of the image source file that generated this `BitmapImage`.
   *
   * @type {Uri}
   * @memberof BitmapImage
   */
  public get UriSource(): Uri {
    return this.uriSource;
  }

  public set UriSource(value: Uri) {
    this.uriSource = value ?? new Uri('', UriKind.Relative);
  }

  /**
   * Sets the source for this `BitmapImage`.
   *
   * @param {SmStream} src
   * @memberof BitmapImage
   * @wIgnore
   */
  public SetSource(src: SmStream): void {
    /* istanbul ignore else */
    if (src == null) {
      throw Error('`src` cannot be `null`');
    }
    /* istanbul ignore else */
    if (src instanceof LoadedResourceImageStream) {
      this.UriSource = new Uri(src.FileEntryInfo, UriKind.RelativeOrAbsolute);
      return;
    } else if (src instanceof MemoryStream) {
      const bytesBlob = new Blob([new Uint8Array(src.ToArray())]);
      this.UriSource = new Uri(
        URL.createObjectURL(bytesBlob),
        UriKind.Absolute
      );
      return;
    }
    Debugger.Throw(
      'Instances of `SmStream` other than `LoadedResourceImageStream` are not supported'
    );
  }
}

result-matching ""

    No results matching ""