back to gui 

wxImage

generated from ../src/mod_gui/misc/image.cpp

This class encapsulates a platform-independent image. An image can be loaded from a file in a variety of formats.

Constants

Class Properties

Name Type Description
handlers read only Array Array of wxImageHandler elements. Get the available list of image handlers.

Class Methods

addHandler

addHandler(Handler)
 
Name Type Default Description
Handler wxImageHandler

Adds a handler to the end of the static list of format handlers. There is usually only one instance of a given handler class in an application session. See handlers and wxInitAllImageHandlers

canRead

canRead(Name) : Boolean
 
Name Type Default Description
Name String A filename.

Returns true when the file can be read.

cleanUpHandlers

cleanUpHandlers()
 

Removes all handlers. Is called automatically by wxWindows.

findHandler

findHandler(Name) : wxImageHandler
 
Name Type Default Description
Name String
findHandler(Extension, 
            Type) : wxImageHandler
 
Name Type Default Description
Extension String
Type Integer
findHandler(Type) : wxImageHandler
 
Name Type Default Description
Type Integer

Searches a handler

findHandlerMime

findHandlerMime(Type) : wxImageHandler
 
Name Type Default Description
Type String A mime type.

Finds the handler associated with the given MIME type.

insertHandler

insertHandler(Handler)
 
Name Type Default Description
Handler wxImageHandler

Adds a handler at the start of the static list of format handlers. There is usually only one instance of a given handler class in an application session. See handlers

removeHandler

removeHandler(Name) : Boolean
 
Name Type Default Description
Name String The name of the handler.

Remove the given handler.

Constructor

wxImage

wxImage()
 
wxImage(Width, 
        Height)
 
Name Type Default Description
Width Integer The width of the image.
Height Integer The height of the image.
wxImage(size)
 
Name Type Default Description
size wxSize The size of the image.
wxImage(Name, 
        Type = wxBitmapType.ANY)
 
Name Type Default Description
Name String The name of a file from which to load the image.
Type Integer wxBitmapType.ANY The type of the image.
wxImage(Name, 
        MimeType)
 
Name Type Default Description
Name String The name of a file from which to load the image.
MimeType String The MIME type of the image.
wxImage(Buffer, 
        Type = wxBitmapType.ANY)
 
Name Type Default Description
Buffer Buffer
Type Integer wxBitmapType.ANY The type of the image.

Properties

Name Type Description
height read only Integer Gets the height of the image in pixels.
mask Boolean Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour.
maskBlue read only Integer Returns the blue value of the mask colour.
maskGreen read only Integer Returns the green value of the mask colour.
maskRed read only Integer Returns the red value of the mask colour.
ok read only Boolean Returns true when the image data is available.
width read only Integer Returns the width of the image in pixels.

Methods

convertToMono

convertToMono(R, 
              G, 
              B) : wxImage
 
Name Type Default Description
R Integer
G Integer
B Integer
convertToMono(Colour) : wxImage
 
Name Type Default Description
Colour wxColour

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

copy

copy() : wxImage
 

Returns an identical copy of image.

create

create(Width, 
       Height)
 
Name Type Default Description
Width Integer The width of the image.
Height Integer The height of the image.
create(Size)
 
Name Type Default Description
Size wxSize The size of the image.

Creates a fresh image with the given size.

destroy

destroy()
 

Destroys the image data.

findFirstUnusedColour

findFirstUnusedColour(StartColour) : Boolean
 
Name Type Default Description
StartColour wxColour The start colour.

Finds the first colour that is never used in the image. The search begins at given start 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. This method returns an array with 1 or 4 elements: the first element is a boolean indicating success. When this is true, 3 elements follow with the r, g, b values of the colour.

getBlue

getBlue(X, 
        Y) : Integer
 
Name Type Default Description
X Integer The x position
Y Integer The y position

Returns the blue intensity at the given coordinate.

getColour

getColour(X, 
          Y) : wxColour
 
Name Type Default Description
X Integer The x position
Y Integer The y position

Returns the colour of the given coordinate.

getGreen

getGreen(X, 
         Y) : Integer
 
Name Type Default Description
X Integer The x position
Y Integer The y position

Returns the green intensity at the given coordinate.

getOption

getOption(Name) : String
 
Name Type Default Description
Name String The name of the option.

Gets a user-defined option. The function is case-insensitive to name. See setOption, getOptionInt, hasOption

getOptionInt

getOptionInt(Name) : Integer
 
Name Type Default Description
Name String The name of the option.

Gets a user-defined option. The function is case-insensitive to name. See setOption, getOptionString, hasOption

getRed

getRed(X, 
       Y) : Integer
 
Name Type Default Description
X Integer The x position
Y Integer The y position

Returns the red intensity at the given coordinate.

getSubImage

getSubImage(Rect) : wxImage
 
