CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
bitmap.h
1
2#ifndef _aspose_system_drawing_bitmap_h_
3#define _aspose_system_drawing_bitmap_h_
4
5#include "fwd.h"
6#include "defines.h"
7#include "drawing/image.h"
8#include "drawing/color.h"
9#include "drawing/rectangle.h"
10#include "drawing/rectangle_f.h"
11#include "drawing/imaging/bitmap_data.h"
12#include "drawing/imaging/pixel_format.h"
13#include "drawing/imaging/image_lock_mode.h"
14#include "drawing/size_f.h"
15#include "system/io/stream.h"
16#include "system/string.h"
17
18#include <memory>
19
20#if defined(ASPOSECPPLIB_BEING_BUILT) || defined(ASPOSECPP_SKIA_EXTERNAL_USAGE)
21#include <core/SkEncodedImageFormat.h>
22#include <core/SkBitmap.h>
23#include <core/SkCanvas.h>
24#endif
25
27ASPOSECPP_3RD_PARTY_CLASS(SkBitmap);
29ASPOSECPP_3RD_PARTY_CLASS(SkCanvas);
31ASPOSECPP_3RD_PARTY_CLASS(SkData);
33ASPOSECPP_3RD_PARTY_CLASS(SkWStream);
35ASPOSECPP_3RD_PARTY_CLASS(SkMatrix);
37ASPOSECPP_3RD_PARTY_STRUCT(SkImageInfo);
39ASPOSECPP_3RD_PARTY_STRUCT(SkRect);
41ASPOSECPP_3RD_PARTY_TYPEDEF(SkColor, uint32_t);
42
43#if defined(ASPOSECPPLIB_BEING_BUILT) || !defined(ASPOSECPP_SKIA_EXTERNAL_USAGE)
44// Static checks of SkEncodedImageFormat enum.
45ASPOSECPP_3RD_PARTY_ENUM_CLASS(SkEncodedImageFormat);
46#endif
47
48namespace System { namespace Drawing {
49
50namespace Detail {
53 ASPOSECPP_3RD_PARTY_ENUM_HOLDER(SkEncodedImageFormat, int, SkEncodedFormatHolder);
54}
55
56namespace Imaging { class Metafile; }
57
58class Graphics;
63class ASPOSECPP_SHARED_CLASS Bitmap : public Image
64{
65 RTTI_INFO(System::Drawing::Bitmap, ::System::BaseTypesInfo<System::Drawing::Image>)
66
67public:
70 ASPOSECPP_SHARED_API Bitmap(const SharedPtr<Image>& original);
74 ASPOSECPP_SHARED_API Bitmap(const SharedPtr<System::IO::Stream>& stream, bool useIcm = false);
77 ASPOSECPP_SHARED_API Bitmap(const String & filename);
81 ASPOSECPP_SHARED_API Bitmap(const String & filename, bool useIcm);
87 ASPOSECPP_SHARED_API Bitmap(int width, int height, Imaging::PixelFormat format = Imaging::PixelFormat::Format32bppArgb);
91 ASPOSECPP_SHARED_API Bitmap(const SharedPtr<Image>& original, const Size &size);
97 ASPOSECPP_SHARED_API Bitmap(const SharedPtr<Image>& original, int width, int height);
98 MEMBER_FUNCTION_MAKE_OBJECT(Bitmap, CODEPORTING_ARGS(const SharedPtr<Image>& original, int width, int height), CODEPORTING_ARGS(original, width, height));
99
101 virtual ASPOSECPP_SHARED_API int get_Width() const override;
103 virtual ASPOSECPP_SHARED_API int get_Height() const override;
104
106 virtual ASPOSECPP_SHARED_API Imaging::ImageFormatPtr get_RawFormat() const override;
108 virtual ASPOSECPP_SHARED_API Imaging::PixelFormat get_PixelFormat() const override;
109
111 virtual ASPOSECPP_SHARED_API Imaging::ColorPalettePtr get_Palette() const override;
114 ASPOSECPP_SHARED_API void set_Palette(Imaging::ColorPalettePtr value) override;
115
119 ASPOSECPP_SHARED_API void SetResolution(float xDpi, float yDpi);
124 ASPOSECPP_SHARED_API void SetPixel(int x, int y, Color color);
125
132
139 ASPOSECPP_SHARED_API Imaging::BitmapDataPtr LockBits(const Rectangle & rect, Imaging::ImageLockMode flags, Imaging::PixelFormat format, const Imaging::BitmapDataPtr& bitmap_data);
142 ASPOSECPP_SHARED_API void UnlockBits(const Imaging::BitmapDataPtr& bitmap_data);
147 ASPOSECPP_SHARED_API Color GetPixel(int x, int y);
148
151 ASPOSECPP_SHARED_API void MakeTransparent(Color transparent_color = Color::get_LightGray());
152
155 ASPOSECPP_SHARED_API IntPtr GetHbitmap();
156
159 virtual ASPOSECPP_SHARED_API SharedPtr<Image> Clone() override;
164 ASPOSECPP_SHARED_API SharedPtr<Bitmap> Clone(Rectangle rect, Imaging::PixelFormat format);
169 ASPOSECPP_SHARED_API SharedPtr<Bitmap> Clone(RectangleF rect, Imaging::PixelFormat format);
170
173 virtual ASPOSECPP_SHARED_API void RotateFlip(RotateFlipType rotate_flip_type) override;
174
175 // it must be public for manually implemented code parts
177 virtual ASPOSECPP_SHARED_API const SkBitmap* GetSkBitmap() const override;
178
180 virtual ASPOSECPP_SHARED_API bool IsMultiImage() const override;
181
182 // Service method used in manually implemented code parts
186 static ASPOSECPP_SHARED_API SharedPtr<Bitmap> ConvertToARGBImage(const SharedPtr<Bitmap>& src_bmp);
187
188 //service method used in manually implemented code parts
190 ASPOSECPP_SHARED_API void PremultipleColors();
191
192 //service method used in manually implemented code parts
195 ASPOSECPP_SHARED_API bool BeginPixelProcessing(bool update_colors = true);
196
197 //service method used in manually implemented code parts
200 ASPOSECPP_SHARED_API bool EndPixelProcessing(bool update_colors = true);
201
202 //service method used in manually implemented code parts
205 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ComputeHash();
206
207private:
210 void PutRawBytesBmp(SkWStream *to);
213 static sk_sp<SkColorTable> CreatePalette(Imaging::PixelFormat pixel_format);
216 sk_sp<SkColorTable> ChoosePalette(Imaging::PixelFormat pixel_format) const;
217
220
222 bool m_is_multi_image = false;
223
225 bool m_pixel_processing_mode = false;
226
228 static const SkColor s_bw_colors[];
230 static const SkColor s_indexed_colors[];
232 static const SkColor s_gray_colors[];
233
234
235protected:
236 friend class Graphics;
237 friend class Imaging::Metafile;
238
239protected:
241 ASPOSECPP_SHARED_API ~Bitmap() override;
246 ASPOSECPP_SHARED_API Bitmap(const SharedPtr<Bitmap>& original, Rectangle rect, Imaging::PixelFormat format);
247 MEMBER_FUNCTION_MAKE_OBJECT(Bitmap, CODEPORTING_ARGS(const SharedPtr<Bitmap>& original, Rectangle rect, Imaging::PixelFormat format), CODEPORTING_ARGS(original, rect, format));
251 ASPOSECPP_SHARED_API bool GetSkBitmapFromArray(const ArrayPtr<uint8_t>& data);
253 virtual ASPOSECPP_SHARED_API std::unique_ptr<SkCanvas> GetDrawingCanvas() const override;
259 virtual ASPOSECPP_SHARED_API sk_sp<SkData> GetRawBytes(SkEncodedImageFormat encoder_type, int quality) override;
261 virtual ASPOSECPP_SHARED_API const SkEncodedImageFormat GetSkEncodedFormat() const override;
263 virtual Imaging::PixelFormat GetOriginalFormat() const override { return m_original_pixel_format; }
264
273 virtual void Draw(SkCanvas* sk_canvas, const SkRect& dest_rect, const SkRect& src_rect, SkMatrix* matrix, SkFilterQuality quality, SkBlendMode blend_mode) const override;
281 virtual void Draw(SkCanvas* sk_canvas, const SkRect& dest_rect, SkMatrix* matrix, SkFilterQuality quality, SkBlendMode blend_mode) const override;
290 virtual void Draw(SkCanvas* sk_canvas, ArrayPtr<PointF> dest_points, const SkRect& src_rect, SkMatrix* matrix, SkFilterQuality quality, SkBlendMode blend_mode) const override;
299 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 override;
300
302 std::unique_ptr<SkBitmap> m_sk_bitmap;
304 Detail::SkEncodedFormatHolder m_sk_encoded_format;
307};
308
309}}
310
311
312#endif
Represents a GDI+ bitmap image. Objects of this class should only be allocated using System::MakeObje...
Definition: bitmap.h:64
~Bitmap() override
Destructor.
virtual SharedPtr< Image > Clone() override
Creates a copy of the current object.
Bitmap(const SharedPtr< Bitmap > &original, Rectangle rect, Imaging::PixelFormat format)
Constructs a Bitmap object that represents a copy of a region of the bitmap image represented by the ...
Bitmap(const String &filename)
Constructs a new Bitmap object from the specified file.
Bitmap(const SharedPtr< System::IO::Stream > &stream, bool useIcm=false)
Constructs a new Bitmap object from the specified stream.
bool GetSkBitmapFromArray(const ArrayPtr< uint8_t > &data)
Assigns the bitmap image data from the specified byte array to the specfied SkBitmap object.
virtual Imaging::ImageFormatPtr get_RawFormat() const override
Returns the file format of the image represented by the current object.
void MakeTransparent(Color transparent_color=Color::get_LightGray())
Changes the color of all pixels with the specified color to transparent.
virtual void Draw(SkCanvas *sk_canvas, const SkRect &dest_rect, const SkRect &src_rect, SkMatrix *matrix, SkFilterQuality quality, SkBlendMode blend_mode) const override
Draws the specified region of the image represented by the current object to the specified region on ...
Detail::SkEncodedFormatHolder m_sk_encoded_format
The format of the image represented by the current object.
Definition: bitmap.h:304
std::unique_ptr< SkBitmap > m_sk_bitmap
The underlying object that contains the binary image represented by the current object.
Definition: bitmap.h:302
virtual const SkEncodedImageFormat GetSkEncodedFormat() const override
Returns a value that specifies the format of the image represented by the current object.
virtual bool IsMultiImage() const override
Returns whether the original format is a multi-image.
virtual Imaging::ColorPalettePtr get_Palette() const override
Returns the color palette used by the image represented by the current object.
virtual Imaging::PixelFormat get_PixelFormat() const override
Returns the pixel format of the image represented by the current object.
void UnlockBits(const Imaging::BitmapDataPtr &bitmap_data)
Unlocks the specified bitmap from system memory.
void set_Palette(Imaging::ColorPalettePtr value) override
Sets the color palette used by the image represented by the current object.
Bitmap(const SharedPtr< Image > &original, int width, int height)
Constructs a new Bitmap object from the specified existing image with width and height scaled to the ...
ArrayPtr< uint8_t > ComputeHash()
Computes the SHA1 hash value.
Bitmap(const SharedPtr< Image > &original, const Size &size)
Constructs a new Bitmap object from the specified existing image, scaled to the specified size.
virtual void Draw(SkCanvas *sk_canvas, ArrayPtr< PointF > dest_points, const SkRect &src_rect, SkMatrix *matrix, SkFilterQuality quality, SkBlendMode blend_mode) const override
Draws the specified region of the image represented by the current object to the specified region on ...
Bitmap(const String &filename, bool useIcm)
Constructs a new Bitmap object from the specified file.
void SetResolution(float xDpi, float yDpi)
Sets the resolution of the image.
virtual std::unique_ptr< SkCanvas > GetDrawingCanvas() const override
Returns the drawing canvas object.
Imaging::BitmapDataPtr LockBits(const Rectangle &rect, Imaging::ImageLockMode flags, Imaging::PixelFormat format, const Imaging::BitmapDataPtr &bitmap_data)
Locks a Bitmap into system memory.
SharedPtr< Bitmap > Clone(Rectangle rect, Imaging::PixelFormat format)
Creates a Bitmap object that represents a copy of a region of the bitmap image represented by the cur...
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 override
Draws the specified region of the image represented by the current object to the specified region on ...
SharedPtr< Bitmap > Clone(RectangleF rect, Imaging::PixelFormat format)
Creates a Bitmap object that represents a copy of a region of the bitmap image represented by the cur...
IntPtr GetHbitmap()
Creates a GDI bitmap object from the bitmap represented by the current object.
virtual void Draw(SkCanvas *sk_canvas, const SkRect &dest_rect, SkMatrix *matrix, SkFilterQuality quality, SkBlendMode blend_mode) const override
Draws the the image represented by the current object to the specified region on the specified canvas...
virtual int get_Width() const override
Returns the width of the image in pixels.
Imaging::BitmapDataPtr LockBits(const Rectangle &rect, Imaging::ImageLockMode flags, Imaging::PixelFormat format)
Locks a Bitmap into system memory.
Bitmap(int width, int height, Imaging::PixelFormat format=Imaging::PixelFormat::Format32bppArgb)
Constructs a new Bitmap object that represents a bitmap image with the specified width,...
void SetPixel(int x, int y, Color color)
Sets the color of the specified pixel in the bitmap image represented by the current object.
virtual int get_Height() const override
Returns the height of the image in pixels.
bool EndPixelProcessing(bool update_colors=true)
Disables pixel processing mode.
bool BeginPixelProcessing(bool update_colors=true)
Enables pixel processing mode.
Color GetPixel(int x, int y)
Returns the color of the specified pixel.
virtual void RotateFlip(RotateFlipType rotate_flip_type) override
Rotates image to multiple of 90 degrees and flips.
virtual sk_sp< SkData > GetRawBytes(SkEncodedImageFormat encoder_type, int quality) override
Saves an image represented by the current object in the specified format using the specified image qu...
virtual Imaging::PixelFormat GetOriginalFormat() const override
Returns the original image format of the bitmap image represented by the current object.
Definition: bitmap.h:263
static SharedPtr< Bitmap > ConvertToARGBImage(const SharedPtr< Bitmap > &src_bmp)
Creates a copy of the specified bitmap image with pixel format changed to Format32bppArgb.
void PremultipleColors()
Premultiplies the colors of the pixels of the image represented by the current object.
Bitmap(const SharedPtr< Image > &original)
Constructs a new Bitmap object from the specified existing image.
virtual const SkBitmap * GetSkBitmap() const override
Returns a raw pointer to the underlying SkBitmap object.
Represents a color. This type should be allocated on stack and passed to functions by value or by ref...
Definition: color.h:24
static Color get_LightGray()
Returns a color whose ARGB value in hexadecimal notation is #FFD3D3D3.
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
Represents a graphic metafile. Objects of this class should only be allocated using System::MakeObjec...
Definition: metafile.h:44
Represents a rectangular area of an image defined as single-precision floating point X and Y coordina...
Definition: rectangle_f.h:15
Represents a rectangular area of an image defined as integer X and Y coordinates of its upper left co...
Definition: rectangle.h:19
Represents a pair of integer values that represent width and height of an image. This type should be ...
Definition: size.h:14
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
PixelFormat
Specifies the color data format of a pixel.
Definition: pixel_format.h:17
@ Format32bppArgb
Specifies that the pixel format is 32 bits per pixel with 8 bits for each of red, green,...
@ Undefined
Specifies that the pixel format is undefined.
ImageLockMode
Specifies properties of the region of an image being locked.
Definition: image_lock_mode.h:9
RotateFlipType
Specifies the type of rotation and/or flipping operation.
Definition: rotate_flip_type.h:7
Definition: db_command.h:9