Class: Wx::Image

Inherits:
Object show all
Defined in:
lib/wx/doc/gen/image.rb,
lib/wx/doc/image.rb

Overview

This class encapsulates a platform-independent image.

An image can be created from data, or using Bitmap#convert_to_image. An image can be loaded from a file in a variety of formats, and is extensible to new formats via image format handlers. Functions are available to set and get image bits, so it can be used for basic image manipulation. A Image cannot (currently) be drawn directly to a DC. Instead, a platform-specific Bitmap object must be created from it using the Bitmap#initialize(wxImage,depth) constructor. This bitmap can then be drawn in a device context, using DC#draw_bitmap. More on the difference between Image and Bitmap: Image is just a buffer of RGB bytes with an optional buffer for the alpha bytes. It is all generic, platform independent and image file format independent code. It includes generic code for scaling, resizing, clipping, and other manipulations of the image data. OTOH, Bitmap is intended to be a wrapper of whatever is the native image format that is quickest/easiest to draw to a DC or to be the target of the drawing operations performed on a MemoryDC. By splitting the responsibilities between Image/Bitmap like this then it’s easier to use generic code shared by all platforms and image types for generic operations and platform specific code where performance or compatibility is needed. One colour value of the image may be used as a mask colour which will lead to the automatic creation of a Mask object associated to the bitmap object.

Alpha channel support

Starting from wxWidgets 2.5.0 Image supports alpha channel data, that is in addition to a byte for the red, green and blue colour components for each pixel it also stores a byte representing the pixel opacity. An alpha value of 0 corresponds to a transparent pixel (null opacity) while a value of 255 means that the pixel is 100% opaque. The constants IMAGE_ALPHA_TRANSPARENT and IMAGE_ALPHA_OPAQUE can be used to indicate those values in a more readable form. While all images have RGB data, not all images have an alpha channel. Before using #get_alpha you should check if this image contains an alpha channel with #has_alpha. Currently the BMP, PNG, TGA, and TIFF format handlers have full alpha channel support for loading so if you want to use alpha you have to use one of these formats. If you initialize the image alpha channel yourself using #set_alpha, you should save it in either PNG, TGA, or TIFF format to avoid losing it as these are the only handlers that currently support saving with alpha.

Available image handlers

The following image handlers are available. BMPHandler is always installed by default. In wxRuby all image handlers are loaded by default at startup by init_all_image_handlers.

  • BMPHandler: For loading (including alpha support) and saving, always installed.

  • PNGHandler: For loading and saving. Includes alpha support.

  • JPEGHandler: For loading and saving.

  • GIFHandler: For loading and saving (see below).

  • PCXHandler: For loading and saving (see below).

  • PNMHandler: For loading and saving (see below).

  • TIFFHandler: For loading and saving. Includes alpha support.

  • TGAHandler: For loading and saving. Includes alpha support.

  • IFFHandler: For loading only.

  • XPMHandler: For loading and saving.

  • ICOHandler: For loading and saving.

  • CURHandler: For loading and saving.

  • ANIHandler: For loading only.

