xtd - Reference Guide 0.2.0
drawing

Definition

All needed for drawing something.

Remarks
A xtd::drawing::graphics class is create from xtd::forms::control::create_graphics or xtd::forms::screen::create_graphics or xtd::drawing::image::create_graphics.
And also when xtd::forms::control::paint event is sent, the xtd::forms::paint_event_args contains a xtd::drawing::graphics associate to the control event paint.
Collaboration diagram for drawing:

Classes

class  xtd::drawing::basic_colors
 Basic colors for all the hmtl basic colors. This class cannot be inherited. More...
 
class  xtd::drawing::bitmap
 Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes. A bitmap is an object used to work with images defined by pixel data. More...
 
class  xtd::drawing::blue_colors
 Blue colors for all the hmtl blue colors. This class cannot be inherited. More...
 
class  xtd::drawing::brown_colors
 Brown colors for all the hmtl brown colors. This class cannot be inherited. More...
 
class  xtd::drawing::brush
 Defines objects used to fill the interiors of graphical shapes such as rectangles, ellipses, pies, polygons, and paths. More...
 
class  xtd::drawing::brushes
 brushes for all the standard colors. This class cannot be inherited. More...
 
class  xtd::drawing::color
 Represents an ARGB (alpha, red, green, blue) color. More...
 
class  xtd::drawing::colors
 colors for all the standard colors. This class cannot be inherited. More...
 
class  xtd::drawing::cyan_colors
 Cyan colors for all the hmtl cyan colors. This class cannot be inherited. More...
 
class  xtd::drawing::drawing2d::conical_gradient_brush
 Encapsulates a xtd::drawing::brush with a conical gradient. This class cannot be inherited. More...
 
class  xtd::drawing::drawing2d::graphics_path
 Defines an object used to draw lines and curves. This class cannot be inherited. More...
 
class  xtd::drawing::drawing2d::graphics_state
 Represents the state of a xtd::drawing::graphics object. This object is returned by a call to the xtd::drawing::graphics::save() methods. This class cannot be inherited. More...
 
class  xtd::drawing::drawing2d::hatch_brush
 Defines a rectangular xtd::drawing::brush with a hatch style, a foreground color, and a background color. This class cannot be inherited. More...
 
class  xtd::drawing::drawing2d::linear_gradient_brush
 Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited. More...
 
class  xtd::drawing::drawing2d::matrix
 Encapsulates a 3-by-3 affine matrix that represents a geometric transform. This class cannot be inherited. More...
 
class  xtd::drawing::drawing2d::radial_gradient_brush
 Encapsulates a xtd::drawing::brush with a radial gradient. This class cannot be inherited. More...
 
class  xtd::drawing::font
 Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited. More...
 
class  xtd::drawing::font_family
 Defines a group of type faces having a similar basic design and certain variations in styles. This class cannot be inherited. More...
 
class  xtd::drawing::graphics
 Defines an object used to draw lines and curves. This class cannot be inherited. More...
 
class  xtd::drawing::gray_colors
 Gray and black colors for all the hmtl gray and black colors. This class cannot be inherited. More...
 
class  xtd::drawing::green_colors
 Green colors for all the hmtl green colors. This class cannot be inherited. More...
 
class  xtd::drawing::icon
 Represents a Windows icon, which is a small bitmap image that is used to represent an object. Icons can be thought of as transparent bitmaps, although their size is determined by the system. More...
 
class  xtd::drawing::image
 An abstract base class that provides functionality for the bitmap and metafile descended classes. More...
 
class  xtd::drawing::orange_colors
 Orange colors for all the hmtl orange colors. This class cannot be inherited. More...
 
class  xtd::drawing::pen
 Defines an object used to draw lines and curves. This class cannot be inherited. More...
 
class  xtd::drawing::pens
 pens for all the standard colors. This class cannot be inherited. More...
 
class  xtd::drawing::pink_colors
 Pink colors for all the hmtl pink colors. This class cannot be inherited. More...
 
class  xtd::drawing::point
 Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane. More...
 
