Cogl.Bitmap

g Cogl.Bitmap Cogl.Bitmap Cogl.Object Cogl.Object Cogl.Object->Cogl.Bitmap

Subclasses:

None

Methods

Inherited:

Cogl.Object (2)

class

get_size_from_file (filename)

class

new_for_data (context, width, height, format, rowstride, data)

class

new_from_buffer (buffer, format, width, height, rowstride, offset)

class

new_from_file (filename)

class

new_with_size (context, width, height, format)

get_buffer ()

get_format ()

get_height ()

get_rowstride ()

get_width ()

Virtual Methods

None

Fields

None

Class Details

class Cogl.Bitmap
Bases:

Cogl.Object

Abstract:

No

classmethod get_size_from_file(filename)
Parameters:

filename (str) – the file to check

Returns:

True if the image was successfully parsed

width:

return location for the bitmap width, or None

height:

return location for the bitmap height, or None

Return type:

(int, width: int, height: int)

Parses an image file enough to extract the width and height of the bitmap.

New in version 1.0.

classmethod new_for_data(context, width, height, format, rowstride, data)
Parameters:
  • context (Cogl.Context) – A Cogl.Context

  • width (int) – The width of the bitmap.

  • height (int) – The height of the bitmap.

  • format (Cogl.PixelFormat) – The format of the pixel data.

  • rowstride (int) – The rowstride of the bitmap (the number of bytes from the start of one row of the bitmap to the next).

  • data (int) – A pointer to the data. The bitmap will take ownership of this data.

Returns:

A new Cogl.Bitmap.

Return type:

Cogl.Bitmap

Creates a bitmap using some existing data. The data is not copied so the application must keep the buffer alive for the lifetime of the Cogl.Bitmap. This can be used for example with Cogl.Framebuffer.read_pixels_into_bitmap() to read data directly into an application buffer with the specified rowstride.

New in version 1.10.

classmethod new_from_buffer(buffer, format, width, height, rowstride, offset)
Parameters:
  • buffer (object) – A #CoglBuffer containing image data

  • format (Cogl.PixelFormat) – The Cogl.PixelFormat defining the format of the image data in the given buffer.

  • width (int) – The width of the image data in the given buffer.

  • height (int) – The height of the image data in the given buffer.

  • rowstride (int) – The rowstride in bytes of the image data in the given buffer.

  • offset (int) – The offset into the given buffer to the first pixel that should be considered part of the Cogl.Bitmap.

Returns:

a Cogl.Bitmap encapsulating the given buffer.

Return type:

Cogl.Bitmap

Wraps some image data that has been uploaded into a #CoglBuffer as a Cogl.Bitmap. The data is not copied in this process.

New in version 1.8.

classmethod new_from_file(filename)
Parameters:

filename (str) – the file to load.

Raises:

GLib.Error

Returns:

a Cogl.Bitmap to the new loaded image data, or None if loading the image failed.

Return type:

Cogl.Bitmap

Loads an image file from disk. This function can be safely called from within a thread.

New in version 1.0.

classmethod new_with_size(context, width, height, format)
Parameters:
Returns:

a Cogl.PixelBuffer representing the newly created array or None on failure

Return type:

Cogl.Bitmap

Creates a new Cogl.Bitmap with the given width, height and format. The initial contents of the bitmap are undefined.

The data for the bitmap will be stored in a newly created Cogl.PixelBuffer. You can get a pointer to the pixel buffer using Cogl.Bitmap.get_buffer(). The #CoglBuffer API can then be used to fill the bitmap with data.

Cogl will try its best to provide a hardware array you can map, write into and effectively do a zero copy upload when creating a texture from it with cogl_texture_new_from_bitmap(). For various reasons, such arrays are likely to have a stride larger than width * bytes_per_pixel. The user must take the stride into account when writing into it. The stride can be retrieved with Cogl.Bitmap.get_rowstride().

New in version 1.10.

get_buffer()
Returns:

the Cogl.PixelBuffer that this buffer uses for storage. Note that if the bitmap was created with Cogl.Bitmap.new_from_file() then it will not actually be using a pixel buffer and this function will return None.

Return type:

Cogl.PixelBuffer

New in version 1.10.

get_format()
Returns:

the Cogl.PixelFormat that the data for the bitmap is in.

Return type:

Cogl.PixelFormat

New in version 1.10.

get_height()
Returns:

the height of the bitmap

Return type:

int

New in version 1.10.

get_rowstride()
Returns:

the rowstride of the bitmap. This is the number of bytes between the address of start of one row to the address of the next row in the image.

Return type:

int

New in version 1.10.

get_width()
Returns:

the width of the bitmap

Return type:

int

New in version 1.10.