When saving in PCX format, PCXHandler will count the number of different colours in the image; if there are 256 or less colours, it will save as 8 bit, else it will save as 24 bit. Loading PNMs only works for ASCII or raw RGB images. When saving in PNM format, PNMHandler will always save as raw RGB. Saving GIFs requires images of maximum 8 bpp (see Quantize), and the alpha channel converted to a mask (see #convert_alpha_to_mask). Saving an animated GIF requires images of the same size (see Wx::GIFHandler::SaveAnimation)

Category: Graphics Device Interface (GDI) Predefined objects/pointers: NULL_IMAGE

See Also:

  • Bitmap
  • init_all_image_handlers
  • PixelData

Requires:

  • USE_IMAGE

Defined Under Namespace

Modules: Histogram Classes: HSVValue, RGBValue

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#clone, #dup, #is_same_as, #un_share

Constructor Details

#initializeWx::Image #initialize(width, height, clear = true) ⇒ Wx::Image #initialize(sz, clear = true) ⇒ Wx::Image #initialize(width, height, data) ⇒ Wx::Image #initialize(sz, data) ⇒ Wx::Image #initialize(width, height, data, alpha) ⇒ Wx::Image #initialize(sz, data, alpha) ⇒ Wx::Image #initialize(name, type = Wx::BitmapType::BITMAP_TYPE_ANY, index = -1) ⇒ Wx::Image #initialize(name, mimetype, index = -1) ⇒ Wx::Image

Returns a new instance of Image.

Overloads:

  • #initializeWx::Image

    Creates an empty Wx::Image object without an alpha channel.

  • #initialize(width, height, clear = true) ⇒ Wx::Image

    Creates an image with the given size and clears it if requested.

    Does not create an alpha channel.

    Parameters:

    • width (Integer)

      Specifies the width of the image.

    • height (Integer)

      Specifies the height of the image.

    • clear (Boolean) (defaults to: true)

      If true, initialize the image to black.

  • #initialize(sz, clear = true) ⇒ Wx::Image

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • sz (Array(Integer, Integer), Wx::Size)
    • clear (Boolean) (defaults to: true)
  • #initialize(width, height, data) ⇒ Wx::Image

    Creates an image from data in memory.

    If static_data is false then the Wx::Image will take ownership of the data and free it afterwards. For this, it has to be allocated with malloc.

    Parameters:

    • width (Integer)

      Specifies the width of the image.

    • height (Integer)

      Specifies the height of the image.

    • data (String)

      A pointer to RGB data

  • #initialize(sz, data) ⇒ Wx::Image

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • sz (Array(Integer, Integer), Wx::Size)
    • data (String)
  • #initialize(width, height, data, alpha) ⇒ Wx::Image

    Creates an image from data in memory.

    If static_data is false then the Wx::Image will take ownership of the data and free it afterwards. For this, it has to be allocated with malloc.

    Parameters:

    • width (Integer)

      Specifies the width of the image.

    • height (Integer)

      Specifies the height of the image.

    • data (String)

      A pointer to RGB data

    • alpha (String)

      A pointer to alpha-channel data

  • #initialize(sz, data, alpha) ⇒ Wx::Image

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • sz (Array(Integer, Integer), Wx::Size)
    • data (String)
    • alpha (String)
  • #initialize(name, type = Wx::BitmapType::BITMAP_TYPE_ANY, index = -1) ⇒ Wx::Image

    Creates an image from a file.

    Remark:

    Depending on how wxWidgets has been configured and by which handlers have been loaded, not all formats may be available. Any handler other than BMP must be previously initialized with add_handler or init_all_image_handlers.

    Note:

    You can use #get_option_int to get the hotspot when loading cursor files: ```ruby hotspot_x = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_X) hotspot_y = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_Y) ```

    Parameters:

    See Also:

  • #initialize(name, mimetype, index = -1) ⇒ Wx::Image

    Creates an image from a file using MIME-types to specify the type.

    Parameters:

    • name (String)

      Name of the file from which to load the image.

    • mimetype (String)

      MIME type string (for example ‘image/jpeg’)

    • index (Integer) (defaults to: -1)

      See description in wxImage(const wxString&, wxBitmapType, int) overload.



1268
# File 'lib/wx/doc/gen/image.rb', line 1268

def initialize(*args) end

Class Method Details

.self.can_read(filename) ⇒ Boolean .self.can_read(stream) ⇒ Boolean

Overloads:

  • .self.can_read(filename) ⇒ Boolean

    Returns true if at least one of the available image handlers can read the file with the given name.

    See Wx::ImageHandler::CanRead for more info.

    Parameters:

    • filename (String)

    Returns:

    • (Boolean)
  • .self.can_read(stream) ⇒ Boolean

    Returns true if at least one of the available image handlers can read the data in the given stream.

    See Wx::ImageHandler::CanRead for more info.

    Parameters:

    Returns:

    • (Boolean)


1289
# File 'lib/wx/doc/gen/image.rb', line 1289

def self.can_read(*args) end

.extensionsArray<String>

Returns an array with the supported file extensions (as ‘bmp’) of the available image handlers.

Returns:

  • (Array<String>)


18
# File 'lib/wx/doc/image.rb', line 18

def self.extensions; end

.get_default_load_flagsInteger

Returns the currently used default file load flags.

See set_default_load_flags for more information about these flags.

Returns:

  • (Integer)


1295
# File 'lib/wx/doc/gen/image.rb', line 1295

def self.get_default_load_flags; end

.get_image_count(filename, type = Wx::BitmapType::BITMAP_TYPE_ANY) ⇒ Integer

If the image file contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images.

For the overload taking the parameter filename, that’s the name of the file to query. For the overload taking the parameter stream, that’s the opened input stream with image data. See Wx::ImageHandler#get_image_count for more info. The parameter type may be one of the following values:

Number of available images. For most image handlers, this is 1 (exceptions are TIFF and ICO formats as well as animated GIFs for which this function returns the number of frames in the animation).

Parameters:

  • filename (String)
  • type (Wx::BitmapType) (defaults to: Wx::BitmapType::BITMAP_TYPE_ANY)

Returns:

  • (Integer)


1166
# File 'lib/wx/doc/gen/image.rb', line 1166

def self.get_image_count(filename, type=Wx::BitmapType::BITMAP_TYPE_ANY) end

.get_image_ext_wildcardString

Iterates all registered Wx::ImageHandler objects, and returns a string containing file extension masks suitable for passing to file open/save dialog boxes.

The format of the returned string is "(.ext1;.ext2)|.ext1;.ext2". It is usually a good idea to prepend a description before passing the result to the dialog. Example:

Wx::FileDialog(self, 'Choose Image', Dir.getwd, '',
                 'Image Files ' + Wx::Image.get_image_ext_wildcard,
                 Wx::FD_OPEN) do |file_dlg|
    # ...
  end

Returns:

  • (String)

See Also:

  • Wx::ImageHandler


1309
# File 'lib/wx/doc/gen/image.rb', line 1309

def self.get_image_ext_wildcard; end

.handler_extensionsHash

returns a Hash with all supported extensions per available BitmapType

Returns:

  • (Hash)


26
# File 'lib/wx/doc/image.rb', line 26

def self.handler_extensions; end

.handlersArray<Wx::BitmapType>

Returns an array of BitmapTypes identifying the available image handlers.

Returns:



14
# File 'lib/wx/doc/image.rb', line 14

def self.handlers; end

.hsv_to_rgb(arg) ⇒ Object

Converts a color in HSV colour space to RGB colour space.

Parameters:



56
# File 'lib/wx/doc/image.rb', line 56

def self.hsv_to_rgb(arg) end

.mime_typesArray<String>

Returns an array with the supported mime types of the available image handlers.

Returns:

  • (Array<String>)


22
# File 'lib/wx/doc/image.rb', line 22

def self.mime_types; end

.rgb_to_hsv(arg) ⇒ Object

Converts a color in RGB colour space to HSV colour space.

Parameters:



60
# File 'lib/wx/doc/image.rb', line 60

def self.rgb_to_hsv(arg) end

.set_default_load_flags(flags) ⇒ void

This method returns an undefined value.

Sets the default value for the flags used for loading image files.

This method changes the global value of the flags used for all the subsequently created Wx::Image objects by default. It doesn’t affect the already existing objects. By default, the global flags include Load_Verbose flag value.

Parameters:

  • flags (Integer)

See Also:



1128
# File 'lib/wx/doc/gen/image.rb', line 1128

def self.set_default_load_flags(flags) end

Instance Method Details

#blur(blurRadius) ⇒ Wx::Image

Blurs the image in both horizontal and vertical directions by the specified pixel blurRadius.

This should not be used when using a single mask colour for transparency.

Parameters:

  • blurRadius (Integer)

Returns:

See Also:



365
# File 'lib/wx/doc/gen/image.rb', line 365

def blur(blurRadius) end

#blur_horizontal(blurRadius) ⇒ Wx::Image

Blurs the image in the horizontal direction only.

This should not be used when using a single mask colour for transparency.

Parameters:

  • blurRadius (Integer)

Returns:

See Also:



374
# File 'lib/wx/doc/gen/image.rb', line 374

def blur_horizontal(blurRadius) end

#blur_vertical(blurRadius) ⇒ Wx::Image

Blurs the image in the vertical direction only.

This should not be used when using a single mask colour for transparency.

Parameters:

  • blurRadius (Integer)

Returns:

See Also:



383
# File 'lib/wx/doc/gen/image.rb', line 383

def blur_vertical(blurRadius) end

#change_brightness(factor) ⇒ void

This method returns an undefined value.

Changes the brightness (value) of each pixel in the image.

factor is a double in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent.

Parameters:

  • factor (Float)


474
# File 'lib/wx/doc/gen/image.rb', line 474

def change_brightness(factor) end

#change_hsv(angleH, factorS, factorV) ⇒ void

This method returns an undefined value.

Changes the hue, the saturation and the brightness (value) of each pixel in the image.

angleH is a double in the range [-1.0..+1.0], where -1.0 corresponds to -360 degrees and +1.0 corresponds to +360 degrees, factorS is a double in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent and factorV is a double in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent.

Parameters:

  • angleH (Float)
  • factorS (Float)
  • factorV (Float)


483
# File 'lib/wx/doc/gen/image.rb', line 483

def change_hsv(angleH, factorS, factorV) end

#change_lightness(alpha) ⇒ Wx::Image

Returns a changed version of the image based on the given lightness.

This utility function simply darkens or lightens a color, based on the specified percentage ialpha. ialpha of 0 would make the color completely black, 200 completely white and 100 would not change the color.

Remark:

This function calls Colour#change_lightness for each pixel in the image.

Parameters:

  • alpha (Integer)

Returns:



610
# File 'lib/wx/doc/gen/image.rb', line 610

def change_lightness(alpha) end

#change_saturation(factor) ⇒ void

This method returns an undefined value.

Changes the saturation of each pixel in the image.

factor is a double in the range [-1.0..+1.0], where -1.0 corresponds to -100 percent and +1.0 corresponds to +100 percent.

Parameters:

  • factor (Float)


467
# File 'lib/wx/doc/gen/image.rb', line 467

def change_saturation(factor) end

#clear(value = 0) ⇒ void

This method returns an undefined value.

Initialize the image data with zeroes (the default) or with the byte value given as value.

Parameters:

  • value (Integer) (defaults to: 0)


346
# File 'lib/wx/doc/gen/image.rb', line 346

def clear(value=0) end

#clear_alphavoid

This method returns an undefined value.

Removes the alpha channel from the image.

This function should only be called if the image has alpha channel data, use #has_alpha to check for this.



1004
# File 'lib/wx/doc/gen/image.rb', line 1004

def clear_alpha; end

#compute_histogramHash

Computes the histogram of the image and fills a hash table, indexed with integer keys built as 0xRRGGBB, containing pairs (Array) of integer values. For each pair the first value is the index of the first pixel in the colour in the image and the second value the number of pixels having the colour in the image. The returned Hash object is extended with the Histogram mixin.

Returns:

  • (Hash)

    hash object extended with Histogram



52
# File 'lib/wx/doc/image.rb', line 52

def compute_histogram; end

#convert_alpha_to_mask(threshold = Wx::IMAGE_ALPHA_THRESHOLD) ⇒ Boolean #convert_alpha_to_mask(mr, mg, mb, threshold = Wx::IMAGE_ALPHA_THRESHOLD) ⇒ Boolean

Overloads:

  • #convert_alpha_to_mask(threshold = Wx::IMAGE_ALPHA_THRESHOLD) ⇒ Boolean

    If the image has alpha channel, this method converts it to mask.

    If the image has an alpha channel, all pixels with alpha value less than threshold are replaced with the mask colour and the alpha channel is removed. Otherwise nothing is done. The mask colour is chosen automatically using #find_first_unused_colour, see the overload below if this is not appropriate. Returns true on success, false on error.

    Parameters:

    • threshold (Integer) (defaults to: Wx::IMAGE_ALPHA_THRESHOLD)

    Returns:

    • (Boolean)
  • #convert_alpha_to_mask(mr, mg, mb, threshold = Wx::IMAGE_ALPHA_THRESHOLD) ⇒ Boolean

    If the image has alpha channel, this method converts it to mask using the specified colour as the mask colour.

    If the image has an alpha channel, all pixels with alpha value less than threshold are replaced with the mask colour and the alpha channel is removed. Otherwise nothing is done.

    Returns true on success, false on error.

    Parameters:

    • mr (Integer)

      The red component of the mask colour.

    • mg (Integer)

      The green component of the mask colour.

    • mb (Integer)

      The blue component of the mask colour.

    • threshold (Integer) (defaults to: Wx::IMAGE_ALPHA_THRESHOLD)

      Pixels with alpha channel values below the given threshold are considered to be transparent, i.e. the corresponding mask pixels are set. Pixels with the alpha values above the threshold are considered to be opaque.

    Returns:

    • (Boolean)


552
# File 'lib/wx/doc/gen/image.rb', line 552

def convert_alpha_to_mask(*args) end

#convert_to_disabled(brightness = 255) ⇒ Wx::Image

Returns disabled (dimmed) version of the image.

Remark:

This function calls Colour#make_disabled for each pixel in the image.

Parameters:

  • brightness (Integer) (defaults to: 255)

Returns:



597
# File 'lib/wx/doc/gen/image.rb', line 597

def convert_to_disabled(brightness=255) end

#convert_to_greyscale(weight_r, weight_g, weight_b) ⇒ Wx::Image #convert_to_greyscaleWx::Image

Overloads:

  • #convert_to_greyscale(weight_r, weight_g, weight_b) ⇒ Wx::Image

    Returns a greyscale version of the image.

    The returned image uses the luminance component of the original to calculate the greyscale. Defaults to using the standard ITU-T BT.601 when converting to YUV, where every pixel equals (R * weight_r) + (G * weight_g) + (B * weight_b).

    Remark:

    This function calls Colour.make_grey for each pixel in the image.

    Parameters:

    • weight_r (Float)
    • weight_g (Float)
    • weight_b (Float)

    Returns:

  • #convert_to_greyscaleWx::Image

    Returns a greyscale version of the image.

    Returns:



571
# File 'lib/wx/doc/gen/image.rb', line 571

def convert_to_greyscale(*args) end

#convert_to_mono(r, g, b) ⇒ Wx::Image

Returns monochromatic version of the image.

The returned image has white colour where the original has (r,g,b) colour and black colour everywhere else.

Remark:

This function calls Colour.make_mono for each pixel in the image.

Parameters:

  • r (Integer)
  • g (Integer)
  • b (Integer)

Returns:



586
# File 'lib/wx/doc/gen/image.rb', line 586

def convert_to_mono(r, g, b) end

#copyWx::Image

Returns an identical copy of this image.

Returns:



295
# File 'lib/wx/doc/gen/image.rb', line 295

def copy; end

#create(width, height, clear = true) ⇒ Boolean #create(sz, clear = true) ⇒ Boolean #create(width, height, data) ⇒ Boolean #create(sz, data) ⇒ Boolean #create(width, height, data, alpha) ⇒ Boolean #create(sz, data, alpha) ⇒ Boolean

Overloads:

  • #create(width, height, clear = true) ⇒ Boolean

    Creates a fresh image.

    See #initialize(int,int,bool) for more info. true if the call succeeded, false otherwise.

    Parameters:

    • width (Integer)
    • height (Integer)
    • clear (Boolean) (defaults to: true)

    Returns:

    • (Boolean)
  • #create(sz, clear = true) ⇒ Boolean

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • sz (Array(Integer, Integer), Wx::Size)
    • clear (Boolean) (defaults to: true)

    Returns:

    • (Boolean)
  • #create(width, height, data) ⇒ Boolean

    Creates a fresh image.

    See wxImage::wxImage(int,int,unsigned char*,bool) for more info. true if the call succeeded, false otherwise.

    Parameters:

    • width (Integer)
    • height (Integer)
    • data (String)

    Returns:

    • (Boolean)
  • #create(sz, data) ⇒ Boolean

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • sz (Array(Integer, Integer), Wx::Size)
    • data (String)

    Returns:

    • (Boolean)
  • #create(width, height, data, alpha) ⇒ Boolean

    Creates a fresh image.

    See wxImage::wxImage(int,int,unsigned char,unsigned char,bool) for more info. true if the call succeeded, false otherwise.

    Parameters:

    • width (Integer)
    • height (Integer)
    • data (String)
    • alpha (String)

    Returns:

    • (Boolean)
  • #create(sz, data, alpha) ⇒ Boolean

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • sz (Array(Integer, Integer), Wx::Size)
    • data (String)
    • alpha (String)

    Returns:

    • (Boolean)


341
# File 'lib/wx/doc/gen/image.rb', line 341

def create(*args) end

#destroyvoid

This method returns an undefined value.

Destroys the image data.



350
# File 'lib/wx/doc/gen/image.rb', line 350

def destroy; end

#find_first_unused_colour(startR = 1, startG = 0, startB = 0) ⇒ Array(Boolean,Integer,Integer,Integer)

Finds the first colour that is never used in the image.

The search begins at given initial colour and continues by increasing R, G and B components (in this order) by 1 until an unused colour is found or the colour space exhausted. The parameters r, g, b are pointers to variables to save the colour. The parameters startR, startG, startB define the initial values of the colour. The returned colour will have RGB values equal to or greater than these. Returns false if there is no unused colour left, true on success.

Note:

This method involves computing the histogram, which is a computationally intensive operation.

Parameters:

  • startR (Integer) (defaults to: 1)
  • startG (Integer) (defaults to: 0)
  • startB (Integer) (defaults to: 0)

Returns:

  • (Array(Boolean,Integer,Integer,Integer))


628
# File 'lib/wx/doc/gen/image.rb', line 628

def find_first_unused_colour(startR=1, startG=0, startB=0) end

#get_blue(x, y) ⇒ Integer Also known as: blue

Returns the blue intensity at the given coordinate.

Parameters:

  • x (Integer)
  • y (Integer)

Returns:

  • (Integer)


648
# File 'lib/wx/doc/gen/image.rb', line 648

def get_blue(x, y) end

#get_green(x, y) ⇒ Integer Also known as: green

Returns the green intensity at the given coordinate.

Parameters:

  • x (Integer)
  • y (Integer)

Returns:

  • (Integer)


641
# File 'lib/wx/doc/gen/image.rb', line 641

def get_green(x, y) end

#get_heightInteger Also known as: height

Gets the height of the image in pixels.

Returns:

  • (Integer)

See Also:



681
# File 'lib/wx/doc/gen/image.rb', line 681

def get_height; end

#get_load_flagsInteger Also known as: load_flags

Returns the file load flags used for this object.

See #set_load_flags for more information about these flags.

Returns:

  • (Integer)


1274
# File 'lib/wx/doc/gen/image.rb', line 1274

def get_load_flags; end

#get_mask_blueInteger Also known as: mask_blue

Gets the blue value of the mask colour.

Returns:

  • (Integer)


663
# File 'lib/wx/doc/gen/image.rb', line 663

def get_mask_blue; end

#get_mask_greenInteger Also known as: mask_green

Gets the green value of the mask colour.

Returns:

  • (Integer)


658
# File 'lib/wx/doc/gen/image.rb', line 658

def get_mask_green; end

#get_mask_redInteger Also known as: mask_red

Gets the red value of the mask colour.

Returns:

  • (Integer)


653
# File 'lib/wx/doc/gen/image.rb', line 653

def get_mask_red; end

#get_option(name) ⇒ String Also known as: option

Gets a user-defined string-valued option.

Generic options:

Options specific to GIFHandler:

  • Wx::IMAGE_OPTION_GIF_COMMENT: The comment text that is read from or written to the GIF file. In an animated GIF each frame can have its own comment. If there is only a comment in the first frame of a GIF it will not be repeated in other frames.

The value of the option or an empty string if not found. Use #has_option if an empty string can be a valid option value.

Parameters:

  • name (String)

    The name of the option, case-insensitive.

Returns:

  • (String)

See Also:



708
# File 'lib/wx/doc/gen/image.rb', line 708

def get_option(name) end

#get_option_int(name) ⇒ Integer Also known as: option_int

Gets a user-defined integer-valued option.

The function is case-insensitive to name. If the given option is not present, the function returns 0. Use #has_option if 0 is a possibly valid value for the option. Generic options:

  • Wx::IMAGE_OPTION_MAX_WIDTH and Wx::IMAGE_OPTION_MAX_HEIGHT: If either of these options is specified, the loaded image will be scaled down (preserving its aspect ratio) so that its width is less than the max width given if it is not 0 and its height is less than the max height given if it is not 0. This is typically used for loading thumbnails and the advantage of using these options compared to calling #rescale after loading is that some handlers (only JPEG one right now) support rescaling the image during loading which is vastly more efficient than loading the entire huge image and rescaling it later (if these options are not supported by the handler, this is still what happens however). These options must be set before calling #load_file to have any effect.

  • Wx::IMAGE_OPTION_ORIGINAL_WIDTH and Wx::IMAGE_OPTION_ORIGINAL_HEIGHT: These options will return the original size of the image if either Wx::IMAGE_OPTION_MAX_WIDTH or Wx::IMAGE_OPTION_MAX_HEIGHT is specified.

  • Wx::IMAGE_OPTION_QUALITY: JPEG quality used when saving. This is an integer in 0..100 range with 0 meaning very poor and 100 excellent (but very badly compressed). This option is currently ignored for the other formats.

  • Wx::IMAGE_OPTION_RESOLUTIONUNIT: The value of this option determines whether the resolution of the image is specified in centimetres or inches, see Wx::ImageResolution enum elements.

  • Wx::IMAGE_OPTION_RESOLUTION, Wx::IMAGE_OPTION_RESOLUTIONX and Wx::IMAGE_OPTION_RESOLUTIONY: These options define the resolution of the image in the units corresponding to Wx::IMAGE_OPTION_RESOLUTIONUNIT options value. The first option can be set before saving the image to set both horizontal and vertical resolution to the same value. The X and Y options are set by the image handlers if they support the image resolution (currently BMP, JPEG and TIFF handlers do) and the image provides the resolution information and can be queried after loading the image.

Options specific to PNGHandler:

Options specific to TIFFHandler:

  • Wx::IMAGE_OPTION_TIFF_BITSPERSAMPLE: Number of bits per sample (channel). Currently values of 1 and 8 are supported. A value of 1 results in a black and white image. A value of 8 (the default) can mean greyscale or RGB, depending on the value of Wx::IMAGE_OPTION_TIFF_SAMPLESPERPIXEL.

  • Wx::IMAGE_OPTION_TIFF_SAMPLESPERPIXEL: Number of samples (channels) per pixel. Currently values of 1 and 3 are supported. A value of 1 results in either a greyscale (by default) or black and white image, depending on the value of Wx::IMAGE_OPTION_TIFF_BITSPERSAMPLE. A value of 3 (the default) will result in an RGB image.

  • Wx::IMAGE_OPTION_TIFF_COMPRESSION: Compression type. By default it is set to 1 (COMPRESSION_NONE). Typical other values are 5 (COMPRESSION_LZW) and 7 (COMPRESSION_JPEG). See tiff.h for more options.

  • Wx::IMAGE_OPTION_TIFF_PHOTOMETRIC: Specifies the photometric interpretation. By default it is set to 2 (PHOTOMETRIC_RGB) for RGB images and 0 (PHOTOMETRIC_MINISWHITE) for greyscale or black and white images. It can also be set to 1 (PHOTOMETRIC_MINISBLACK) to treat the lowest value as black and highest as white. If you want a greyscale image it is also sufficient to only specify Wx::IMAGE_OPTION_TIFF_PHOTOMETRIC and set it to either PHOTOMETRIC_MINISWHITE or PHOTOMETRIC_MINISBLACK. The other values are taken care of.

Options specific to GIFHandler:

  • Wx::IMAGE_OPTION_GIF_TRANSPARENCY: How to deal with transparent pixels. By default, the color of transparent pixels is changed to bright pink, so that if the image is accidentally drawn without transparency, it will be obvious. Normally, this would not be noticed, as these pixels will not be rendered. But in some cases it might be useful to load a GIF without making any modifications to its colours. Use Wx::IMAGE_OPTION_GIF_TRANSPARENCY_UNCHANGED to keep the colors correct. Use Wx::IMAGE_OPTION_GIF_TRANSPARENCY_HIGHLIGHT to convert transparent pixels to pink (default). This option has been added in wxWidgets 3.1.1.

Note:

Be careful when combining the options Wx::IMAGE_OPTION_TIFF_SAMPLESPERPIXEL, Wx::IMAGE_OPTION_TIFF_BITSPERSAMPLE, and Wx::IMAGE_OPTION_TIFF_PHOTOMETRIC. While some measures are taken to prevent illegal combinations and/or values, it is still easy to abuse them and come up with invalid results in the form of either corrupted images or crashes.

The value of the option or 0 if not found. Use #has_option if 0 can be a valid option value.

Parameters:

  • name (String)

    The name of the option, case-insensitive.

Returns:

  • (Integer)

See Also:



767
# File 'lib/wx/doc/gen/image.rb', line 767

def get_option_int(name) end

#get_or_find_mask_colourArray(Boolean,Integer,Integer,Integer) Also known as: or_find_mask_colour

Get the current mask colour or find a suitable unused colour that could be used as a mask colour.

Returns true if the image currently has a mask.

Returns:

  • (Array(Boolean,Integer,Integer,Integer))


774
# File 'lib/wx/doc/gen/image.rb', line 774

def get_or_find_mask_colour; end

#get_paletteWx::Palette Also known as: palette

Returns the palette associated with the image.

Currently the palette is only used when converting to Bitmap under Windows. Some of the Wx::Image handlers have been modified to set the palette if one exists in the image file (usually 256 or less colour images in GIF or PNG format).

Returns:



782
# File 'lib/wx/doc/gen/image.rb', line 782

def get_palette; end

#get_red(x, y) ⇒ Integer Also known as: red

Returns the red intensity at the given coordinate.

Parameters:

  • x (Integer)
  • y (Integer)

Returns:

  • (Integer)


634
# File 'lib/wx/doc/gen/image.rb', line 634

def get_red(x, y) end

#get_sizeWx::Size

Returns the size of the image in pixels.

Returns:

See Also:



690
# File 'lib/wx/doc/gen/image.rb', line 690

def get_size; end

#get_sub_image(rect) ⇒ Wx::Image Also known as: sub_image

Returns a sub image of the current one as long as the rect belongs entirely to the image.

Parameters:

Returns:



788
# File 'lib/wx/doc/gen/image.rb', line 788

def get_sub_image(rect) end

#get_typeWx::BitmapType Also known as: type

Gets the type of image found by #load_file or specified with #save_file.

Returns:



793
# File 'lib/wx/doc/gen/image.rb', line 793

def get_type; end

#get_widthInteger Also known as: width

Gets the width of the image in pixels.

Returns:

  • (Integer)

See Also:



672
# File 'lib/wx/doc/gen/image.rb', line 672

def get_width; end

#has_alphaBoolean Also known as: has_alpha?

Returns true if this image has alpha channel, false otherwise.

Returns:

  • (Boolean)

See Also:



802
# File 'lib/wx/doc/gen/image.rb', line 802

def has_alpha; end

#has_maskBoolean Also known as: has_mask?

Returns true if there is a mask active, false otherwise.

Returns:

  • (Boolean)


807
# File 'lib/wx/doc/gen/image.rb', line 807

def has_mask; end

#has_option(name) ⇒ Boolean Also known as: has_option?

Returns true if the given option is present.

The function is case-insensitive to name. The lists of the currently supported options are in #get_option and #get_option_int function docs.

Parameters:

  • name (String)

Returns:

  • (Boolean)

See Also:



819
# File 'lib/wx/doc/gen/image.rb', line 819

def has_option(name) end

#init_alphavoid

This method returns an undefined value.

Initializes the image alpha channel data.

It is an error to call it if the image already has alpha data. If it doesn’t, alpha data will be by default initialized to all pixels being fully opaque. But if the image has a mask colour, all mask pixels will be completely transparent.



356
# File 'lib/wx/doc/gen/image.rb', line 356

def init_alpha; end

#is_okBoolean Also known as: ok?

Returns true if image data is present.

Returns:

  • (Boolean)


824
# File 'lib/wx/doc/gen/image.rb', line 824

def is_ok; end

#is_transparent(x, y, threshold = Wx::IMAGE_ALPHA_THRESHOLD) ⇒ Boolean Also known as: transparent?

Returns true if the given pixel is transparent, i.e. either has the mask colour if this image has a mask or if this image has alpha channel and alpha value of this pixel is strictly less than threshold.

Parameters:

  • x (Integer)
  • y (Integer)
  • threshold (Integer) (defaults to: Wx::IMAGE_ALPHA_THRESHOLD)

Returns:

  • (Boolean)


832
# File 'lib/wx/doc/gen/image.rb', line 832

def is_transparent(x, y, threshold=Wx::IMAGE_ALPHA_THRESHOLD) end

#load_file(name, type = Wx::BitmapType::BITMAP_TYPE_ANY, index = -1) ⇒ Boolean #load_file(name, mimetype, index = -1) ⇒ Boolean

Overloads:

  • #load_file(name, type = Wx::BitmapType::BITMAP_TYPE_ANY, index = -1) ⇒ Boolean

    Loads an image from a file.

    If no handler type is provided, the library will try to autodetect the format.

    Parameters:

    • name (String)

      Name of the file from which to load the image.

    • type (Wx::BitmapType) (defaults to: Wx::BitmapType::BITMAP_TYPE_ANY)

      See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.

    • index (Integer) (defaults to: -1)

      See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.

    Returns:

    • (Boolean)
  • #load_file(name, mimetype, index = -1) ⇒ Boolean

    Loads an image from a file.

    If no handler type is provided, the library will try to autodetect the format.

    Parameters:

    • name (String)

      Name of the file from which to load the image.

    • mimetype (String)

      MIME type string (for example ‘image/jpeg’)

    • index (Integer) (defaults to: -1)

      See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.

    Returns:

    • (Boolean)


913
# File 'lib/wx/doc/gen/image.rb', line 913

def load_file(*args) end

#load_stream(stream, type = Wx::BitmapType::BITMAP_TYPE_ANY, index = -1) ⇒ Boolean #load_stream(stream, mimetype, index = -1) ⇒ Boolean

Overloads:

  • #load_stream(stream, type = Wx::BitmapType::BITMAP_TYPE_ANY, index = -1) ⇒ Boolean

    Loads an image from an input stream.

    If the file can’t be loaded, this function returns false and logs an error using Wx.log_error. If the file can be loaded but some problems were detected while doing it, it can also call Wx.log_warning to notify about these problems. If this is undesirable, use #set_load_flags to reset Load_Verbose flag and suppress these warnings.

    true if the operation succeeded, false otherwise. If the optional index parameter is out of range, false is returned and a call to Wx.log_error takes place.

    Remark:

    Depending on how wxWidgets has been configured, not all formats may be available.

    Note:

    You can use #get_option_int to get the hotspot when loading cursor files: ```ruby hotspot_x = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_X) hotspot_y = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_Y) ```

    Parameters:

    Returns:

    • (Boolean)

    See Also:

  • #load_stream(stream, mimetype, index = -1) ⇒ Boolean

    Loads an image from an input stream.

    Parameters:

    • stream (IO, Wx::InputStream)

      Opened input stream from which to load the image. Currently, the stream must support seeking.

    • mimetype (String)

      MIME type string (for example ‘image/jpeg’)

    • index (Integer) (defaults to: -1)

      See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.

    Returns:

    • (Boolean)


895
# File 'lib/wx/doc/gen/image.rb', line 895

def load_stream(*args) end

#mirror(horizontally = true) ⇒ Wx::Image

Returns a mirrored copy of the image.

The parameter horizontally indicates the orientation.

Parameters:

  • horizontally (Boolean) (defaults to: true)

Returns:



390
# File 'lib/wx/doc/gen/image.rb', line 390

def mirror(horizontally=true) end

#paste(image, x, y, alphaBlend = Wx::ImageAlphaBlendMode::IMAGE_ALPHA_BLEND_OVER) ⇒ void

This method returns an undefined value.

Copy the data of the given image to the specified position in this image.

Takes care of the mask colour and out of bounds problems.

Parameters:

  • image (Wx::Image)

    The image containing the data to copy, must be valid.

  • x (Integer)

    The horizontal position of the position to copy the data to.

  • y (Integer)

    The vertical position of the position to copy the data to.

  • alphaBlend (Wx::ImageAlphaBlendMode) (defaults to: Wx::ImageAlphaBlendMode::IMAGE_ALPHA_BLEND_OVER)

    This parameter (new in wx 3.1.5) determines whether the alpha values of the original image replace (default) or are composed with the alpha channel of this image. Notice that alpha blending overrides the mask handling.



400
# File 'lib/wx/doc/gen/image.rb', line 400

def paste(image, x, y, alphaBlend=Wx::ImageAlphaBlendMode::IMAGE_ALPHA_BLEND_OVER) end

#replace(r1, g1, b1, r2, g2, b2) ⇒ void

This method returns an undefined value.

Replaces the colour specified by r1,g1,b1 by the colour r2,g2,b2.

Parameters:

  • r1 (Integer)
  • g1 (Integer)
  • b1 (Integer)
  • r2 (Integer)
  • g2 (Integer)
  • b2 (Integer)


410
# File 'lib/wx/doc/gen/image.rb', line 410

def replace(r1, g1, b1, r2, g2, b2) end

#rescale(width, height, quality = Wx::ImageResizeQuality::IMAGE_QUALITY_NORMAL) ⇒ Wx::Image

Changes the size of the image in-place by scaling it: after a call to this function,the image will have the given width and height.

For a description of the quality parameter, see the #scale function. Returns the (modified) image itself.

Parameters:

  • width (Integer)
  • height (Integer)
  • quality (Wx::ImageResizeQuality) (defaults to: Wx::ImageResizeQuality::IMAGE_QUALITY_NORMAL)

Returns:

See Also:



420
# File 'lib/wx/doc/gen/image.rb', line 420

def rescale(width, height, quality=Wx::ImageResizeQuality::IMAGE_QUALITY_NORMAL) end

#resize(size, pos, red = -1,, green = -1,, blue = -1)) ⇒ Wx::Image

Changes the size of the image in-place without scaling it by adding either a border with the given colour or cropping as necessary.

The image is pasted into a new image with the given size and background colour at the position pos relative to the upper left of the new image. If red = green = blue = -1 then use either the current mask colour if set or find, use, and set a suitable mask colour for any newly exposed areas. The (modified) image itself.

Parameters:

  • size (Array(Integer, Integer), Wx::Size)
  • pos (Array(Integer, Integer), Wx::Point)
  • red (Integer) (defaults to: -1,)
  • green (Integer) (defaults to: -1,)
  • blue (Integer) (defaults to: -1))