class  xtd::drawing::point_f
 Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimensional plane. More...
 
class  xtd::drawing::purple_colors
 Purple, violet and magenta colors for all the hmtl purple, violet and magenta colors. This class cannot be inherited. More...
 
class  xtd::drawing::rectangle
 Stores a set of four integers that represent the location and size of a rectangle. More...
 
class  xtd::drawing::rectangle_f
 Stores a set of four floating-point numbers that represent the location and size of a rectangle. For more advanced region functions, use a xtd::drawing::region object. More...
 
class  xtd::drawing::red_colors
 Red colors for all the hmtl red colors. This class cannot be inherited. More...
 
class  xtd::drawing::region
 Describes the interior of a graphics shape composed of rectangles and paths. This class cannot be inherited. More...
 
class  xtd::drawing::size
 Stores an ordered pair of integers, which specify a height and width. More...
 
class  xtd::drawing::size_f
 Stores an ordered pair of floating-point, which specify a height and width. More...
 
class  xtd::drawing::solid_brush
 Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes, such as rectangles, ellipses, pies, polygons, and paths. This class cannot be inherited. More...
 
class  xtd::drawing::system_brushes
 Each property of the xtd::drawing::system_brushes class is a xtd::drawing::solid_brush that is the color of a Windows display element. More...
 
class  xtd::drawing::system_colors
 Each property of the xtd::drawing::system_colors class is a xtd::drawing::color structure that is the color of a Windows display element. More...
 
class  xtd::drawing::system_fonts
 Specifies the fonts used to display text in Windows display elements. More...
 
class  xtd::drawing::system_icons
 Each property of the xtd::drawing::system_icons class is an xtd::drawing::icon object for Windows system-wide icons. This class cannot be inherited. More...
 
class  xtd::drawing::system_images
 Each property of the xtd::drawing::system_images class is an xtd::drawing::image object for Windows system-wide images. This class cannot be inherited. More...
 
class  xtd::drawing::system_pens
 Each property of the xtd::drawing::system_pens class is a xtd::drawing::xtd::drawing::pen that is the color of a Windows display element and that has a width of 1 pixel. More...
 
class  xtd::drawing::texture_brush
 Each property of the xtd::drawing::texture_brush class is a xtd::drawing::brush object that uses an image to fill the interior of a shape. This class cannot be inherited. More...
 
class  xtd::drawing::white_colors
 White colors for all the hmtl white colors. This class cannot be inherited. More...
 
class  xtd::drawing::yellow_colors
 Yellow colors for all the hmtl yellow colors. This class cannot be inherited. More...
 
class  xtd::forms::control_paint
 Provides methods used to paint common Windows controls and their elements. This class cannot be inherited. More...
 

Typedefs

using xtd::drawing::black_colors = xtd::drawing::gray_colors
 Gray and black colors for all the hmtl gray and black colors. More...
 
using xtd::drawing::extended_colors = xtd::drawing::colors
 extended_colors for all the html extended colors. More...
 
using xtd::drawing::drawing2d::gradient_stop = std::pair< xtd::drawing::color, float >
 Describes the location and color of a transition point in a gradient. More...
 
using xtd::drawing::drawing2d::gradient_stop_collection = std::vector< xtd::drawing::drawing2d::gradient_stop >
 Represents a collection of xtd::drawing::drawing2d::gradient_stop objects that can be individually accessed by index. More...
 
using xtd::drawing::magenta_colors = xtd::drawing::purple_colors
 Purple, violet and magenta colors for all the hmtl purple, violet and magenta colors. More...
 
using xtd::drawing::violet_colors = xtd::drawing::purple_colors
 Purple, violet and magenta colors for all the hmtl purple, violet and magenta colors. More...
 

Methods

graphics xtd::drawing::image::create_graphics ()
 Creates the xtd::drawing::graphics for the image. More...
 
xtd::drawing::rectangle_f xtd::drawing::image::get_bounds (xtd::drawing::graphics_unit page_unit) const
 Gets the bounds of the image in the specified unit. More...
 
