Show / Hide Table of Contents

Class ImageStreamUtils

Inheritance
object
ImageStreamUtils
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.Util
Assembly: SoCore.dll
Syntax
public static class ImageStreamUtils

Methods

FitToAsync(Stream, int, int, CancellationToken)

Declaration
public static Task<Stream> FitToAsync(this Stream imageStream, int width, int height, CancellationToken cancellationToken)
Parameters
Type Name Description
Stream imageStream
int width
int height
CancellationToken cancellationToken
Returns
Type Description
Task<Stream>

FitToPng(Stream, int, int)

Convenience wrapper around FitToPngBytes(Stream, int, int) that returns a positioned-at-zero MemoryStream wrapping the resulting bytes.

Declaration
public static Stream FitToPng(this Stream imageStream, int width, int height)
Parameters
Type Name Description
Stream imageStream
int width
int height
Returns
Type Description
Stream

FitToPngBytes(Stream, int, int)

Synchronous companion to FitToAsync(Stream, int, int, CancellationToken). Resizes the input image to fit within the given bounds while preserving aspect ratio, and returns the result as PNG-encoded bytes. Always re-encodes as PNG regardless of the input format. Returns null if input is null.

Declaration
public static byte[] FitToPngBytes(this Stream imageStream, int width, int height)
Parameters
Type Name Description
Stream imageStream
int width
int height
Returns
Type Description
byte[]

GetDefaultMimeTypeAsync(Stream, CancellationToken)

Declaration
public static Task<string> GetDefaultMimeTypeAsync(this Stream imageStream, CancellationToken cancellationToken)
Parameters
Type Name Description
Stream imageStream
CancellationToken cancellationToken
Returns
Type Description
Task<string>

GetNoPhotoPng()

Returns the product-wide "no photo" placeholder (a person silhouette) as PNG bytes, loaded once from an embedded resource and cached. Used as the visible fallback for the SrNoPhoto / SrNoPhotoWithBorder strategies on the cross-platform image path, replacing the GDI+-rendered "NO PHOTO" text image. A fresh copy is returned on every call, so callers may freely mutate the result without affecting the process-wide cached source.

Declaration
public static byte[] GetNoPhotoPng()
Returns
Type Description
byte[]

GetThumbnailPngBytes(Stream, int, int)

Fast thumbnail companion to FitToPngBytes(Stream, int, int). Mirrors the old System.Drawing GetThumbnailImage path for very small images where speed matters more than high-quality scaling.

Declaration
public static byte[] GetThumbnailPngBytes(this Stream imageStream, int width, int height)
Parameters
Type Name Description
Stream imageStream
int width
int height
Returns
Type Description
byte[]

GetTransparentPixelPng()

Returns a 1×1 fully transparent PNG as bytes. Useful as a fallback for missing or invalid images. A fresh copy is returned on every call, so callers may freely mutate the result without affecting the process-wide cached source.

Declaration
public static byte[] GetTransparentPixelPng()
Returns
Type Description
byte[]
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top