xtd 0.2.0
image.h
Go to the documentation of this file.
1 #pragma once
5 #include "../drawing_export.h"
9 #include "imaging/image_flags.h"
10 #include "imaging/image_format.h"
11 #include "imaging/pixel_format.h"
12 #include "imaging/property_item.h"
13 #include "graphics.h"
14 #include "graphics_unit.h"
15 #include "rectangle.h"
16 #include "rotate_flip_type.h"
17 #include "size.h"
18 #include "size_f.h"
19 #include <xtd/any>
20 #include <xtd/iequatable>
21 #include <xtd/object>
22 #include <xtd/ustring>
23 #include <cstdint>
24 #include <map>
25 #include <memory>
26 #include <iostream>
27 
29 namespace xtd {
31  namespace drawing {
33  class bitmap;
35 
48  class drawing_export_ image : public xtd::object, public xtd::iequatable<image> {
49  struct data;
50 
51  public:
53  image();
54  image(const image& image) = default;
55  image& operator =(const image& image) = default;
56  ~image();
58 
60 
63  static image empty;
65 
67 
89  int32 flags() const noexcept;
90 
96  std::vector<guid> frame_dimentions_list() const noexcept;
97 
100  intptr handle() const noexcept;
101 
104  int32 height() const noexcept;
105 
108  float horizontal_resolution() const noexcept;
109 
113  imaging::color_palette palette() const noexcept;
116  void palette(const imaging::color_palette& palette) noexcept;
117 
121  const size_f& physical_dimension() const noexcept;
122 
125  imaging::pixel_format pixel_format() const noexcept;
126 
130  const std::vector<int32>& property_id_list() const noexcept;
131 
135  const std::vector<imaging::property_item>& property_items() const noexcept;
136 
139  const imaging::image_format& raw_format() const noexcept;
140 
143  const drawing::size& size() const noexcept;
144 
147  const std::any& tag() const noexcept;
150  void tag(const std::any& tag) noexcept;
151 
154  float vertical_resolution() const noexcept;
155 
158  int32 width() const noexcept;
160 
162 
164 
169  image blur(int32 radius) const;
170 
174  graphics create_graphics();
175 
176  bool equals(const image& image) const noexcept override;
177 
181  static image from_file(const xtd::ustring& filename) {return image(filename);}
182 
187  static bitmap from_hbitmap(intptr hbitmap);
188 
194  static image from_stream(std::istream& stream);
195 
200  static image from_data(const char* const* bits);
201 
205  xtd::drawing::rectangle_f get_bounds(xtd::drawing::graphics_unit page_unit) const noexcept;
206 
210  xtd::drawing::imaging::encoder_parameters get_encoder_parameter_list(xtd::guid encoder) const noexcept;
211 
218  size_t get_frame_count(const xtd::drawing::imaging::frame_dimension& dimension) const;
219 
223  static int32 get_pixel_format_size(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
224 
231  xtd::drawing::imaging::property_item get_property_item(int32 propid);
232 
239  xtd::drawing::image get_thmbnail_image(int32 thumb_width, int32 thunb_height) noexcept;
240 
244  static bool is_alpha_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
245 
249  static bool is_canonical_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
250 
254  static bool is_extended_pixel_format(xtd::drawing::imaging::pixel_format pixfmt) noexcept;
255 
261 
266  void save(const xtd::ustring& filename) const;
270  void save(const xtd::ustring& filename, const xtd::drawing::imaging::image_format& format) const;
276  void save(std::ostream& stream, const xtd::drawing::imaging::image_format& format) const;
278 
279  protected:
281  explicit image(intptr hbitmap);
282  explicit image(const xtd::ustring& filename);
283  explicit image(const xtd::ustring& filename, bool use_icm);
284  explicit image(std::istream& stream);
285  explicit image(std::istream& stream, bool use_icm);
286  explicit image(const char* const* bits);
287  image(int32 width, int32 height);
288  image(int32 width, int32 height, float horizontal_resolution, float vertical_resolution);
289  image(int32 width, int32 height, xtd::drawing::imaging::pixel_format format);
290  image(int32 width, int32 height, int32 stride, xtd::drawing::imaging::pixel_format format, intptr scan0);
291  image(const image& image, int32 width, int32 height);
292  image(const image& image, const rectangle& rect);
293  static image from_hicon(intptr hicon);
294  void set_pixel_format(imaging::pixel_format value);
296 
297  private:
298  void update_properties();
299 
300  std::shared_ptr<data> data_;
301  };
302  }
303 }
rotate_flip_type
Specifies how much an image is rotated and the axis used to flip the image.
Definition: rotate_flip_type.h:19
intmax_t intptr
Represent a pointer or a handle.
Definition: types.h:151
Contains xtd::drawing::rotate_flip_type enum class.
Specifies the file format of the image. Not inheritable.
Definition: image_format.h:25
Enum flags attribute.
Contains xtd::drawing::imaging::color_palette class.
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:31
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Stores a set of four floating-point numbers that represent the location and size of a rectangle...
Definition: rectangle_f.h:34
Contains xtd::drawing::imaging::image_flags class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
Contains xtd::drawing::imaging::frame_dimension class.
Stores an ordered pair of floating-point, which specify a height and width.
Definition: size_f.h:31
Encapsulates a metadata property to be included in an image file. Not inheritable.
Definition: property_item.h:25
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes...
Definition: bitmap.h:26
Contains xtd::drawing::rectangle class.
Encapsulates an array of EncoderParameter objects.
Definition: encoder_parameters.h:23
pixel_format
Specifies the format of the color data for each pixel in the image.
Definition: pixel_format.h:23
Provides properties that get the frame dimensions of an image. Not inheritable.
Definition: frame_dimension.h:24
Contains xtd::drawing::imaging::property_item class.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:44
An abstract base class that provides functionality for the bitmap and metafile descended classes...
Definition: image.h:48
Contains xtd::drawing::imaging::encoder_parameters class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
Contains xtd::drawing::size_f class.
int_least32_t int32
Represents a 32-bit signed integer.
Definition: types.h:129
Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be us...
Definition: guid.h:23
Contains xtd::drawing::graphics_unit enum class.
graphics_unit
Specifies the unit of measure for the given data. This enumeration has a flags attribute that allows ...
Definition: graphics_unit.h:17
Contains xtd::drawing::size class.
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:70
Contains xtd::drawing::imaging::image_format class.
static image empty
Represent an empty xtd::drawing::image.
Definition: image.h:63
Contains xtd::drawing::graphics class.
Contains xtd::drawing::imaging::pixel_format enum class.