Returns:

See Also:



434
# File 'lib/wx/doc/gen/image.rb', line 434

def resize(size, pos, red=-1, green=-1, blue=-1) end

#rotate(angle, rotationCentre, interpolating = true, offsetAfterRotation = nil) ⇒ Wx::Image

Rotates the image about the given point, by angle radians.

Passing true to interpolating results in better image quality, but is slower. If the image has a mask, then the mask colour is used for the uncovered pixels in the rotated image background. Else, black (rgb 0, 0, 0) will be used. Returns the rotated image, leaving this image intact.

Parameters:

  • angle (Float)
  • rotationCentre (Array(Integer, Integer), Wx::Point)
  • interpolating (Boolean) (defaults to: true)
  • offsetAfterRotation (Wx::Point) (defaults to: nil)

Returns:



446
# File 'lib/wx/doc/gen/image.rb', line 446

def rotate(angle, rotationCentre, interpolating=true, offsetAfterRotation=nil) end

#rotate180Wx::Image

Returns a copy of the image rotated by 180 degrees.

Returns:



455
# File 'lib/wx/doc/gen/image.rb', line 455

def rotate180; end

#rotate90(clockwise = true) ⇒ Wx::Image

Returns a copy of the image rotated 90 degrees in the direction indicated by clockwise.

