projects/wms-framework/src/lib/models/controls/BitmapImage.ts
The BitmapImage used to reference images.
Properties |
|
Methods |
|
Accessors |
constructor(uriSource?: Uri)
|
||||||
Creates an instance of
Parameters :
|
Private uriSource |
Type : Uri
|
Stores the source URI. |
Public SetSource | ||||||
SetSource(src: SmStream)
|
||||||
Inherited from
BitmapSource
|
||||||
Defined in
BitmapSource:72
|
||||||
Sets the source for this
Parameters :
Returns :
void
|
UriSource | ||||||
getUriSource()
|
||||||
Gets or sets the URI of the image source file that generated this
Returns :
Uri
|
||||||
setUriSource(value: Uri)
|
||||||
Parameters :
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'
);
}
}