xtd 0.2.0
image.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../drawing_export.hpp"
14#include "graphics.hpp"
15#include "graphics_unit.hpp"
16#include "rectangle.hpp"
17#include "rotate_flip_type.hpp"
18#include "size.hpp"
19#include "size_f.hpp"
20#include <xtd/any_object>
21#include <xtd/iequatable>
22#include <xtd/object>
23#include <xtd/string>
24
26namespace xtd {
28 namespace drawing {
30 class bitmap;
31 namespace imaging::effects {
32 struct resize_effect;
33 struct scale_effect;
34 }
36
49 class drawing_export_ image : public xtd::object, public xtd::iequatable<image> {
50 struct data;
51
52 public:
54 image();
55 image(image&&) = default;
56 image(const image& image) = default;
57 image& operator =(const image& image) = default;
58 ~image();
60
62
65 static image empty;
67
69
77 const xtd::byte* alpha() const;
78
86
107 int32 flags() const noexcept;
108
114 xtd::array<guid> frame_dimentions_list() const noexcept;
115
118 intptr handle() const noexcept;
119
122 int32 height() const noexcept;
123
126 float horizontal_resolution() const noexcept;
127
131 imaging::color_palette palette() const noexcept;
134 void palette(const imaging::color_palette& palette) noexcept;
135
139 const size_f& physical_dimension() const noexcept;
140
143 imaging::pixel_format pixel_format() const noexcept;
144
148 const xtd::array<int32>& property_id_list() const noexcept;
149
153 const xtd::array<imaging::property_item>& property_items() const noexcept;
154
157 const imaging::image_format& raw_format() const noexcept;
158
166 const xtd::byte* rgb() const;
167
175 xtd::byte* rgb();
176
179 const drawing::size& size() const noexcept;
180
183 const xtd::any_object& tag() const noexcept;
186 void tag(const xtd::any_object& tag) noexcept;
187
190 float vertical_resolution() const noexcept;
191
194 int32 width() const noexcept;
196
198
202 image clone() const;
203
206 graphics create_graphics();
207
211 bool equals(const object& obj) const noexcept override;
215 bool equals(const image& other) const noexcept override;
216
220 xtd::drawing::rectangle_f get_bounds(xtd::drawing::graphics_unit page_unit) const noexcept;
221
225 xtd::drawing::imaging::encoder_parameters get_encoder_parameter_list(xtd::guid encoder) const noexcept;
226
233 xtd::size get_frame_count(const xtd::drawing::imaging::frame_dimension& dimension) const;
234
237 xtd::size get_hash_code() const noexcept override;
238
245 xtd::drawing::imaging::property_item get_property_item(int32 propid);
246
253 xtd::drawing::image get_thmbnail_image(int32 thumb_width, int32 thunb_height) noexcept;
254
259 void rotate_flip(xtd::drawing::rotate_flip_type rotate_flip_type);
260
265 void save(const xtd::string& filename) const;
269 void save(const xtd::string& filename, const xtd::drawing::imaging::image_format& format) const;
275 void save(std::ostream& stream, const xtd::drawing::imaging::image_format& format) const;
277
279
284 static image from_file(const xtd::string& filename);
285
290 static bitmap from_hbitmap(intptr hbitmap);
291
297 static image from_stream(std::istream& stream);
298
306 static bitmap from_xbm_data(const unsigned char* bits, int32 width, int32 height);
307
313 static bitmap from_xpm_data(const char* const* bits);
314
318 static int32 get_pixel_format_size(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
319
323 static bool is_alpha_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
324
328 static bool is_canonical_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
329
333 static bool is_extended_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
335
336 protected:
338 friend xtd::drawing::imaging::effects::resize_effect;
339 friend xtd::drawing::imaging::effects::scale_effect;
340 explicit image(intptr hbitmap);
341 explicit image(const xtd::string& filename);
342 explicit image(const xtd::string& filename, bool use_icm);
343 explicit image(std::istream& stream);
344 explicit image(std::istream& stream, bool use_icm);
345 image(int32 width, int32 height);
346 image(int32 width, int32 height, float horizontal_resolution, float vertical_resolution);
347 image(int32 width, int32 height, xtd::drawing::imaging::pixel_format format);
348 image(int32 width, int32 height, int32 stride, xtd::drawing::imaging::pixel_format format, intptr scan0);
349 image(const image& image, int32 width, int32 height);
350 image(const image& image, const rectangle& rect);
351 static image from_hicon(intptr hicon);
352 drawing::color get_pixel(int32 x, int32 y) const;
353 void resize(const xtd::drawing::rectangle& rect, const xtd::drawing::color& fill_color);
354 void scale(const xtd::drawing::size& size, xtd::drawing::drawing_2d::interpolation_mode interpolation_mode);
355 void set_pixel(int32 x, int32 y, const drawing::color& color);
356 void set_pixel_format(imaging::pixel_format value);
358
359 private:
360 void update_properties();
361
362 xtd::sptr<data> data_;
363 };
364 }
365}
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.hpp:26
Represents an ARGB (alpha, red, green, blue) color.
Definition color.hpp:46
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.hpp:67
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.hpp:49
const xtd::byte * alpha() const
Gets the image alpha pointer, which represents the alpha data of the image.
int32 flags() const noexcept
Gets attribute flags for the pixel data of this xtd::drawing::image.
xtd::byte * alpha()
Gets the image alpha pointer, which represents the alpha data of the image.
static image empty
Represent an empty xtd::drawing::image.
Definition image.hpp:65
Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be us...
Definition guid.hpp:24
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:43
The xtd::shared_ptr_object is a shared pointer as std::shared_ptr.
Definition shared_ptr_object.hpp:30
Contains xtd::drawing::imaging::color_palette class.
Contains xtd::drawing::imaging::encoder_parameters struct.
Contains xtd::drawing::imaging::frame_dimension class.
Contains xtd::drawing::graphics class.
Contains xtd::drawing::graphics_unit enum class.
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
graphics_unit
Specifies the unit of measure for the given data. This enumeration has a flags attribute that allows ...
Definition graphics_unit.hpp:17
rotate_flip_type
Specifies how much an image is rotated and the axis used to flip the image.
Definition rotate_flip_type.hpp:19
Contains xtd::drawing::imaging::image_flags class.
Contains xtd::drawing::imaging::image_format class.
Contains xtd::drawing::drawing_2d::interpolation_mode enum class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::drawing::imaging::pixel_format enum class.
Contains xtd::drawing::imaging::property_item class.
Contains xtd::drawing::rectangle class.
Contains xtd::drawing::rotate_flip_type enum class.
Contains xtd::drawing::size_f class.
Stores a set of four floating-point numbers that represent the location and size of a rectangle....
Definition rectangle_f.hpp:34
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44
Stores an ordered pair of floating-point, which specify a height and width.
Definition size_f.hpp:31
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31
Contains xtd::drawing::size class.