Mac OS: handle possible NULL return after screen capture attempt.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10078 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
4d5e10097e
commit
4eee9f1f63
@ -3351,6 +3351,7 @@ unsigned char *Fl_X::bitmap_from_window_rect(Fl_Window *win, int x, int y, int w
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
NSBitmapImageRep *bitmap = rect_to_NSBitmapImageRep(win, x, y, w, h);
|
NSBitmapImageRep *bitmap = rect_to_NSBitmapImageRep(win, x, y, w, h);
|
||||||
|
if (bitmap == nil) return NULL;
|
||||||
*bytesPerPixel = [bitmap bitsPerPixel]/8;
|
*bytesPerPixel = [bitmap bitsPerPixel]/8;
|
||||||
int bpp = (int)[bitmap bytesPerPlane];
|
int bpp = (int)[bitmap bytesPerPlane];
|
||||||
int bpr = (int)[bitmap bytesPerRow];
|
int bpr = (int)[bitmap bytesPerRow];
|
||||||
@ -3388,6 +3389,7 @@ CGImageRef Fl_X::CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, i
|
|||||||
else {
|
else {
|
||||||
int bpp;
|
int bpp;
|
||||||
unsigned char *bitmap = bitmap_from_window_rect(win, x, y, w, h, &bpp);
|
unsigned char *bitmap = bitmap_from_window_rect(win, x, y, w, h, &bpp);
|
||||||
|
if (!bitmap) return NULL;
|
||||||
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
|
CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB();
|
||||||
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, bitmap, w*h*bpp, imgProviderReleaseData);
|
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, bitmap, w*h*bpp, imgProviderReleaseData);
|
||||||
img = CGImageCreate(w, h, 8, 8*bpp, w*bpp, lut,
|
img = CGImageCreate(w, h, 8, 8*bpp, w*bpp, lut,
|
||||||
|
@ -45,6 +45,7 @@ fl_read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
|||||||
Fl_Window *window = Fl_Window::current();
|
Fl_Window *window = Fl_Window::current();
|
||||||
while(window->window()) window = window->window();
|
while(window->window()) window = window->window();
|
||||||
base = Fl_X::bitmap_from_window_rect(window,x,y,w,h,&delta);
|
base = Fl_X::bitmap_from_window_rect(window,x,y,w,h,&delta);
|
||||||
|
if (!base) return NULL;
|
||||||
rowBytes = delta*w;
|
rowBytes = delta*w;
|
||||||
x = y = 0;
|
x = y = 0;
|
||||||
}
|
}
|
||||||
|
@ -143,11 +143,13 @@ void fl_scroll(int X, int Y, int W, int H, int dx, int dy,
|
|||||||
|
|
||||||
#elif defined(__APPLE_QUARTZ__)
|
#elif defined(__APPLE_QUARTZ__)
|
||||||
CGImageRef img = Fl_X::CGImage_from_window_rect(Fl_Window::current(), src_x, src_y, src_w, src_h);
|
CGImageRef img = Fl_X::CGImage_from_window_rect(Fl_Window::current(), src_x, src_y, src_w, src_h);
|
||||||
CGRect rect = { { dest_x, dest_y }, { src_w, src_h } };
|
if (img) {
|
||||||
Fl_X::q_begin_image(rect, 0, 0, src_w, src_h);
|
CGRect rect = { { dest_x, dest_y }, { src_w, src_h } };
|
||||||
CGContextDrawImage(fl_gc, rect, img);
|
Fl_X::q_begin_image(rect, 0, 0, src_w, src_h);
|
||||||
Fl_X::q_end_image();
|
CGContextDrawImage(fl_gc, rect, img);
|
||||||
CFRelease(img);
|
Fl_X::q_end_image();
|
||||||
|
CFRelease(img);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
# error unsupported platform
|
# error unsupported platform
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user