Parameters:

  • clockwise (Boolean) (defaults to: true)

Returns:



451
# File 'lib/wx/doc/gen/image.rb', line 451

def rotate90(clockwise=true) end

#rotate_hue(angle) ⇒ void

This method returns an undefined value.

Rotates the hue of each pixel in the image by angle, which is a double in the range [-1.0..+1.0], where -1.0 corresponds to -360 degrees and +1.0 corresponds to +360 degrees.

Parameters:

  • angle (Float)


460
# File 'lib/wx/doc/gen/image.rb', line 460

def rotate_hue(angle) end

#save_file(name, type) ⇒ Boolean #save_file(name, mimetype) ⇒ Boolean #save_file(name) ⇒ Boolean

Overloads:

  • #save_file(name, type) ⇒ Boolean

    Saves an image in the named file.

    Parameters:

    Returns:

    • (Boolean)
  • #save_file(name, mimetype) ⇒ Boolean

    Saves an image in the named file.

    Parameters:

    • name (String)

      Name of the file to save the image to.

    • mimetype (String)

      MIME type.

    Returns:

    • (Boolean)
  • #save_file(name) ⇒ Boolean

    Saves an image in the named file.

    File type is determined from the extension of the file name. Note that this function may fail if the extension is not recognized! You can use one of the forms above to save images to files with non-standard extensions.

    Parameters:

    • name (String)

      Name of the file to save the image to.

    Returns:

    • (Boolean)


