| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.Gdk.Objects.Texture
Description
A GdkTexture represents image data that can be displayed on screen.
There are various ways to create GdkTexture objects from a Pixbuf
or a cairo surface, or other pixel data.
An important aspect of GdkTextures is that they are immutable - once the image data has been wrapped in a GdkTexture, it may be uploaded to the GPU or used in other ways that make it impractical to allow modification.
Synopsis
- newtype Texture = Texture (ManagedPtr Texture)
- class (GObject o, IsDescendantOf Texture o) => IsTexture o
- toTexture :: (MonadIO m, IsTexture o) => o -> m Texture
- noTexture :: Maybe Texture
- textureDownload :: (HasCallStack, MonadIO m, IsTexture a) => a -> Ptr Word8 -> Word64 -> m ()
- textureGetHeight :: (HasCallStack, MonadIO m, IsTexture a) => a -> m Int32
- textureGetWidth :: (HasCallStack, MonadIO m, IsTexture a) => a -> m Int32
- textureNewForPixbuf :: (HasCallStack, MonadIO m, IsPixbuf a) => a -> m Texture
- textureNewFromFile :: (HasCallStack, MonadIO m, IsFile a) => a -> m Texture
- textureNewFromResource :: (HasCallStack, MonadIO m) => Text -> m Texture
- textureSaveToPng :: (HasCallStack, MonadIO m, IsTexture a) => a -> Text -> m Bool
- constructTextureHeight :: IsTexture o => Int32 -> IO (GValueConstruct o)
- getTextureHeight :: (MonadIO m, IsTexture o) => o -> m Int32
- constructTextureWidth :: IsTexture o => Int32 -> IO (GValueConstruct o)
- getTextureWidth :: (MonadIO m, IsTexture o) => o -> m Int32
Exported types
Memory-managed wrapper type.
Constructors
| Texture (ManagedPtr Texture) |
Instances
| Eq Texture Source # | |
| GObject Texture Source # | |
Defined in GI.Gdk.Objects.Texture Methods gobjectType :: IO GType # | |
| IsGValue Texture Source # | Convert |
| HasParentTypes Texture Source # | |
Defined in GI.Gdk.Objects.Texture | |
| type ParentTypes Texture Source # | |
Defined in GI.Gdk.Objects.Texture | |
class (GObject o, IsDescendantOf Texture o) => IsTexture o Source #
Instances
| (GObject o, IsDescendantOf Texture o) => IsTexture o Source # | |
Defined in GI.Gdk.Objects.Texture | |
Methods
Overloaded methods
download
Arguments
| :: (HasCallStack, MonadIO m, IsTexture a) | |
| => a |
|
| -> Ptr Word8 |
|
| -> Word64 |
|
| -> m () |
Downloads the texture into local memory. This may be
an expensive operation, as the actual texture data may
reside on a GPU or on a remote display server.
The data format of the downloaded data is equivalent to
FormatArgb32, so every downloaded pixel requires
4 bytes of memory.
Downloading a texture into a Cairo image surface:
C code
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
gdk_texture_get_width (texture),
gdk_texture_get_height (texture));
gdk_texture_download (texture,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_stride (surface));
cairo_surface_mark_dirty (surface);getHeight
Arguments
| :: (HasCallStack, MonadIO m, IsTexture a) | |
| => a |
|
| -> m Int32 | Returns: the height of the |
Returns the height of the texture.
getWidth
Arguments
| :: (HasCallStack, MonadIO m, IsTexture a) | |
| => a |
|
| -> m Int32 | Returns: the width of the |
Returns the width of texture.
newForPixbuf
Arguments
| :: (HasCallStack, MonadIO m, IsPixbuf a) | |
| => a |
|
| -> m Texture | Returns: a new |
Creates a new texture object representing the GdkPixbuf.
newFromFile
Arguments
| :: (HasCallStack, MonadIO m, IsFile a) | |
| => a |
|
| -> m Texture | Returns: A newly-created |
Creates a new texture by loading an image from a file. The file format is
detected automatically. If Nothing is returned, then error will be set.
newFromResource
textureNewFromResource Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Text |
|
| -> m Texture | Returns: A newly-created texture |
Creates a new texture by loading an image from a resource. The file format is detected automatically.
It is a fatal error if resourcePath does not specify a valid
image resource and the program will abort if that happens.
If you are unsure about the validity of a resource, use
textureNewFromFile to load it.
saveToPng
Arguments
| :: (HasCallStack, MonadIO m, IsTexture a) | |
| => a |
|
| -> Text |
|
| -> m Bool |
Store the given texture to the filename as a PNG file.
This is a utility function intended for debugging and testing.
If you want more control over formats, proper error handling or
want to store to a File or other location, you might want to
look into using the gdk-pixbuf library.
Properties
height
The height of the texture.
constructTextureHeight :: IsTexture o => Int32 -> IO (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “height” property. This is rarely needed directly, but it is used by new.
getTextureHeight :: (MonadIO m, IsTexture o) => o -> m Int32 Source #
Get the value of the “height” property.
When overloading is enabled, this is equivalent to
get texture #height
width
The width of the texture.
constructTextureWidth :: IsTexture o => Int32 -> IO (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “width” property. This is rarely needed directly, but it is used by new.
getTextureWidth :: (MonadIO m, IsTexture o) => o -> m Int32 Source #
Get the value of the “width” property.
When overloading is enabled, this is equivalent to
get texture #width