Author: manolo
Date: 2010-07-09 10:29:35 -0700 (Fri, 09 Jul 2010)
New Revision: 7670
Log:
Fixed use of x and y args when reading from offscreen buffer and test when w or 
h are too big

Modified:
   branches/branch-1.3/src/fl_read_image_mac.cxx

Modified: branches/branch-1.3/src/fl_read_image_mac.cxx
===================================================================
--- branches/branch-1.3/src/fl_read_image_mac.cxx       2010-07-08 13:07:16 UTC 
(rev 7669)
+++ branches/branch-1.3/src/fl_read_image_mac.cxx       2010-07-09 17:29:35 UTC 
(rev 7670)
@@ -49,13 +49,14 @@
     int sh = CGBitmapContextGetHeight(src);
     rowBytes = CGBitmapContextGetBytesPerRow(src);
     delta = CGBitmapContextGetBitsPerPixel(src)/8;
-    if( (sw - x > w) || (sh - y > h) )  return NULL;
+    if( (sw - x < w) || (sh - y < h) )  return NULL;
     }
   else { // reading from current window
     Fl_Window *window = Fl_Window::current();
     while(window->window()) window = window->window();
     base = MACbitmapFromRectOfWindow(window,x,y,w,h,&delta);
     rowBytes = delta*w;
+    x = y = 0;
     }
   // Allocate the image data array as needed...
   int d = alpha ? 4 : 3;
@@ -65,8 +66,8 @@
   // Copy the image from the off-screen buffer to the memory buffer.
   int           idx, idy;      // Current X & Y in image
   uchar *pdst, *psrc;
-  for (idy = 0, pdst = p; idy < h; idy ++) {
-    for (idx = 0, psrc = base + idy * rowBytes; idx < w; idx ++, psrc += 
delta, pdst += d) {
+  for (idy = y, pdst = p; idy < h + y; idy ++) {
+    for (idx = 0, psrc = base + idy * rowBytes + x * delta; idx < w; idx ++, 
psrc += delta, pdst += d) {
       pdst[0] = psrc[0];  // R
       pdst[1] = psrc[1];  // G
       pdst[2] = psrc[2];  // B

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to