981
# File 'lib/wx/doc/gen/image.rb', line 981

def save_file(*args) end

#scale(width, height, quality = Wx::ImageResizeQuality::IMAGE_QUALITY_NORMAL) ⇒ Wx::Image

Returns a scaled version of the image.

This is also useful for scaling bitmaps in general as the only other way to scale bitmaps is to blit a MemoryDC into another MemoryDC. The parameter quality determines what method to use for resampling the image, see Wx::ImageResizeQuality documentation. It should be noted that although using Wx::ImageResizeQuality::IMAGE_QUALITY_HIGH produces much nicer looking results it is a slower method. Downsampling will use the box averaging method which seems to operate very fast. If you are upsampling larger images using this method you will most likely notice that it is a bit slower and in extreme cases it will be quite substantially slower as the bicubic algorithm has to process a lot of data. It should also be noted that the high quality scaling may not work as expected when using a single mask colour for transparency, as the scaling will blur the image and will therefore remove the mask partially. Using the alpha channel will work. Example:

# get the bitmap from somewhere
  bmp = ...
  
  # rescale it to have size of 32*32
  if bmp.width != 32 || bmp.height != 32
     image = bmp.convert_to_image
     bmp = Wx::Bitmap.new(image.scale(32, 32))
  
     # another possibility:
     image.rescale(32, 32)
     bmp = image.to_bitmap
  end
