summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2010-07-09 17:29:35 +0000
committerManolo Gouy <Manolo>2010-07-09 17:29:35 +0000
commit0ac2bc4d40209005b37931bc4541c2af777635fa (patch)
treeac5ad065d9494b113fdbda9891510644692a0b42 /src
parentbd1ac8889b3c30bfe1f4f23e807a55506cbbdbf6 (diff)
Fixed use of x and y args when reading from offscreen buffer and test when w or h are too big
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7670 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_read_image_mac.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fl_read_image_mac.cxx b/src/fl_read_image_mac.cxx
index 5493ff3ca..212aaca0c 100644
--- a/src/fl_read_image_mac.cxx
+++ b/src/fl_read_image_mac.cxx
@@ -49,13 +49,14 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
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 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
// 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