Aspose::Pdf::ImagePlacement Class Referencefinal

Represents characteristics of an image placed to Pdf document page. More...

Inherits System::Object.

Public Member Functions

System::SharedPtr< Aspose::Pdf::Matrixget_Matrix ()
 Current transformation matrix for this image. More...
 
System::SharedPtr< Aspose::Pdf::Rectangleget_Rectangle ()
 Gets rectangle of the Image. More...
 
float get_Rotation ()
 Gets rotation angle of the Image. More...
 
System::SharedPtr< Aspose::Pdf::Devices::Resolutionget_Resolution ()
 Gets resolution of the Image. More...
 
System::SharedPtr< XImageget_Image ()
 Gets related XImage resource object. More...
 
System::SharedPtr< Aspose::Pdf::Pageget_Page ()
 Gets the page containing the image. More...
 
System::SharedPtr< Aspose::Pdf::CompositingParametersget_CompositingParameters ()
 Gets compositing parameters of graphics state active for the image placed to the page. More...
 
void Replace (System::SharedPtr< System::IO::Stream > image)
 Replace image in collection with another image. More...
 
void Save (System::SharedPtr< System::IO::Stream > stream)
 Saves image with corresponding transformations: scaling, rotation and resolution. More...
 
void Save (System::SharedPtr< System::IO::Stream > stream, System::SharedPtr< System::Drawing::Imaging::ImageFormat > format)
 Saves image with corresponding transformations: scaling, rotation and resolution. More...
 
- Public Member Functions inherited from System::Object
ASPOSECPP_SHARED_API Object ()
 Creates object. Initializes all internal data structures. More...
 
virtual ASPOSECPP_SHARED_API ~Object ()
 Destroys object. Frees all internal data structures. More...
 
ASPOSECPP_SHARED_API Object (Object const &x)
 Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
Objectoperator= (Object const &x)
 Assignment operator. Doesn't copy anything, really, just initializes new object and enables copy constructing subclasses. More...
 
ObjectSharedRefAdded ()
 Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int SharedRefRemovedSafe ()
 Decrements and returns shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
int RemovedSharedRefs (int count)
 Decreases shared reference count by specified value. More...
 
Detail::SmartPtrCounter * WeakRefAdded ()
 Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
void WeakRefRemoved ()
 Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisProtector. More...
 
Detail::SmartPtrCounter * GetCounter ()
 Gets reference counter data structure associated with the object. More...
 
int SharedCount () const
 Gets current value of shared refernce counter. More...
 
ASPOSECPP_SHARED_API void Lock ()
 Implements C# lock() statement locking. Call directly or use LockContext sentry object. More...
 
ASPOSECPP_SHARED_API void Unlock ()
 Implements C# lock() statement unlocking. Call directly or use LockContext sentry object. More...
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 Compares objects using C# Object.Equals semantics. More...
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 Analog of C# Object.GetHashCode() method. Enables hashing of custom objects. More...
 
virtual ASPOSECPP_SHARED_API String ToString () ASPOSE_CONST
 Analog of C# Object.ToString() method. Enables converting custom objects to string. More...
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 Analog of C# Object.MemberwiseClone() method. Enables cloning custom types. More...
 
virtual ASPOSECPP_SHARED_API const TypeInfoGetType () const
 Gets actual type of object. Analog of C# System.Object.GetType() call. More...
 
virtual ASPOSECPP_SHARED_API bool Is (const TypeInfo &targetType) const
 Check if object represents an instance of type described by targetType. Analog of C# 'is' operator. More...
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode. More...
 
template<>
bool Equals (float const &objA, float const &objB)
 
template<>
bool Equals (double const &objA, double const &objB)
 
template<>
bool ReferenceEquals (String const &str, std::nullptr_t)
 
template<>
bool ReferenceEquals (String const &str1, String const &str2)
 

Protected Member Functions

bool get_IsInline ()
 
 ImagePlacement (System::SharedPtr< Aspose::Pdf::Page > page, System::SharedPtr< XImage > image, double xIndent, double yIndent, double scaledWidth, double scaledHeight, int32_t resHorizontal, int32_t resVertical, System::SharedPtr< Aspose::Pdf::CompositingParameters > compositingParameters, float rotationAngle, System::SharedPtr< Aspose::Pdf::Matrix > matrix, bool isInline)
 Initializes new instance of the ImagePlacement object. More...
 

Additional Inherited Members

- Public Types inherited from System::Object
typedef SmartPtr< Objectptr
 Alias for smart pointer type. More...
 
