CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
image.h
1
2#ifndef _aspose_system_drawing_image_h_
3#define _aspose_system_drawing_image_h_
4
5#include "system/object.h"
6#include "system/nullable.h"
7#include "system/idisposable.h"
8#include "system/details/array_view.h"
9#include "drawing/imaging/image_attributes.h"
10#include "drawing/imaging/image_format.h"
11#include "drawing/imaging/image_codec_info.h"
12#include "drawing/imaging/encoder_parameters.h"
13#include "drawing/imaging/encoder_value.h"
14#include "drawing/imaging/pixel_format.h"
15#include "drawing/imaging/color_palette.h"
16#include "drawing/imaging/frame_dimension.h"
17#include "drawing/rotate_flip_type.h"
18#include "drawing/graphics_unit.h"
19#include "drawing/size.h"
20#include "drawing/rectangle_f.h"
21#include "system/io/stream.h"
22#include "system/string.h"
23#include "imaging/image_flags.h"
24#include "imaging/property_item.h"
25
26// skia headers and forwards
27#if defined(ASPOSECPPLIB_BEING_BUILT) || defined(ASPOSECPP_SKIA_EXTERNAL_USAGE)
28#include <core/SkImage.h>
29#include <core/SkData.h>
30#include <core/SkEncodedImageFormat.h>
31#include <encode/SkTIFFImageEncoder.h>
32#endif
33
34#define ASPOSE_DUMMY_META_FILE
35
37ASPOSECPP_3RD_PARTY_CLASS(SkBitmap);
39ASPOSECPP_3RD_PARTY_CLASS(SkCanvas);
41ASPOSECPP_3RD_PARTY_CLASS(SkData);
43ASPOSECPP_3RD_PARTY_CLASS(SkMatrix);
45ASPOSECPP_3RD_PARTY_CLASS(SkTIFFImageEncoder)
47ASPOSECPP_3RD_PARTY_CLASS(SkRWStream);
48// Forward declaration of SkImageInfo struct.
49ASPOSECPP_3RD_PARTY_STRUCT(SkImageInfo);
50// Forward declaration of SkRect struct.
51ASPOSECPP_3RD_PARTY_STRUCT(SkRect);
52
53#if defined(ASPOSECPPLIB_BEING_BUILT) || !defined(ASPOSECPP_SKIA_EXTERNAL_USAGE)
54ASPOSECPP_3RD_PARTY_ENUM_CLASS(SkEncodedImageFormat);
56ASPOSECPP_3RD_PARTY_ENUM(SkFilterQuality);
58ASPOSECPP_3RD_PARTY_ENUM_CLASS(SkBlendMode);
59#endif
60
61template <typename T> class sk_sp;
62
63namespace System { namespace Drawing {
64
65 class Bitmap;
66 class TextureBrush;
71 class ASPOSECPP_SHARED_CLASS Image: virtual public System::IDisposable
72 {
73 RTTI_INFO(System::Drawing::Image, ::System::BaseTypesInfo<System::IDisposable>)
74
75 public:
78 ASPOSECPP_SHARED_API void Save(const String & filename);
82 ASPOSECPP_SHARED_API void Save(const String & filename, const Imaging::ImageFormatPtr& format);
86 ASPOSECPP_SHARED_API void Save(const SharedPtr<System::IO::Stream>& stream, const Imaging::ImageFormatPtr& format);
91 ASPOSECPP_SHARED_API void Save(const String & filename, const Imaging::ImageCodecInfoPtr& encoder, const Imaging::EncoderParametersPtr& encoder_params);
96 ASPOSECPP_SHARED_API void Save(const SharedPtr<System::IO::Stream>& stream, const Imaging::ImageCodecInfoPtr& encoder, const Imaging::EncoderParametersPtr& encoder_params);
99 ASPOSECPP_SHARED_API void SaveAdd(const Imaging::EncoderParametersPtr& encoder_params);
103 ASPOSECPP_SHARED_API void SaveAdd(const SharedPtr<Image>& image, const Imaging::EncoderParametersPtr& encoder_params);
104
107 virtual ASPOSECPP_SHARED_API SharedPtr<Image> Clone() = 0;
108
111 virtual ASPOSECPP_SHARED_API void RotateFlip(RotateFlipType rotate_flip_type);
112
114 virtual ASPOSECPP_SHARED_API ArrayPtr<int> get_PropertyIdList() const;
115
120 ASPOSECPP_SHARED_API RectangleF GetBounds(GraphicsUnit & page_unit);
121
123 virtual ASPOSECPP_SHARED_API int get_Width() const = 0;
125 virtual ASPOSECPP_SHARED_API int get_Height() const = 0;
128 virtual int32_t get_Flags() const;
131 ASPOSECPP_SHARED_API Size get_Size() const;
132
134 virtual ASPOSECPP_SHARED_API Imaging::ImageFormatPtr get_RawFormat() const = 0;
136 virtual ASPOSECPP_SHARED_API Imaging::PixelFormat get_PixelFormat() const = 0;
137
139 virtual ASPOSECPP_SHARED_API System::SharedPtr<System::Object> get_Tag() const;
141 virtual ASPOSECPP_SHARED_API void set_Tag(const System::SharedPtr<System::Object> tag);
142
144 ASPOSECPP_SHARED_API float get_HorizontalResolution() const;
146 ASPOSECPP_SHARED_API float get_VerticalResolution() const;
147
149 virtual ASPOSECPP_SHARED_API Imaging::ColorPalettePtr get_Palette() const;
152 virtual ASPOSECPP_SHARED_API void set_Palette(Imaging::ColorPalettePtr value);
153
155 virtual ASPOSECPP_SHARED_API bool IsMultiImage() const;
156
159 ASPOSECPP_SHARED_API ArrayPtr<Guid> get_FrameDimensionsList() const;
160
164 ASPOSECPP_SHARED_API int GetFrameCount(const Imaging::FrameDimensionPtr& dimension);
169 ASPOSECPP_SHARED_API int SelectActiveFrame(const Imaging::FrameDimensionPtr& dimension, int frameIndex);
170
173
179 static ASPOSECPP_SHARED_API SharedPtr<Image> FromStream(const SharedPtr<System::IO::Stream>& stream, bool use_embedded_color_management = false, bool validate_image_data = true);
184 static ASPOSECPP_SHARED_API SharedPtr<Image> FromFile(const String & filename, bool use_embedded_color_management = false);
185
189 static ASPOSECPP_SHARED_API bool IsAlphaPixelFormat(Imaging::PixelFormat pixfmt);
193 static ASPOSECPP_SHARED_API int GetPixelFormatSize(Imaging::PixelFormat pixfmt);
197 static ASPOSECPP_SHARED_API SharedPtr<Bitmap> FromHbitmap(IntPtr hbitmap);
199 void Dispose() override { };
200
202 virtual ASPOSECPP_SHARED_API const SkBitmap* GetSkBitmap() const = 0;
203
205 using GetThumbnailImageAbort = System::MulticastDelegate<bool()>;
206
213 ASPOSECPP_SHARED_API SharedPtr<Image> GetThumbnailImage(int thumbWidth, int thumbHeight, Image::GetThumbnailImageAbort callback, IntPtr callbackData);
214
215 protected:
217 static const int s_default_save_quality = 80;
218
219 friend class Graphics;
220 friend class TextureBrush;
221 friend class Bitmap;
222
225 {
234 };
235
237 static SkBitmap ConvertToGrayscale(const SkBitmap& src_bitmap);
238
242
244 virtual ASPOSECPP_SHARED_API std::unique_ptr<SkCanvas> GetDrawingCanvas() const = 0;
250 virtual ASPOSECPP_SHARED_API sk_sp<SkData> GetRawBytes(SkEncodedImageFormat encoder_type, int quality) = 0;
251
258 ASPOSECPP_SHARED_API void InternalSave(const SharedPtr<System::IO::Stream>& stream, SkEncodedImageFormat encoder_type,
260 int pixel_format = 32, int quality = s_default_save_quality);
261
266 void InternalSave(const SharedPtr<IO::Stream>& stream, SkEncodedImageFormat encoder_type, const SaveOptions& options);
267
271 void InternalSavePage(const SkBitmap* bitmap, const SaveOptions& options);
272
277 ASPOSECPP_SHARED_API SkEncodedImageFormat CheckOutputFormat(const Imaging::ImageFormatPtr& image_format) const;
282 static ASPOSECPP_SHARED_API SkEncodedImageFormat CheckOutputFormat(const Imaging::ImageCodecInfoPtr& encoder);
287 static ASPOSECPP_SHARED_API SkEncodedImageFormat CheckOutputFormat(SkEncodedImageFormat encoded_format);
288
290 virtual ASPOSECPP_SHARED_API const SkEncodedImageFormat GetSkEncodedFormat() const = 0;
292 virtual ASPOSECPP_SHARED_API Imaging::PixelFormat GetOriginalFormat() const = 0;
293
302 virtual void Draw(SkCanvas* sk_canvas, const SkRect& dest_rect, const SkRect&src_rect, SkMatrix* matrix, SkFilterQuality quality, SkBlendMode blend_mode) const = 0;
310 virtual void Draw(SkCanvas* sk_canvas, const SkRect& dest_rect, SkMatrix* matrix, SkFilterQuality quality, SkBlendMode blend_mode) const = 0;
319 virtual void Draw(SkCanvas* sk_canvas, ArrayPtr<PointF> dest_points, const SkRect& src_rect, SkMatrix* matrix, SkFilterQuality quality, SkBlendMode blend_mode) const = 0;
328 virtual void Draw(SkCanvas* sk_canvas, const System::Details::ArrayView<PointF>& dest_points, const SkRect& src_rect, SkMatrix* matrix, SkFilterQuality quality, SkBlendMode blend_mode) const = 0;
329
333 static ASPOSECPP_SHARED_API bool IsWmf(const System::SharedPtr<System::IO::Stream>& stream);
334
338 static ASPOSECPP_SHARED_API bool IsEmf(const System::SharedPtr<System::IO::Stream>& stream);
339
343 float m_horizontal_resolution = 96.f; //only default 96dpi is supported
345 float m_vertical_resolution = 96.f; //only default 96dpi is supported
346
347 private:
348 std::unique_ptr<SkRWStream> m_stream;
349 std::unique_ptr<SkTIFFImageEncoder> m_tiff_encoder;
350
351 System::SharedPtr<System::Object> m_tag = nullptr;
353
355 static const int16_t s_tiff_tag_compression = 0x103;
357 int16_t GetTiffCompression(const ArrayPtr<uint8_t>& stream);
359 Nullable<int16_t> m_tiff_compression;
360
365 sk_sp<SkData> GetTiffRawBytes(Imaging::EncoderValue encoder_value, int pixel_format);
366
368 Imaging::PixelFormat GetTiffPixelFormat(const ArrayPtr<uint8_t>& stream);
369 };
370}}
371
372
373#endif
Represents a GDI+ bitmap image. Objects of this class should only be allocated using System::MakeObje...
Definition: bitmap.h:64
Represents a drawing surface. Objects of this class should only be allocated using System::MakeObject...
Definition: graphics.h:68
A base class for System::Drawing::Bitmap and System::Drawing::Metafile classes providing basic functi...
Definition: image.h:72
SharedPtr< Image > GetThumbnailImage(int thumbWidth, int thumbHeight, Image::GetThumbnailImageAbort callback, IntPtr callbackData)
Gets a thumbnail for this System::Drawing::Image object.
void Dispose() override
Releases all resources aquired by the current object.
Definition: image.h:199
virtual int32_t get_Flags() const
Returns a bit-wise combination of ImageFlags enum values that represents the attributes of the image.
static SaveOptions ParseEncoderParameters(const Imaging::EncoderParametersPtr &encoder_params)
Converts a set of encoder parameters into a SaveOptions structure.
void Save(const SharedPtr< System::IO::Stream > &stream, const Imaging::ImageFormatPtr &format)
Saves the image represented by the current object to the specified stream in the specified format.
static SkEncodedImageFormat CheckOutputFormat(SkEncodedImageFormat encoded_format)
Checks if the specified format is among supported.
static SkBitmap ConvertToGrayscale(const SkBitmap &src_bitmap)
Converts 32bpp image to 8bpp grayscale image.
virtual const SkBitmap * GetSkBitmap() const =0
Returns an underlying SkBitmap object.
static SharedPtr< Image > FromStream(const SharedPtr< System::IO::Stream > &stream, bool use_embedded_color_management=false, bool validate_image_data=true)
Creates an Image object from the specified stream.
System::MulticastDelegate< bool()> GetThumbnailImageAbort
A callback to cancel GetThumbnailImage execution.
Definition: image.h:205
virtual void set_Palette(Imaging::ColorPalettePtr value)
Sets the color palette used by the image represented by the current object.
void Save(const String &filename, const Imaging::ImageFormatPtr &format)
Saves the image represented by the current object to the specified file in the specified format.
virtual sk_sp< SkData > GetRawBytes(SkEncodedImageFormat encoder_type, int quality)=0
Saves an image represented by the current object in the specified format using the specified image qu...
virtual void Draw(SkCanvas *sk_canvas, ArrayPtr< PointF > dest_points, const SkRect &src_rect, SkMatrix *matrix, SkFilterQuality quality, SkBlendMode blend_mode) const =0
Draws the specified region of the image to the specified region on the specified canvas....
int SelectActiveFrame(const Imaging::FrameDimensionPtr &dimension, int frameIndex)
Selects the specified frame.
static SharedPtr< Bitmap > FromHbitmap(IntPtr hbitmap)
Constructs a Bitmap object from the specified GDI bitmap.
float get_HorizontalResolution() const
Returns the horizontal resolution of the image represented by the current object in pixels per inch.
virtual ArrayPtr< SharedPtr< Imaging::PropertyItem > > get_PropertyItems() const
Gets all the property items(pieces of metadata) stored in this image.
virtual std::unique_ptr< SkCanvas > GetDrawingCanvas() const =0
Returns the drawing canvas object.
virtual void Draw(SkCanvas *sk_canvas, const SkRect &dest_rect, SkMatrix *matrix, SkFilterQuality quality, SkBlendMode blend_mode) const =0
Draws the the image to the specified region on the specified canvas. The source image is scaled and t...
int GetFrameCount(const Imaging::FrameDimensionPtr &dimension)
Returns the number of frames of the specified frame dimension.
void SaveAdd(const SharedPtr< Image > &image, const Imaging::EncoderParametersPtr &encoder_params)
Adds a frame to the file or stream specified in a previous call to the Save() method.
static bool IsWmf(const System::SharedPtr< System::IO::Stream > &stream)
Determines if the data in the specified stream starts with the WMF format marker.
virtual int get_Width() const =0
Returns the width of the image in pixels.
ArrayPtr< Guid > get_FrameDimensionsList() const
Returns an array of GUIDs that represent the dimensions of frames within the image represented by the...
static SharedPtr< Image > FromFile(const String &filename, bool use_embedded_color_management=false)
Creates an Image object from the specified file.
RectangleF GetBounds(GraphicsUnit &page_unit)
Returns the image bounds in the specified measurement units.
virtual void Draw(SkCanvas *sk_canvas, const SkRect &dest_rect, const SkRect &src_rect, SkMatrix *matrix, SkFilterQuality quality, SkBlendMode blend_mode) const =0
Draws the specified region of the image to the specified region on the specified canvas....
virtual ArrayPtr< int > get_PropertyIdList() const
Gets IDs of the property items stored in this image.
static SkEncodedImageFormat CheckOutputFormat(const Imaging::ImageCodecInfoPtr &encoder)
Checks if the specified encoder is supported and returns a SkEncodedFormat value that represents an i...
void Save(const String &filename)
Saves the image represented by the current object to the specified file in PNG format.
virtual System::SharedPtr< System::Object > get_Tag() const
Gets an object that provides additional data about the image.
virtual void RotateFlip(RotateFlipType rotate_flip_type)
Rotate image to multiple of 90 degrees and flip.
virtual int get_Height() const =0
Returns the height of the image in pixels.
virtual const SkEncodedImageFormat GetSkEncodedFormat() const =0
Returns an underlying SkEncodedFormat object.
void InternalSave(const SharedPtr< System::IO::Stream > &stream, SkEncodedImageFormat encoder_type, Imaging::EncoderValue encoder_value=Imaging::EncoderValue::CompressionLZW, int pixel_format=32, int quality=s_default_save_quality)
Saves the image represented by the current object to the specified stream in the specified format.
void SaveAdd(const Imaging::EncoderParametersPtr &encoder_params)
Adds a frame to the file or stream specified in a previous call to the Save() method.
static bool IsAlphaPixelFormat(Imaging::PixelFormat pixfmt)
Determines if the specified pixel format contains alpha information.
void InternalSave(const SharedPtr< IO::Stream > &stream, SkEncodedImageFormat encoder_type, const SaveOptions &options)
Saves the image represented by the current object to the specified stream in the specified format.
void Save(const SharedPtr< System::IO::Stream > &stream, const Imaging::ImageCodecInfoPtr &encoder, const Imaging::EncoderParametersPtr &encoder_params)
Saves the image represented by the current object to the specified stream using the specified encoder...
float get_VerticalResolution() const
Returns the vertical resolution of the image represented by the current object in pixels per inch.
virtual Imaging::PixelFormat get_PixelFormat() const =0
Returns the pixel format of the image represented by the current object.
virtual void set_Tag(const System::SharedPtr< System::Object > tag)
Sets an object that provides additional data about the image.
virtual Imaging::ImageFormatPtr get_RawFormat() const =0
Returns the file format of the image represented by the current object.
virtual Imaging::ColorPalettePtr get_Palette() const
Returns the color palette used by the image represented by the current object.
static int GetPixelFormatSize(Imaging::PixelFormat pixfmt)
Returns the number of bits used to represent the color depth in the specified pixel format.
Size get_Size() const
Returns a Size object that represents the width and height of the image in pixels.
virtual SharedPtr< Image > Clone()=0
Creates a copy of the current object.
void Save(const String &filename, const Imaging::ImageCodecInfoPtr &encoder, const Imaging::EncoderParametersPtr &encoder_params)
Saves the image represented by the current object to the specified file using the specified encoder a...
SkEncodedImageFormat CheckOutputFormat(const Imaging::ImageFormatPtr &image_format) const
Checks if the specified image format is supported and returns a SkEncodedFormat value that represents...
virtual bool IsMultiImage() const
Returns whether the original format is a multi-image.
virtual void Draw(SkCanvas *sk_canvas, const System::Details::ArrayView< PointF > &dest_points, const SkRect &src_rect, SkMatrix *matrix, SkFilterQuality quality, SkBlendMode blend_mode) const =0
Draws the specified region of the image to the specified region on the specified canvas....
virtual Imaging::PixelFormat GetOriginalFormat() const =0
Returns the original image format.
static bool IsEmf(const System::SharedPtr< System::IO::Stream > &stream)
Determines if the data in the specified stream starts with the EMF format marker.
Imaging::ColorPalettePtr m_palette
The color palette used by the image represented by the current object.
Definition: image.h:341
void InternalSavePage(const SkBitmap *bitmap, const SaveOptions &options)
Saves the bitmap as a part of a multipage image.
Represents a rectangular area of an image defined as single-precision floating point X and Y coordina...
Definition: rectangle_f.h:15
Represents a pair of integer values that represent width and height of an image. This type should be ...
Definition: size.h:14
Represents a brush that uses an image to fill the interior of a shape. Objects of this class should o...
Definition: texture_brush.h:38
Defines method that releases resources owned by the current object. Objects of this class should only...
Definition: idisposable.h:30
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
@ Bitmap
Defines color adjustment information for Bitmap objects.
EncoderValue
Specifies the parameter value passed to a JPEG or TIFF image encoder.
Definition: encoder_value.h:10
@ CompressionLZW
The LZW compression method.
ImageFlags
Represents attributes of the pixel data represented by an Image object.
Definition: image_flags.h:9
PixelFormat
Specifies the color data format of a pixel.
Definition: pixel_format.h:17
RotateFlipType
Specifies the type of rotation and/or flipping operation.
Definition: rotate_flip_type.h:7
GraphicsUnit
Represents a unit of measure.
Definition: graphics_unit.h:10
Definition: db_command.h:9
Structure that represents save options.
Definition: image.h:225
Nullable< Imaging::EncoderValue > Flag
Specifies the parameter value passed to a JPEG or TIFF image encoder.
Definition: image.h:229
Nullable< int > PixelFormat
The amount bits per pixel.
Definition: image.h:233
Nullable< int > Quality
The quality level used when encoding an image.
Definition: image.h:227
Nullable< Imaging::EncoderValue > Compression
The compression type.
Definition: image.h:231