xtd::drawing::imaging::encoder_parameters xtd::drawing::image::get_encoder_parameter_list (xtd::guid encoder) const
 Returns information about the parameters supported by the specified image encoder. More...
 
size_t xtd::drawing::image::get_frame_count (const xtd::drawing::imaging::frame_dimension &dimension) const
 Returns the number of frames of the specified dimension. More...
 
xtd::drawing::imaging::property_item xtd::drawing::image::get_property_item (int32_t propid)
 Gets the specified property item from this xtd::drawing::image. More...
 
xtd::drawing::image xtd::drawing::image::get_thmbnail_image (int32_t thumb_width, int32_t thunb_height)
 Returns a thumbnail for this xtd::drawing::image. More...
 
void xtd::drawing::image::rotate_flip (xtd::drawing::rotate_flip_type rotate_flip_type)
 Rotates, flips, or rotates and flips the xtd::drawing::image. More...
 
void xtd::drawing::image::save (const xtd::ustring &filename) const
 Saves this xtd::drawing::image to the specified file or stream. More...
 
void xtd::drawing::image::save (const xtd::ustring &filename, const xtd::drawing::imaging::image_format &format) const
 Saves this xtd::drawing::image to the specified file in the specified format. More...
 
void xtd::drawing::image::save (std::ostream &stream, const xtd::drawing::imaging::image_format &format) const
 Saves this image to the specified stream in the specified format. More...
 
static image xtd::drawing::image::from_file (const xtd::ustring &filename)
 Creates an image from the specified file. More...
 
static bitmap xtd::drawing::image::from_hbitmap (intptr_t hbitmap)
 Creates a xtd::drawing::bitmap from a handle to a GDI bitmap. More...
 
static image xtd::drawing::image::from_stream (std::istream &stream)
 Creates an xtd::drawing::image from the specified data stream. More...
 
static image xtd::drawing::image::from_data (const char *const *bits)
 Creates an xtd::drawing::image from the specified data pointer. More...
 
static int32_t xtd::drawing::image::get_pixel_format_size (xtd::drawing::imaging::pixel_format pixfmt)
 Returns the color depth, in number of bits per pixel, of the specified pixel format. More...
 
static bool xtd::drawing::image::is_alpha_pixel_format (xtd::drawing::imaging::pixel_format pixfmt)
 Returns a value that indicates whether the pixel format for this xtd::drawing::image contains alpha information. More...
 
static bool xtd::drawing::image::is_canonical_pixel_format (xtd::drawing::imaging::pixel_format pixfmt)
 Returns a value that indicates whether the pixel format is 32 bits per pixel. More...
 
static bool xtd::drawing::image::is_extended_pixel_format (xtd::drawing::imaging::pixel_format pixfmt)
 Returns a value that indicates whether the pixel format is 64 bits per pixel. More...
 

Methods

drawing::graphics xtd::forms::control::create_graphics () const
 Creates the xtd::drawing::graphics for the control. More...
 

Properties

static drawing::graphics xtd::forms::screen::create_graphics ()
 Creates the xtd::drawing::graphics for the screen. More...
 

Typedef Documentation

◆ black_colors

#include <xtd.drawing/include/xtd/drawing/black_colors.h>

Gray and black colors for all the hmtl gray and black colors.

Namespace
xtd::drawing
Library
xtd.drawing

◆ extended_colors

#include <xtd.drawing/include/xtd/drawing/extended_colors.h>

extended_colors for all the html extended colors.

Namespace
xtd::drawing
Library
xtd.drawing

◆ gradient_stop

#include <xtd.drawing/include/xtd/drawing/drawing2d/gradient_stop.h>

Describes the location and color of a transition point in a gradient.

Namespace
xtd::drawing::drawing2d
Library
xtd.drawing
Parameters
colorThe color of the gradient stop.
offsetThe location of the gradient stop within the gradient vector.
Remarks
A value of 0.0 specifies that the stop is positioned at the beginning of the gradient vector, while a value of 1.0 specifies that the stop is positioned at the end of the gradient vector.

◆ gradient_stop_collection

◆ magenta_colors