typedef System::Details::SharedMembersType shared_members_type
 structure to keep list of shared pointers contained in object. More...
 
- Static Public Member Functions inherited from System::Object
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 Compares objects by reference. More...
 
template<typename T >
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 Reference-compares value type object with nullptr. More...
 
template<typename T1 , typename T2 >
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares reference type objects in C# style. More...
 
template<typename T1 , typename T2 >
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 Compares value type objects in C# style. More...
 
static const TypeInfoType ()
 Impleemnts C# typeof(System.Object) construct. More...
 

Detailed Description

Represents characteristics of an image placed to Pdf document page.

When an image is placed to a page it may have dimensions other than physical dimensions defined in Resources. The object ImagePlacement is intended to provide such information like dimensions, resolution and so on.

The example demonstrates how to find images on the first PDF document page and get images as bitmaps with visible dimensions.

// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create ImagePlacementAbsorber object to perform image placement search
ImagePlacementAbsorber abs = new ImagePlacementAbsorber();
// Accept the absorber for first page
doc.Pages[1].Accept(abs);
// Retrieve images with visible dimensions
foreach (ImagePlacement imagePlacement in abs.ImagePlacements)
{
Bitmap scaledImage;
using (MemoryStream imageStream = new MemoryStream())
{
// Retrieve image from resources
imagePlacement.Image.Save(imageStream, ImageFormat.Png);
Bitmap resourceImage = (Bitmap) Bitmap.FromStream(imageStream);
// Create new bitmap with actual dimensions
scaledImage = new Bitmap(resourceImage, (int)imagePlacement.Rectangle.Width, (int)imagePlacement.Rectangle.Height);
}
}

Constructor & Destructor Documentation

◆ ImagePlacement()

Aspose::Pdf::ImagePlacement::ImagePlacement ( System::SharedPtr< Aspose::Pdf::Page page,
System::SharedPtr< XImage image,
double  xIndent,
double  yIndent,
double  scaledWidth,
double  scaledHeight,
int32_t  resHorizontal,
int32_t  resVertical,
System::SharedPtr< Aspose::Pdf::CompositingParameters compositingParameters,
float  rotationAngle,
System::SharedPtr< Aspose::Pdf::Matrix matrix,
bool  isInline 
)
protected

Initializes new instance of the ImagePlacement object.

Member Function Documentation

◆ get_CompositingParameters()

System::SharedPtr<Aspose::Pdf::CompositingParameters> Aspose::Pdf::ImagePlacement::get_CompositingParameters ( )

Gets compositing parameters of graphics state active for the image placed to the page.

◆ get_Image()

System::SharedPtr<XImage> Aspose::Pdf::ImagePlacement::get_Image ( )

Gets related XImage resource object.

◆ get_IsInline()

bool Aspose::Pdf::ImagePlacement::get_IsInline ( )
protected

◆ get_Matrix()

System::SharedPtr<Aspose::Pdf::Matrix> Aspose::Pdf::ImagePlacement::get_Matrix ( )

Current transformation matrix for this image.

◆ get_Page()

System::SharedPtr<Aspose::Pdf::Page> Aspose::Pdf::ImagePlacement::get_Page ( )

Gets the page containing the image.

◆ get_Rectangle()

System::SharedPtr<Aspose::Pdf::Rectangle> Aspose::Pdf::ImagePlacement::get_Rectangle ( )

Gets rectangle of the Image.

◆ get_Resolution()

System::SharedPtr<Aspose::Pdf::Devices::Resolution> Aspose::Pdf::ImagePlacement::get_Resolution ( )

Gets resolution of the Image.

◆ get_Rotation()

float Aspose::Pdf::ImagePlacement::get_Rotation ( )

Gets rotation angle of the Image.

◆ Replace()

void Aspose::Pdf::ImagePlacement::Replace ( System::SharedPtr< System::IO::Stream image)

Replace image in collection with another image.

Parameters
imageStream containing image data.

◆ Save() [1/2]

void Aspose::Pdf::ImagePlacement::Save ( System::SharedPtr< System::IO::Stream stream)

Saves image with corresponding transformations: scaling, rotation and resolution.

Parameters
streamStream where image will be saved

◆ Save() [2/2]

void Aspose::Pdf::ImagePlacement::Save ( System::SharedPtr< System::IO::Stream stream,
System::SharedPtr< System::Drawing::Imaging::ImageFormat format 
)

Saves image with corresponding transformations: scaling, rotation and resolution.

Parameters
streamStream where image will be saved
formatFormat which will be used for image enconding. ImageFormat