Name Type Default Description
Rect wxRect

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

hasOption

hasOption(Name) : Boolean
 
Name Type Default Description
Name String The name of the option.

Returns true if the given option is present. The function is case-insensitive to name. See setOption, getOptionInt, hasOption

loadFile

loadFile(Name, 
         Type = wxBitmapType.ANY) : Boolean
 
Name Type Default Description
Name String The name of a file
Type Integer wxBitmapType.ANY The type of the image.
loadFile(Name, 
         MimeType = wxBitmapType.ANY) : Boolean
 
Name Type Default Description
Name String The name of a file
MimeType String wxBitmapType.ANY The MIME type of the image.

Loads an image from a file.

mirror

mirror(Horizontally = Y) : wxImage
 
Name Type Default Description
Horizontally Boolean Y The orientation.

Returns a mirrored copy of the image. The parameter horizontally indicates the orientation.

paste

paste(Image, 
      X, 
      Y)
 
Name Type Default Description
Image wxImage The image to paste.
X Integer The x position.
Y Integer The y position.

Pastes image into this instance and takes care of the mask colour and out of bounds problems.

replace

replace(R1, 
        G1, 
        B1, 
        R2, 
        G2, 
        B2)
 
Name Type Default Description
R1 Integer
G1 Integer
B1 Integer
R2 Integer
G2 Integer
B2 Integer
replace(Colour1, 
        Colour2)
 
Name Type Default Description
Colour1 wxColour
Colour2 wxColour

Replaces the colour with another colour.

rescale

rescale(Width, 
        Height) : wxImage
 
Name Type Default Description
Width Integer The width of the new image.
Height Integer The height of the new image.
rescale(Size) : wxImage
 
Name Type Default Description
Size wxSize The size of the new image.

Changes the size of the image in-place: after a call to this function, the image will have the given width and height. Returns the (modified) image itself.

rotate

rotate(Angle, 
       Center, 
       InterPol = true, 
       Offset = null) : wxImage
 
Name Type Default Description
Angle Double The rotation angle.
Center wxPoint The height of the new image.
InterPol Boolean true Interpolates the new image.
Offset wxPoint null

Rotates the image about the given point, by angle radians. Passing true for 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 will be used. Returns the rotated image, leaving this image intact.

rotate90

rotate90(ClockWise = true) : wxImage
 
Name Type Default Description
ClockWise Boolean true The direction of the rotation. Default is true.

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

saveFile

saveFile(Name, 
         Type = wxBitmapType.ANY) : Boolean
 
Name Type Default Description
Name String The name of a file
Type Integer wxBitmapType.ANY The type of the image.
saveFile(Name, 
         MimeType = wxBitmapType.ANY) : Boolean
 
Name Type Default Description
Name String The name of a file
MimeType String wxBitmapType.ANY The MIME type of the image.

Saves an image to a file.

scale

scale(Width, 
      Height) : wxImage
 
Name Type Default Description
Width Integer The width of the new image.
Height Integer The height of the new image.
scale(Size) : wxImage
 
Name Type Default Description
Size wxSize The size of the new image.

Returns a scaled version of the image with size Width * Height.

setMaskColour

setMaskColour(R, 
              G, 
              B)
 
Name Type Default Description
R Integer
G Integer
B Integer
setMaskColour(Colour)
 
Name Type Default Description
Colour wxColour

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

setMaskFromImage

setMaskFromImage(Image, 
                 R, 
                 G, 
                 B) : Boolean
 
Name Type Default Description
Image wxImage The mask image to extract mask shape from. Must have same dimensions as the image.
R Integer
G Integer
B Integer
setMaskFromImage(Image, 
                 Colour) : Boolean
 
Name Type Default Description
Image wxImage The mask image to extract mask shape from. Must have same dimensions as the image.
Colour wxColour

Sets image's mask so that the pixels that have RGB value of r,g,b (or colour) 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 whose corresponding pixel in mask has given RGB value. 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.

setOption

setOption(Name, 
          Value)
 
Name Type Default Description
Name String Name of the option
Value String Value of the option
setOption(Name, 
          Value)
 
Name Type Default Description
Name String Name of the option
Value Integer Value of the option

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). See getOption, getOptionInt, hasOption.

setRGB

setRGB(X, 
       Y, 
       R, 
       G, 
       B)
 
Name Type Default Description
X Integer The x position
Y Integer The y position
R Integer
G Integer
B Integer
setRGB(X, 
       Y, 
       Colour)
 
Name Type Default Description
X Integer The x position
Y Integer The y position
Colour wxColour

Sets the colour of the pixel at the given coordinate. This routine performs bounds-checks for the coordinate so it can be considered a safe way to manipulate the data, but in some cases this might be too slow.




Design downloaded from Zeroweb.org: Free website templates, layouts, and tools.