#include <xtd.drawing/include/xtd/drawing/magenta_colors.h>

Purple, violet and magenta colors for all the hmtl purple, violet and magenta colors.

Namespace
xtd::drawing
Library
xtd.drawing

◆ violet_colors

#include <xtd.drawing/include/xtd/drawing/violet_colors.h>

Purple, violet and magenta colors for all the hmtl purple, violet and magenta colors.

Namespace
xtd::drawing
Library
xtd.drawing

Function Documentation

◆ create_graphics() [1/3]

static drawing::graphics xtd::forms::screen::create_graphics ( )
static

#include <xtd.forms/include/xtd/forms/screen.h>

Creates the xtd::drawing::graphics for the screen.

Returns
A xtd::drawing::graphics for the screen.

◆ create_graphics() [2/3]

graphics xtd::drawing::image::create_graphics ( )
inline

#include <xtd.drawing/include/xtd/drawing/image.h>

Creates the xtd::drawing::graphics for the image.

Returns
A xtd::drawing::graphics for the image.

◆ create_graphics() [3/3]

drawing::graphics xtd::forms::control::create_graphics ( ) const

#include <xtd.forms/include/xtd/forms/control.h>

Creates the xtd::drawing::graphics for the control.

Returns
A xtd::drawing::graphics for the control.
Remarks
The graphics object that you retrieve through the create_graphics method should not normally be retained after the current Windows message has been processed, because anything painted with that object will be erased with the next WM_PAINT message. Therefore you cannot cache the graphics object for reuse, except to use non-visual methods like xtd::drawing::graphics::measure_string. Instead, you must call create_graphics every time that you want to use the graphics object.

◆ from_data()

static image xtd::drawing::image::from_data ( const char *const *  bits)
static

#include <xtd.drawing/include/xtd/drawing/image.h>

Creates an xtd::drawing::image from the specified data pointer.

Parameters
dataA pointer that contains the data for this xtd::drawing::image.
Returns
The xtd::drawing::image this method creates.
Remarks
This method is used for creating a xtd::drawing::image from an XPM (or XBM) image.
Examples:
bitmap_button.cpp.

◆ from_file()

static image xtd::drawing::image::from_file ( const xtd::ustring filename)
inlinestatic

#include <xtd.drawing/include/xtd/drawing/image.h>

Creates an image from the specified file.

Parameters
filenameA string that contains the name of the file from which to create the image.
Returns
The xtd::drawing::image this method creates.
Examples:
image_list.cpp.

◆ from_hbitmap()

static bitmap xtd::drawing::image::from_hbitmap ( intptr_t  hbitmap)
static

#include <xtd.drawing/include/xtd/drawing/image.h>

Creates a xtd::drawing::bitmap from a handle to a GDI bitmap.

Parameters
hbitmapThe GDI bitmap handle from which to create the xtd::drawing::bitmap.
Returns
The xtd::drawing::bitmap this method creates.
Remarks
The xtd::drawing::image::from_hbitmap method makes a copy of the GDI bitmap; so you can release the incoming GDI bitmap using the GDI DeleteObject method immediately after creating the new xtd::drawing::image.

◆ from_stream()

static image xtd::drawing::image::from_stream ( std::istream &  stream)
static

#include <xtd.drawing/include/xtd/drawing/image.h>

Creates an xtd::drawing::image from the specified data stream.

Parameters
streamA std::istream that contains the data for this xtd::drawing::image.
Returns
The xtd::drawing::image this method creates.
Remarks
You must keep the stream open for the lifetime of the xtd::drawing::image.
Note
The xtd::drawing::image class does not support alpha transparency in bitmaps. To enable alpha transparency, use PNG images with 32 bits per pixel.

◆ get_bounds()

xtd::drawing::rectangle_f xtd::drawing::image::get_bounds ( xtd::drawing::graphics_unit  page_unit) const

#include <xtd.drawing/include/xtd/drawing/image.h>

Gets the bounds of the image in the specified unit.

