wxBitmap(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

wxBitmap(3) β€” Erlang Module Definition πŸ¦‹

okay bestie, buckle up, we're diving into wxBitmap and it's giving platform-dependent bitmap energy. let's go πŸ’…

✨ NAME ✨

wxBitmap β€” this class encapsulates the concept of a platform-dependent bitmap, either monochrome or colour or colour with alpha channel support. iconic tbh.

πŸ’– DESCRIPTION πŸ’–

okay so if you need direct access to the bitmap data instead of, like, drawing to it using wxMemoryDC, you're gonna need the wxPixelData class β€” which, btw, is not implemented in wx β€” and specifically either wxNativePixelData for RGB bitmaps or wxAlphaPixelData for bitmaps that also have an alpha channel. periodt.

heads up: a lot of wxBitmap functions take a type parameter, and that type is a value from the ?wxBitmapType enumeration. but bestie, whether those values actually work depends on the platform your program is running on and on how wxWidgets was configured. if literally all possible wxWidgets settings are in play, here's the tea:

  • wxMSW supports BMP and ICO files, BMP and ICO resources;
  • wxGTK supports any file supported by gdk-pixbuf;
  • wxMac supports PICT resources;
  • wxX11 supports XPM files, XPM data, XBM data;

plus, wxBitmap can load and save every format that wxImage can β€” go check wxImage for more deets. but obvi you have to have loaded the wxImage handlers first (see ?wxInitAllImageHandlers() and wxImage::AddHandler β€” which is not implemented in wx). also important: all the available wxBitmapHandlers for a given wxWidgets port get automatically loaded at startup, so you won't need to use wxBitmap::AddHandler (also not implemented in wx). no cap.

more on the wxImage vs wxBitmap drama: wxImage is just a buffer of RGB bytes with an optional buffer for the alpha bytes. it's 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 (on the other hand), wxBitmap is meant to be a wrapper around whatever the native image format is β€” the one that's quickest/easiest to draw to a DC or to be the target of the drawing operations performed on a wxMemoryDC. by splitting the responsibilities between wxImage/wxBitmap like this, it becomes 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. slay.

predefined objects (include wx.hrl): ?wxNullBitmap πŸ’–

see also, bestie:

  • Overview bitmap
  • Overview bitmap
  • wxDC:blit/6
  • wxIcon
  • wxCursor
  • wxMemoryDC
  • wxImage

wxWidgets docs: wxBitmap

🌈 DATA TYPES 🌈

wxBitmap() :: wx:wx_object().

✨ FUNCTIONS ✨

okay bestie, this is where the wxBitmap glow-up actually happens. every function, every overload, every little when clause. no skipping, no skimming, we are eating this whole plate. πŸ’…


convertToImage(This) -> wxImage:wxImage() when This :: wxBitmap().

Creates an image from a platform-dependent bitmap.

This preserves mask information so that bitmaps and images can be converted back and forth without loss in that respect. πŸ¦‹


copyFromIcon(This, Icon) -> boolean() when This :: wxBitmap(), Icon :: wxIcon:wxIcon().

Creates the bitmap from an icon. iconic behavior, honestly. πŸ‘‘


create β€” overload o'clock ⏰

create(This, Width, Height) -> boolean()
                when
                    This :: wxBitmap(),
                    Width :: integer(),
                    Height :: integer();
            (This, Sz, [Option]) -> boolean()
                when
                    This :: wxBitmap(),
                    Sz :: {W :: integer(), H :: integer()},
                    Option :: {depth, integer()}.

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


create(This, Width, Height, [Option]) -> boolean()
                when
                    This :: wxBitmap(),
                    Width :: integer(),
                    Height :: integer(),
                    Option :: {depth, integer()};
            (This, Width, Height, Dc) -> boolean()
                when
                    This :: wxBitmap(),
                    Width :: integer(),
                    Height :: integer(),
                    Dc :: wxDC:wxDC().

Create a bitmap compatible with the given DC, inheriting its magnification factor.

Return: true if the creation was successful.

Since: 3.1.0


destroy(This :: wxBitmap()) -> ok.

Destroys the object. bye bestie, thanks for the memories. πŸ’€


getDepth(This) -> integer() when This :: wxBitmap().

Gets the colour depth of the bitmap.

A value of 1 indicates a monochrome bitmap.


getHeight(This) -> integer() when This :: wxBitmap().

Gets the height of the bitmap in pixels.

See: getWidth/1


getMask(This) -> wxMask:wxMask() when This :: wxBitmap().

Gets the associated mask (if any) which may have been loaded from a file or set for the bitmap.

See:

  • setMask/2
  • wxMask

getPalette(This) -> wxPalette:wxPalette() when This :: wxBitmap().

Gets the associated palette (if any) which may have been loaded from a file or set for the bitmap.

See: wxPalette


getSubBitmap(This, Rect) -> wxBitmap()

getSubBitmap(This, Rect) -> wxBitmap()
                             when
                                 This :: wxBitmap(),
                                 Rect ::
                                     {X :: integer(),
                                      Y :: integer(),
                                      W :: integer(),
                                      H :: integer()}.

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

This function preserves bit depth and mask information.


getWidth(This) -> integer() when This :: wxBitmap().

Gets the width of the bitmap in pixels.

See: getHeight/1


isOk(This) -> boolean() when This :: wxBitmap().

Returns true if bitmap data is present.


loadFile(This, Name, [Option]) -> boolean()

loadFile(This, Name, [Option]) -> boolean()
                         when
                             This :: wxBitmap(),
                             Name :: unicode:chardata(),
                             Option :: {type, wx:wx_enum()}.

Loads a bitmap from a file or resource.

Return: true if the operation succeeded, false otherwise.

Remark: A palette may be associated with the bitmap if one exists (especially for colour Windows bitmaps), and if the code supports it. You can check if one has been created by using the getPalette/1 member.

See: saveFile/4


new() β€” the default baby constructor 🍼

new() -> wxBitmap().

Default constructor.

Constructs a bitmap object with no data; an assignment or another member function such as create/4 or loadFile/3 must be called subsequently.


new(Name) and friends β€” overloaded constructor realness ✨

new(Name) -> wxBitmap() when Name :: unicode:chardata();
                (Sz) -> wxBitmap() when Sz :: {W :: integer(), H :: integer()};
                (Img) -> wxBitmap()
                    when Img :: wxImage:wxImage() | wxBitmap:wxBitmap().

new(Width, Height) -> wxBitmap()
                    when Width :: integer(), Height :: integer();
                (Name, [Option]) -> wxBitmap()
                    when
                        Name :: unicode:chardata(),
                        Option :: {type, wx:wx_enum()};
                (Sz, [Option]) -> wxBitmap()
                    when
                        Sz :: {W :: integer(), H :: integer()},
                        Option :: {depth, integer()};
                (Img, [Option]) -> wxBitmap()
                    when Img :: wxImage:wxImage(), Option :: {depth,
       integer()}.

Creates this bitmap object from the given image.

This has to be done to actually display an image as you cannot draw an image directly on a window.

The resulting bitmap will use the provided colour depth (or that of the current system if depth is ?wxBITMAP_SCREEN_DEPTH) which entails that a colour reduction may take place.

On Windows, if there is a palette present (set with SetPalette), it will be used when creating the wxBitmap (most useful in 8-bit display mode). On other platforms, the palette is currently ignored.


new(Bits, Width, Height) and its bestie overload πŸŽ€

new(Bits, Width, Height) -> wxBitmap()
                    when
                        Bits :: binary(),
                        Width :: integer(),
                        Height :: integer();
                (Width, Height, [Option]) -> wxBitmap()
                    when
                        Width :: integer(),
                        Height :: integer(),
                        Option :: {depth, integer()}.

Creates a new bitmap.

A depth of ?wxBITMAP_SCREEN_DEPTH indicates the depth of the current screen or visual.

Some platforms only support 1 for monochrome and ?wxBITMAP_SCREEN_DEPTH for the current colour setting.

A depth of 32 including an alpha channel is supported under MSW, Mac and GTK+.


new(Bits, Width, Height, [Option]) β€” bits from static data πŸ’Ύ

new(Bits, Width, Height, [Option]) -> wxBitmap()
                    when
                        Bits :: binary(),
                        Width :: integer(),
                        Height :: integer(),
                        Option :: {depth, integer()}.

Creates a bitmap from the given array bits.

You should only use this function for monochrome bitmaps (depth 1) in portable programs: in this case the bits parameter should contain an XBM image.

For other bit depths, the behaviour is platform dependent: under Windows, the data is passed without any changes to the underlying CreateBitmap() API. Under other platforms, only monochrome bitmaps may be created using this constructor and wxImage should be used for creating colour bitmaps from static data.


ok(This) -> boolean() when This :: wxBitmap().

Equivalent to: isOk/1


saveFile(This, Name, Type, [Option]) -> boolean()

saveFile(This, Name, Type, [Option]) -> boolean()
                         when
                             This :: wxBitmap(),
                             Name :: unicode:chardata(),
                             Type :: wx:wx_enum(),
                             Option :: {palette, wxPalette:wxPalette()}.

Saves a bitmap in the named file.

Return: true if the operation succeeded, false otherwise.

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

See: loadFile/3


setDepth(This, Depth) -> ok

setDepth(This, Depth) -> ok
                         when This :: wxBitmap(), Depth :: integer().
Deprecated: This function is deprecated since version 3.1.2, dimensions and depth can only be set at construction time.

Sets the depth member (does not affect the bitmap data).


setHeight(This, Height) -> ok

setHeight(This, Height) -> ok
                          when This :: wxBitmap(), Height :: integer().
Deprecated: This function is deprecated since version 3.1.2, dimensions and depth can only be set at construction time.

Sets the height member (does not affect the bitmap data).


setMask(This, Mask) -> ok

setMask(This, Mask) -> ok
                        when This :: wxBitmap(), Mask :: wxMask:wxMask().

Sets the mask for this bitmap.

Remark: The bitmap object owns the mask once this has been called.

Note: A mask can be set also for bitmap with an alpha channel but doing so under wxMSW is not recommended because performance of drawing such bitmap is not very good.

See:

  • getMask/1
  • wxMask

setPalette(This, Palette) -> ok

setPalette(This, Palette) -> ok
                           when
                               This :: wxBitmap(),
                               Palette :: wxPalette:wxPalette().

Sets the associated palette.

(Not implemented under GTK+).

See: wxPalette


setWidth(This, Width) -> ok

setWidth(This, Width) -> ok
                         when This :: wxBitmap(), Width :: integer().
Deprecated: This function is deprecated since version 3.1.2, dimensions and depth can only be set at construction time.

Sets the width member (does not affect the bitmap data).


and that's the whole page, bestie. source/version says Ericsson AB, wx 2.6, and the manpage is wxBitmap(3). no date on this footer, so we're not gonna invent one. slay. πŸ’–βœ¨

πŸ“¦ where this page comes from