Note:

The algorithm used for the default (normal) quality value doesn't work with images larger than 65536 (2^16) pixels in either dimension for 32-bit programs. For 64-bit programs the limit is 2^48 and so not relevant in practice.

Parameters:

  • width (Integer)
  • height (Integer)
  • quality (Wx::ImageResizeQuality) (defaults to: Wx::ImageResizeQuality::IMAGE_QUALITY_NORMAL)

Returns:

See Also:



517
# File 'lib/wx/doc/gen/image.rb', line 517

def scale(width, height, quality=Wx::ImageResizeQuality::IMAGE_QUALITY_NORMAL) end

#set_alpha(x, y, alpha) ⇒ void

This method returns an undefined value.

Sets the alpha value for the given pixel.

This function should only be called if the image has alpha channel data, use #has_alpha to check for this.

Parameters:

  • x (Integer)
  • y (Integer)
  • alpha (Integer)


998
# File 'lib/wx/doc/gen/image.rb', line 998

def set_alpha(x, y, alpha) end

#set_alpha_data(alpha = nil) ⇒ void

This method returns an undefined value.

This function is similar to set_data and has similar restrictions.

The pointer passed to it may however be NULL in which case the function will allocate the alpha array internally this is useful to add alpha channel data to an image which doesn’t have any. If the pointer is not NULL, it must have one byte for each image pixel and be allocated with malloc(). Wx::Image takes ownership of the pointer and will free it unless static_data parameter is set to true in this case the caller should do it.