Parameters
page_unitOne of the xtd::drawing::graphics_unit values indicating the unit of measure for the bounding rectangle.
Returns
The xtd::drawing::rectangle_f that represents the bounds of the image, in the specified unit.

◆ get_encoder_parameter_list()

xtd::drawing::imaging::encoder_parameters xtd::drawing::image::get_encoder_parameter_list ( xtd::guid  encoder) const

#include <xtd.drawing/include/xtd/drawing/image.h>

Returns information about the parameters supported by the specified image encoder.

Parameters
guidA GUID that specifies the image encoder.
Returns
An xtd::drawing::imaging::encoder_parameters that contains an array of xtd::drawing::imaging::encoder_parameter objects. Each xtd::drawing::imaging::encoder_parameter contains information about one of the parameters supported by the specified image encoder.

◆ get_frame_count()

size_t xtd::drawing::image::get_frame_count ( const xtd::drawing::imaging::frame_dimension dimension) const

#include <xtd.drawing/include/xtd/drawing/image.h>

Returns the number of frames of the specified dimension.

Parameters
dimensionA xtd::drawing::imaging::frame_dimension that specifies the identity of the dimension type.
Returns
The number of frames in the specified dimension.
Remarks
This method returns information about multiple-frame images, which come in two styles: multiple page and multiple resolution.
A multiple-page image is an image that contains more than one image. Each page contains a single image (or frame). These pages (or images, or frames) are typically displayed in succession to produce an animated sequence, such as an animated .gif file.
A multiple-resolution image is an image that contains more than one copy of an image at different resolutions. This is commonly used by MIP mapping where the displayed image size determines the resolution of the image used for drawing. GDI+ can support an arbitrary number of pages (or images, or frames), as well as an arbitrary number of resolutions. The defined dimensions are properties of the xtd::drawing::imaging::frame_dimension.

◆ get_pixel_format_size()

static int32_t xtd::drawing::image::get_pixel_format_size ( xtd::drawing::imaging::pixel_format  pixfmt)
static

#include <xtd.drawing/include/xtd/drawing/image.h>

Returns the color depth, in number of bits per pixel, of the specified pixel format.

Parameters
pixfmtThe xtd::drawing::imaging::pixel_format member that specifies the format for which to find the size.
Returns
The color depth of the specified pixel format.

◆ get_property_item()

xtd::drawing::imaging::property_item xtd::drawing::image::get_property_item ( int32_t  propid)

#include <xtd.drawing/include/xtd/drawing/image.h>

Gets the specified property item from this xtd::drawing::image.

Parameters
propidThe ID of the property item to get.
Returns
The xtd::drawing::imaging::property_item this method gets.
Exceptions
xtd::argument_exceptionThe image format of this image does not support property items.
Remarks
For a list of property item IDs and links to more information, see Id.
It is difficult to set property items, because the xtd::drawing::imaging::property_item class has no public constructors. One way to work around this restriction is to obtain a xtd::drawing::imaging::property_item by retrieving the xtd::drawing::image::property_item property value or calling the xtd::drawing::image::get_property_item method of an xtd::drawing::image that already has property items. Then you can set the fields of the xtd::drawing::imaging::property_item and pass it to xtd::drawing::image::set_property_item.

◆ get_thmbnail_image()

xtd::drawing::image xtd::drawing::image::get_thmbnail_image ( int32_t  thumb_width,
int32_t  thunb_height 
)

#include <xtd.drawing/include/xtd/drawing/image.h>

Returns a thumbnail for this xtd::drawing::image.

Parameters
thbmb_widthThe width, in pixels, of the requested thumbnail image.
thum_heightThe height, in pixels, of the requested thumbnail image.
Returns
An xtd::drawing::image that represents the thumbnail.
Remarks
If the xtd::drawing::image contains an embedded thumbnail image, this method retrieves the embedded thumbnail and scales it to the requested size. If the xtd::drawing::image does not contain an embedded thumbnail image, this method creates a thumbnail image by scaling the main image.
The xtd::drawing::image::get_thumbnail_image method works well when the requested thumbnail image has a size of about 120 x 120 pixels. If you request a large thumbnail image (for example, 300 x 300) from an xtd::drawing::image that has an embedded thumbnail, there could be a noticeable loss of quality in the thumbnail image. It might be better to scale the main image (instead of scaling the embedded thumbnail) by calling the xtd::drawing::graphics::draw_image method.

