[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Drawing.IBackgroundPictures.AddPictureInPixel

AddPictureInPixel Method

AddPictureInPixel(string, double, double, double, double)

Creates a background picture from an existing file and returns the IBackgroundPicture object that represents the new background picture.

The picture is positioned and sized by the destination rectangle specified in pixels relative to the upper-left corner of the document.

Declaration
IBackgroundPicture AddPictureInPixel(string filename, double left, double top, double width, double height)
Function AddPictureInPixel(filename As String, left As Double, top As Double, width As Double, height As Double) As IBackgroundPicture
Parameters
Type Name Description
string filename

The file from which the background picture is created.

double left

The position, in pixels, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document.

double top

The position, in pixels, of the upper-left corner of the destination rectangle relative to the top of the document.

double width

The width of the destination rectangle, in pixels.

double height

The height of the destination rectangle, in pixels.

Returns
Type Description
IBackgroundPicture

The IBackgroundPicture object that represents the new background picture.

Examples
IBackgroundPictures backgroundPictures = worksheet.BackgroundPictures;
string imagePath = CreateSampleImageFile();
IBackgroundPicture picture = null;
try
{
    picture = backgroundPictures.AddPictureInPixel(imagePath, 12, 18, 160, 90);
    picture.Name = "Watermark";
}
finally
{
    if (File.Exists(imagePath))
    {
        File.Delete(imagePath);
    }
}
Exceptions
Type Condition
IOException

if the specified file cannot be read.

AddPictureInPixel(Stream, ImageType, double, double, double, double)

Creates a background picture from an existing stream and returns the IBackgroundPicture object that represents the new background picture.

The picture is positioned and sized by the destination rectangle specified in pixels relative to the upper-left corner of the document.

Declaration
IBackgroundPicture AddPictureInPixel(Stream stream, ImageType type, double left, double top, double width, double height)
Function AddPictureInPixel(stream As Stream, type As ImageType, left As Double, top As Double, width As Double, height As Double) As IBackgroundPicture
Parameters
Type Name Description
Stream stream

The stream from which the background picture is created.

ImageType type

Specifies the type of picture to create.

double left

The position, in pixels, of the upper-left corner of the destination rectangle relative to the upper-left corner of the document.

double top

The position, in pixels, of the upper-left corner of the destination rectangle relative to the top of the document.

double width

The width of the destination rectangle, in pixels.

double height

The height of the destination rectangle, in pixels.

Returns
Type Description
IBackgroundPicture

The IBackgroundPicture object that represents the new background picture.

Examples
IBackgroundPictures backgroundPictures = worksheet.BackgroundPictures;
IBackgroundPicture picture = null;
using (MemoryStream stream = CreateSampleImageStream())
{
    picture = backgroundPictures.AddPictureInPixel(stream, ImageType.PNG, 12, 18, 160, 90);
}
Exceptions
Type Condition
IOException

if an I/O error occurs while reading the image stream.