diff libinterp/corefcn/gl2ps-print.cc @ 22392:4dfb28724863

Clip double RGB data before passing to gl2psDrawPixels (bug #48873). * gl2ps-print.cc (gl2ps_renderer::draw_pixels): clip data between 0 and 1. * imshow.m: Correct title of demo #8.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Thu, 25 Aug 2016 10:02:22 +0200
parents 47629df12b79
children 52c205a0ad88
line wrap: on
line diff
--- a/libinterp/corefcn/gl2ps-print.cc	Fri Aug 26 16:21:04 2016 +0200
+++ b/libinterp/corefcn/gl2ps-print.cc	Thu Aug 25 10:02:22 2016 +0200
@@ -691,7 +691,13 @@
   void
   gl2ps_renderer::draw_pixels (int w, int h, const float *data)
   {
-    gl2psDrawPixels (w, h, 0, 0, GL_RGB, GL_FLOAT, data);
+    // Clip data between 0 and 1 for float values 
+    OCTAVE_LOCAL_BUFFER (float, tmp_data, 3*w*h);
+
+    for (int i = 0; i < 3*h*w; i++)
+      tmp_data[i] = (data[i] < 0.0f ? 0.0f : (data[i] > 1.0f ? 1.0f : data[i]));
+        
+    gl2psDrawPixels (w, h, 0, 0, GL_RGB, GL_FLOAT, tmp_data);
   }
 
   void