[Cogl] [PATCH 07/11] bitmap: calc rowstride from width * bpp if 0

Robert Bragg robert at sixbynine.org
Thu Jun 27 09:22:14 PDT 2013


From: Robert Bragg <robert at linux.intel.com>

This updates cogl_bitmap_new_for_data() to calculate the rowstride from
the width and bpp if the given rowstride is 0, to be consistent with how
the texture apis work.
---
 cogl/cogl-bitmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c
index e8779a9..274d4ad 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -178,6 +178,10 @@ cogl_bitmap_new_for_data (CoglContext *context,
 
   g_return_val_if_fail (cogl_is_context (context), NULL);
 
+  /* Rowstride from width if not given */
+  if (rowstride == 0)
+    rowstride = width * _cogl_pixel_format_get_bytes_per_pixel (format);
+
   bmp = g_slice_new (CoglBitmap);
   bmp->context = context;
   bmp->format = format;
-- 
1.8.2.1



More information about the Cogl mailing list