Parameters:

  • alpha (String) (defaults to: nil)


989
# File 'lib/wx/doc/gen/image.rb', line 989

def set_alpha_data(alpha=nil) end

#set_load_flags(flags) ⇒ void Also known as: load_flags=

This method returns an undefined value.

Sets the flags used for loading image files by this object.

The flags will affect any future calls to #load_file for this object. To change the flags for all image objects, call set_default_load_flags before creating any of them. Currently the only defined flag is Load_Verbose which determines if the non-fatal (i.e. not preventing the file from being loaded completely) problems should result in the calls to Wx.log_warning function. It is recommended to customize handling of these warnings by e.g. defining a custom log target (see Logging Overview), but if such warnings should be completely suppressed, clearing this flag provides a simple way to do it, for example:

image = Wx::Image.new
  image.set_load_flags(image.get_load_flags & ~Wx::Image::Load_Verbose)
  image.load_file(...)

Parameters:

  • flags (Integer)

See Also:



1027
# File 'lib/wx/doc/gen/image.rb', line 1027

def set_load_flags(flags) end

#set_mask(hasMask = true) ⇒ void Also known as: mask=

This method returns an undefined value.

Specifies whether there is a mask or not.

The area of the mask is determined by the current mask colour.

Parameters:

  • hasMask (Boolean) (defaults to: true)


