Aspose::Words::Drawing::Fill::SetImage method
Contents
[
Hide
]Fill::SetImage(const System::ArrayPtr<uint8_t>&) method
Changes the fill type to single image.
void Aspose::Words::Drawing::Fill::SetImage(const System::ArrayPtr<uint8_t> &imageBytes)
Parameter | Type | Description |
---|---|---|
imageBytes | const System::ArrayPtr<uint8_t>& | The image bytes array. |
Examples
Shows how to set shape fill type as image.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// There are several ways of setting image.
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertShape(Aspose::Words::Drawing::ShapeType::Rectangle, 80, 80);
// 1 - Using a local system filename:
shape->get_Fill()->SetImage(get_ImageDir() + u"Logo.jpg");
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.FileName.docx");
// 2 - Load a file into a byte array:
shape->get_Fill()->SetImage(System::IO::File::ReadAllBytes(get_ImageDir() + u"Logo.jpg"));
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.ByteArray.docx");
// 3 - From a stream:
{
auto stream = System::MakeObject<System::IO::FileStream>(get_ImageDir() + u"Logo.jpg", System::IO::FileMode::Open);
shape->get_Fill()->SetImage(stream);
}
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.Stream.docx");
See Also
- Class Fill
- Namespace Aspose::Words::Drawing
- Library Aspose.Words for C++
Fill::SetImage(const System::SharedPtr<System::IO::Stream>&) method
Changes the fill type to single image.
void Aspose::Words::Drawing::Fill::SetImage(const System::SharedPtr<System::IO::Stream> &stream)
Parameter | Type | Description |
---|---|---|
stream | const System::SharedPtr<System::IO::Stream>& | The stream that contains the image bytes. |
Examples
Shows how to set shape fill type as image.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// There are several ways of setting image.
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertShape(Aspose::Words::Drawing::ShapeType::Rectangle, 80, 80);
// 1 - Using a local system filename:
shape->get_Fill()->SetImage(get_ImageDir() + u"Logo.jpg");
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.FileName.docx");
// 2 - Load a file into a byte array:
shape->get_Fill()->SetImage(System::IO::File::ReadAllBytes(get_ImageDir() + u"Logo.jpg"));
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.ByteArray.docx");
// 3 - From a stream:
{
auto stream = System::MakeObject<System::IO::FileStream>(get_ImageDir() + u"Logo.jpg", System::IO::FileMode::Open);
shape->get_Fill()->SetImage(stream);
}
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.Stream.docx");
See Also
- Class Fill
- Namespace Aspose::Words::Drawing
- Library Aspose.Words for C++
Fill::SetImage(const System::String&) method
Changes the fill type to single image.
void Aspose::Words::Drawing::Fill::SetImage(const System::String &fileName)
Parameter | Type | Description |
---|---|---|
fileName | const System::String& | The path to the image file. |
Examples
Shows how to set shape fill type as image.
auto doc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(doc);
// There are several ways of setting image.
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertShape(Aspose::Words::Drawing::ShapeType::Rectangle, 80, 80);
// 1 - Using a local system filename:
shape->get_Fill()->SetImage(get_ImageDir() + u"Logo.jpg");
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.FileName.docx");
// 2 - Load a file into a byte array:
shape->get_Fill()->SetImage(System::IO::File::ReadAllBytes(get_ImageDir() + u"Logo.jpg"));
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.ByteArray.docx");
// 3 - From a stream:
{
auto stream = System::MakeObject<System::IO::FileStream>(get_ImageDir() + u"Logo.jpg", System::IO::FileMode::Open);
shape->get_Fill()->SetImage(stream);
}
doc->Save(get_ArtifactsDir() + u"Shape.FillImage.Stream.docx");
See Also
- Class Fill
- Namespace Aspose::Words::Drawing
- Library Aspose.Words for C++