◆ is_alpha_pixel_format()

static bool xtd::drawing::image::is_alpha_pixel_format ( xtd::drawing::imaging::pixel_format  pixfmt)
static

#include <xtd.drawing/include/xtd/drawing/image.h>

Returns a value that indicates whether the pixel format for this xtd::drawing::image contains alpha information.

Parameters
pixfmtThe PixelFormat to test.
Returns
true if pixfmt contains alpha information; otherwise, false.

◆ is_canonical_pixel_format()

static bool xtd::drawing::image::is_canonical_pixel_format ( xtd::drawing::imaging::pixel_format  pixfmt)
static

#include <xtd.drawing/include/xtd/drawing/image.h>

Returns a value that indicates whether the pixel format is 32 bits per pixel.

Parameters
pixfmtThe PixelFormat to test.
Returns
true if pixfmt is canonical; otherwise, false.

◆ is_extended_pixel_format()

static bool xtd::drawing::image::is_extended_pixel_format ( xtd::drawing::imaging::pixel_format  pixfmt)
static

#include <xtd.drawing/include/xtd/drawing/image.h>

Returns a value that indicates whether the pixel format is 64 bits per pixel.

Parameters
pixfmtThe PixelFormat to test.
Returns
true if pixfmt is extended; otherwise, false.

◆ rotate_flip()

void xtd::drawing::image::rotate_flip ( xtd::drawing::rotate_flip_type  rotate_flip_type)

#include <xtd.drawing/include/xtd/drawing/image.h>

Rotates, flips, or rotates and flips the xtd::drawing::image.

Parameters
rotate_flip_typeA xtd::drawing::rotate_flip_type member that specifies the type of rotation and flip to apply to the image.
Remarks
The xtd::drawing::image::rotate_flip method rotates the image clockwise.
If you wish to draw on an image once it has been rotated, you should always retrieve a new graphics object from the image, otherwise an exception could occur.

◆ save() [1/3]

void xtd::drawing::image::save ( const xtd::ustring filename) const

#include <xtd.drawing/include/xtd/drawing/image.h>

Saves this xtd::drawing::image to the specified file or stream.

Parameters
filenameA string that contains the name of the file to which to save this xtd::drawing::image.
Remarks
If no encoder exists for the file format of the image, the Portable Network Graphics (PNG) encoder is used. When you use the xtd::drawing::image::save method to save a graphic image as a Windows Metafile Format (WMF) or Enhanced Metafile Format (EMF) file, the resulting file is saved as a Portable Network Graphics (PNG) file. This behavior occurs because the GDI+ component of the .NET Framework does not have an encoder that you can use to save files as .wmf or .emf files.
Saving the image to the same file it was constructed from is not allowed and throws an exception.

◆ save() [2/3]

void xtd::drawing::image::save ( const xtd::ustring filename,
const xtd::drawing::imaging::image_format format 
) const

#include <xtd.drawing/include/xtd/drawing/image.h>

Saves this xtd::drawing::image to the specified file in the specified format.

Parameters
filenameA string that contains the name of the file to which to save this xtd::drawing::image.
formatThe xtd::drawing::imaging::image_format for this xtd::drawing::image.

◆ save() [3/3]

void xtd::drawing::image::save ( std::ostream &  stream,
const xtd::drawing::imaging::image_format format 
) const

#include <xtd.drawing/include/xtd/drawing/image.h>

Saves this image to the specified stream in the specified format.

Parameters
streamThe std::otream where the image will be saved.
formatThe xtd::drawing::imaging::image_format for this xtd::drawing::image.
Remarks
You should avoid saving an image to the same stream that was used to construct it. Doing so might damage the stream.
The image must be saved to the stream at an offset of zero. If any additional data has been written to the stream before saving the image, the image data in the stream will be corrupted.