1035
# File 'lib/wx/doc/gen/image.rb', line 1035

def set_mask(hasMask=true) end

#set_mask_colour(red, green, blue) ⇒ void

This method returns an undefined value.

Sets the mask colour for this image (and tells the image to use the mask).

Parameters:

  • red (Integer)
  • green (Integer)
  • blue (Integer)


1043
# File 'lib/wx/doc/gen/image.rb', line 1043

def set_mask_colour(red, green, blue) end

#set_mask_from_image(mask, mr, mg, mb) ⇒ Boolean

Sets image’s mask so that the pixels that have RGB value of mr,mg,mb in mask will be masked in the image.

This is done by first finding an unused colour in the image, setting this colour as the mask colour and then using this colour to draw all pixels in the image who corresponding pixel in mask has given RGB value. The parameter mask is the mask image to extract mask shape from. It must have the same dimensions as the image. The parameters mr, mg, mb are the RGB values of the pixels in mask that will be used to create the mask. Returns false if mask does not have same dimensions as the image or if there is no unused colour left. Returns true if the mask was successfully applied.

Note:

Note that this method involves computing the histogram, which is a computationally intensive operation.

Parameters:

  • mask (Wx::Image)
  • mr (Integer)
  • mg (Integer)
  • mb (Integer)

Returns:

  • (Boolean)


1062
# File 'lib/wx/doc/gen/image.rb', line 1062

def set_mask_from_image(mask, mr, mg, mb) end

#set_option(name, value) ⇒ void #set_option(name, value) ⇒ void

Overloads:

  • #set_option(name, value) ⇒ void

    This method returns an undefined value.

    Sets a user-defined option.

    The function is case-insensitive to name. For example, when saving as a JPEG file, the option quality is used, which is a number between 0 and 100 (0 is terrible, 100 is very good). The lists of the currently supported options are in #get_option and #get_option_int function docs.

    Parameters:

    • name (String)
    • value (String)

    See Also:

  • #set_option(name, value) ⇒ void

    This method returns an undefined value.

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

    Parameters:

    • name (String)
    • value (Integer)


1081
# File 'lib/wx/doc/gen/image.rb', line 1081

def set_option(*args) end

#set_palette(palette) ⇒ void Also known as: palette=

This method returns an undefined value.

Associates a palette with the image.

The palette may be used when converting Wx::Image to Bitmap (MSW only at present) or in file save operations (none as yet).

Parameters:



1088
# File 'lib/wx/doc/gen/image.rb', line 1088

def set_palette(palette) end

#set_rgb(x, y, r, g, b) ⇒ void #set_rgb(rect, red, green, blue) ⇒ void

Overloads:

  • #set_rgb(x, y, r, g, b) ⇒ void

    This method returns an undefined value.

    Set the color of the pixel at the given x and y coordinate.

    Parameters:

    • x (Integer)
    • y (Integer)
    • r (Integer)
    • g (Integer)
    • b (Integer)
  • #set_rgb(rect, red, green, blue) ⇒ void

    This method returns an undefined value.

    Sets the colour of the pixels within the given rectangle.

    This routine performs bounds-checks for the coordinate so it can be considered a safe way to manipulate the data.

    Parameters:

    • rect (Wx::Rect)
    • red (Integer)
    • green (Integer)
    • blue (Integer)


1108
# File 'lib/wx/doc/gen/image.rb', line 1108

def set_rgb(*args) end

#set_rgb_data_with_size(data, new_width, new_height) ⇒ void

This method returns an undefined value.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:

  • data (String)
  • new_width (Integer)
  • new_height (Integer)


1011
# File 'lib/wx/doc/gen/image.rb', line 1011

def set_rgb_data_with_size(data, new_width, new_height) end

#set_type(type) ⇒ void Also known as: type=

This method returns an undefined value.

Set the type of image returned by #get_type.

This method is mostly used internally by the library but can also be called from the user code if the image was created from data in the given bitmap format without using #load_file (which would set the type correctly automatically). Notice that the image must be created before this function is called.

Parameters:



1116
# File 'lib/wx/doc/gen/image.rb', line 1116

def set_type(type) end

#size(size, pos, red = -1,, green = -1,, blue = -1)) ⇒ Wx::Image

Returns a resized version of this image without scaling it by adding either a border with the given colour or cropping as necessary.

The image is pasted into a new image with the given size and background colour at the position pos relative to the upper left of the new image. If red = green = blue = -1 then the areas of the larger image not covered by this image are made transparent by filling them with the image mask colour (which will be allocated automatically if it isn’t currently set). Otherwise, the areas will be filled with the colour with the specified RGB components.

Parameters:

  • size (Array(Integer, Integer), Wx::Size)
  • pos (Array(Integer, Integer), Wx::Point)
  • red (Integer) (defaults to: -1,)
  • green (Integer) (defaults to: -1,)
  • blue (Integer) (defaults to: -1))

Returns:

See Also:



531
# File 'lib/wx/doc/gen/image.rb', line 531

def size(size, pos, red=-1, green=-1, blue=-1) end

#write(stream, mimetype) ⇒ Boolean #write(stream, type) ⇒ Boolean

Overloads:

  • #write(stream, mimetype) ⇒ Boolean

    Saves an image in the given stream.

    true if the operation succeeded, false otherwise.

    Remark:

    Depending on how wxWidgets has been configured, not all formats may be available.

    Note:

    You can use #set_option to set the hotspot when saving an image into a cursor file (default hotspot is in the centre of the image): ```ruby image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_X, hotspot_x) image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_Y, hotspot_y) ```

    Parameters:

    • stream (IO, Wx::OutputStream)

      Opened output stream to save the image to.

    • mimetype (String)

      MIME type.

    Returns:

    • (Boolean)

    See Also:

  • #write(stream, type) ⇒ Boolean

    Saves an image in the given stream.

    Parameters:

    Returns:

    • (Boolean)


945
# File 'lib/wx/doc/gen/image.rb', line 945

def write(*args) end