Reviewed-by: Robert Bragg &lt;<a href="mailto:robert@linux.intel.com">robert@linux.intel.com</a>&gt;<div><br><div class="gmail_quote">On Mon, Mar 19, 2012 at 2:32 PM, Neil Roberts <span dir="ltr">&lt;<a href="mailto:neil@linux.intel.com">neil@linux.intel.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This adds a public convenience wrapper around<br>
cogl_framebuffer_read_pixels_into_bitmap which allocates a temporary<br>
CoglBitmap to read into the application&#39;s own buffer. This can only be<br>
used for the 99% common case where the rowstride is exactly the<br>
bpp*width and the source is the color buffer.<br>
---<br>
 cogl/cogl-framebuffer.c                            |   27 +++++++++++<br>
 cogl/cogl-framebuffer.h                            |   48 ++++++++++++++++++++<br>
 .../cogl-2.0-experimental-sections.txt             |    1 +<br>
 3 files changed, 76 insertions(+), 0 deletions(-)<br>
<br>
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c<br>
index ab7f0aa..8cbee1d 100644<br>
--- a/cogl/cogl-framebuffer.c<br>
+++ b/cogl/cogl-framebuffer.c<br>
@@ -2179,6 +2179,33 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,<br>
   return TRUE;<br>
 }<br>
<br>
+gboolean<br>
+cogl_framebuffer_read_pixels (CoglFramebuffer *framebuffer,<br>
+                              int x,<br>
+                              int y,<br>
+                              int width,<br>
+                              int height,<br>
+                              CoglPixelFormat format,<br>
+                              guint8 *pixels)<br>
+{<br>
+  int bpp = _cogl_pixel_format_get_bytes_per_pixel (format);<br>
+  CoglBitmap *bitmap;<br>
+  gboolean ret;<br>
+<br>
+  bitmap = cogl_bitmap_new_for_data (framebuffer-&gt;context,<br>
+                                     width, height,<br>
+                                     format,<br>
+                                     bpp * width, /* rowstride */<br>
+                                     pixels);<br>
+  ret = cogl_framebuffer_read_pixels_into_bitmap (framebuffer,<br>
+                                                  x, y,<br>
+                                                  COGL_READ_PIXELS_COLOR_BUFFER,<br>
+                                                  bitmap);<br>
+  cogl_object_unref (bitmap);<br>
+<br>
+  return ret;<br>
+}<br>
+<br>
 void<br>
 _cogl_blit_framebuffer (unsigned int src_x,<br>
                         unsigned int src_y,<br>
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h<br>
index b314426..896a3c1 100644<br>
--- a/cogl/cogl-framebuffer.h<br>
+++ b/cogl/cogl-framebuffer.h<br>
@@ -1280,6 +1280,54 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,<br>
                                           CoglBitmap *bitmap);<br>
<br>
 /**<br>
+ * cogl_framebuffer_read_pixels:<br>
+ * @framebuffer: A #CoglFramebuffer<br>
+ * @x: The x position to read from<br>
+ * @y: The y position to read from<br>
+ * @width: The width of the region of rectangles to read<br>
+ * @height: The height of the region of rectangles to read<br>
+ * @format: The pixel format to store the data in<br>
+ * @pixels: The address of the buffer to store the data in<br>
+ *<br>
+ * This is a convenience wrapper around<br>
+ * cogl_framebuffer_read_pixels_into_bitmap() which allocates a<br>
+ * temporary #CoglBitmap to read pixel data directly into the given<br>
+ * buffer. The rowstride of the buffer is assumed to be the width of<br>
+ * the region times the bytes per pixel of the format. The source for<br>
+ * the data is always taken from the color buffer. If you want to use<br>
+ * any other rowstride or source, please use the<br>
+ * cogl_framebuffer_read_pixels_into_bitmap() function directly.<br>
+ *<br>
+ * The implementation of the function looks like this:<br>
+ *<br>
+ * |[<br>
+ * bitmap = cogl_bitmap_new_for_data (context,<br>
+ *                                    width, height,<br>
+ *                                    format,<br>
+ *                                    /&lt;!-- --&gt;* rowstride *&lt;!-- --&gt;/<br>
+ *                                    bpp * width,<br>
+ *                                    pixels);<br>
+ * cogl_framebuffer_read_pixels_into_bitmap (framebuffer,<br>
+ *                                           x, y,<br>
+ *                                           COGL_READ_PIXELS_COLOR_BUFFER,<br>
+ *                                           bitmap);<br>
+ * cogl_object_unref (bitmap);<br>
+ * ]|<br>
+ *<br>
+ * Return value: %TRUE if the read succeeded or %FALSE otherwise.<br>
+ * Since: 1.10<br>
+ * Stability: unstable<br>
+ */<br>
+gboolean<br>
+cogl_framebuffer_read_pixels (CoglFramebuffer *framebuffer,<br>
+                              int x,<br>
+                              int y,<br>
+                              int width,<br>
+                              int height,<br>
+                              CoglPixelFormat format,<br>
+                              guint8 *pixels);<br>
+<br>
+/**<br>
  * cogl_get_draw_framebuffer:<br>
  *<br>
  * Gets the current #CoglFramebuffer as set using<br>
diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt<br>
index 1907687..ad3e067 100644<br>
--- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt<br>
+++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt<br>
@@ -396,6 +396,7 @@ cogl_framebuffer_get_context<br>
 cogl_framebuffer_clear<br>
 cogl_framebuffer_clear4f<br>
 cogl_framebuffer_read_pixels_into_bitmap<br>
+cogl_framebuffer_read_pixels<br>
<br>
 &lt;SUBSECTION&gt;<br>
 cogl_framebuffer_draw_primitive<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.3.16.g9464b<br>
<br>
_______________________________________________<br>
Cogl mailing list<br>
<a href="mailto:Cogl@lists.freedesktop.org">Cogl@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/cogl" target="_blank">http://lists.freedesktop.org/mailman/listinfo/cogl</a><br>
</font></span></blockquote></div><br></div>