Back to Devexpress

OfficeImage.GetImageBytes(OfficeImageFormat) Method

officefileapi-devexpress-dot-office-dot-utils-dot-officeimage-dot-getimagebytes-x28-devexpress-dot-office-dot-utils-dot-officeimageformat-x29.md

latest4.5 KB
Original Source

OfficeImage.GetImageBytes(OfficeImageFormat) Method

Returns a byte array of image data encoded in the specified format.

Namespace : DevExpress.Office.Utils

Assembly : DevExpress.Office.v25.2.Core.dll

NuGet Package : DevExpress.Office.Core

Declaration

csharp
public abstract byte[] GetImageBytes(
    OfficeImageFormat imageFormat
)
vb
Public MustOverride Function GetImageBytes(
    imageFormat As OfficeImageFormat
) As Byte()

Parameters

NameTypeDescription
imageFormatOfficeImageFormat

An OfficeImageFormat enumeration member specifying the format of the resulting image data.

|

Returns

TypeDescription
Byte[]

A Byte array that contains the image data.

|

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetImageBytes(OfficeImageFormat) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-richedit-build-a-mail-application/CS/RichEditSendMail/Form1.cs#L112

csharp
OfficeImageFormat imageFormat = GetActualImageFormat(image.RawFormat);
Stream stream = new MemoryStream(image.GetImageBytes(imageFormat));
string mediaContentType = OfficeImage.GetContentType(imageFormat);

spreadsheet-document-api-use-worksheet-table-as-data-source/CS/SpreadsheetDocumentServerAsDataSourceExample/MyPictureProvider.cs#L41

csharp
{
    employeePictures.Add(pic.Name, DXImage.FromStream(new MemoryStream(pic.Image.GetImageBytes(OfficeImageFormat.Bmp))));
}

office-file-api-ai-implementation/CS/BusinessObjects/OpenAIClientImageHelper.cs#L20

csharp
internal async Task<string> DescribeImageAsync(OfficeImage image) {
    return await GetImageDescription(image.GetImageBytes(OfficeImageFormat.Png));
}

winforms-richedit-build-a-mail-application/VB/RichEditSendMail/Form1.vb#L104

vb
Dim imageFormat As OfficeImageFormat = GetActualImageFormat(image.RawFormat)
Dim stream As Stream = New MemoryStream(image.GetImageBytes(imageFormat))
Dim mediaContentType As String = OfficeImage.GetContentType(imageFormat)

spreadsheet-document-api-use-worksheet-table-as-data-source/VB/SpreadsheetDocumentServerAsDataSourceExample/MyPictureProvider.vb#L34

vb
For Each pic As Picture In sheet.Pictures
    employeePictures.Add(pic.Name, DXImage.FromStream(New MemoryStream(pic.Image.GetImageBytes(OfficeImageFormat.Bmp))))
Next pic

See Also

OfficeImage Class

OfficeImage Members

DevExpress.Office.Utils Namespace