[master] 966e15f - Simpler implementation of Fl_Quartz_Image_Surface_Driver::image()

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 966e15f - Simpler implementation of Fl_Quartz_Image_Surface_Driver::image() "ManoloFLTK" 01:02 Oct 14 top right image
 
commit 966e15fe376cb931e543c69371627cfa00bfc6a8
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Wed Oct 14 09:56:41 2020 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Wed Oct 14 09:56:53 2020 +0200

    Simpler implementation of Fl_Quartz_Image_Surface_Driver::image()

 src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
index 61068cf..e0146c8 100644
--- src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
+++ src/drivers/Quartz/Fl_Quartz_Image_Surface_Driver.cxx
@@ -114,10 +114,19 @@ Fl_RGB_Image* Fl_Quartz_Image_Surface_Driver::image()
   CGContextFlush(offscreen);
   int W = CGBitmapContextGetWidth(offscreen);
   int H = CGBitmapContextGetHeight(offscreen);
-  int save_w = width, save_h = height;
-  width = W; height = H;
-  unsigned char *data = fl_read_image(NULL, 0, 0, W, H, 0);
-  width = save_w; height = save_h;
+  int bpr = CGBitmapContextGetBytesPerRow(offscreen);
+  int bpp = CGBitmapContextGetBitsPerPixel(offscreen)/8;
+  uchar *base = (uchar*)CGBitmapContextGetData(offscreen);
+  int idx, idy;
+  uchar *pdst, *psrc;
+  unsigned char *data = new uchar[W * H * 3];
+  for (idy = 0, pdst = data; idy < H; idy ++) {
+    for (idx = 0, psrc = base + idy * bpr; idx < W; idx ++, psrc += bpp, pdst += 3) {
+      pdst[0] = psrc[0];  // R
+      pdst[1] = psrc[1];  // G
+      pdst[2] = psrc[2];  // B
+    }
+  }
   Fl_RGB_Image *image = new Fl_RGB_Image(data, W, H);
   image->alloc_array = 1;
   return image;
Direct Link to Message ]
 
bottom left image   bottom right image
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2020 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.