summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-02-09 17:26:20 +0000
committerManolo Gouy <Manolo>2018-02-09 17:26:20 +0000
commit0012debf3773221a231c40794d09021f0c75c3cf (patch)
tree3f333115b0de245764a8804044668666eff23781
parent6f5340d430aa0a1a13dc7ce527424a9c50c1382d (diff)
After r.12653, it is also necessary to remove Fl_Cocoa_Window_Driver::bitmap_from_window_rect()
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12657 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_cocoa.mm74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 20ac19641..533d6f251 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -4248,80 +4248,6 @@ static NSBitmapImageRep* rect_to_NSBitmapImageRep(Fl_Window *win, int x, int y,
return bitmap;
}
-
-unsigned char *Fl_Cocoa_Window_Driver::bitmap_from_window_rect(int x, int y, int w, int h, int *bytesPerPixel)
-/* Returns a capture of a rectangle of a mapped window as a pre-multiplied RGBA array of bytes.
- Alpha values are always 1 (except for the angles of a window title bar)
- so pre-multiplication can be ignored.
- *bytesPerPixel is set to the value 3 or 4 upon return.
- delete[] the returned pointer after use
- */
-{
- Fl_Window *win = pWindow;
- NSBitmapImageRep *bitmap = rect_to_NSBitmapImageRep(win, x, y, w, h);
- if (bitmap == nil) return NULL;
- *bytesPerPixel = [bitmap bitsPerPixel]/8;
- int bpp = (int)[bitmap bytesPerPlane];
- int bpr = (int)[bitmap bytesPerRow];
- int hh = bpp/bpr; // sometimes hh = h-1 for unclear reason, and hh = 2*h with retina
- int ww = bpr/(*bytesPerPixel); // sometimes ww = w-1, and ww = 2*w with retina
- const uchar *start = [bitmap bitmapData]; // start of the bitmap data
- bool convert = false;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- if (fl_mac_os_version >= 100400 && ([bitmap bitmapFormat] & NSAlphaFirstBitmapFormat)) {
- // bitmap is ARGB --> convert it to RGBA (ARGB happens with Mac OS 10.11)
- // it is enough to offset reading by one byte because A is always 0xFF
- // so ARGBARGB becomes RGBARGBA as needed
- start++;
- convert = true;
- }
-#endif
- unsigned char *data;
- size_t tocopy;
- if (ww > w) { // with a retina display, we have to scale the image by a factor of 2
- uchar *data2 = [bitmap bitmapData];
- if (convert) { // duplicate the NSBitmapImageRep data taking care not to access beyond its end
- tocopy = ww*hh*4;
- data2 = new uchar[tocopy];
- memcpy(data2, start, --tocopy);
- data2[tocopy] = 0xFF; // set the last A byte
- }
- Fl_RGB_Image *rgb = new Fl_RGB_Image(data2, ww, hh, 4);
- rgb->alloc_array = (convert ? 1 : 0);
- Fl_RGB_Scaling save_scaling = Fl_Image::RGB_scaling();
- Fl_Image::RGB_scaling(FL_RGB_SCALING_BILINEAR);
- Fl_RGB_Image *rgb2 = (Fl_RGB_Image*)rgb->copy(w, h);
- Fl_Image::RGB_scaling(save_scaling);
- delete rgb;
- rgb2->alloc_array = 0;
- data = (uchar*)rgb2->array;
- delete rgb2;
- }
- else {
- data = new unsigned char[w * h * *bytesPerPixel];
- if (w == ww) { // the NSBitmapImageRep data can be copied in one step
- tocopy = w * hh * (*bytesPerPixel);
- if (convert) { // take care not to access beyond the image end
- data[--tocopy] = 0xFF; // set the last A byte
- }
- memcpy(data, start, tocopy);
- } else { // copy the NSBitmapImageRep data line by line
- const uchar *p = start;
- unsigned char *q = data;
- tocopy = bpr;
- for (int i = 0; i < hh; i++) {
- if (i == hh-1 && convert) tocopy--; // take care not to access beyond the image end
- memcpy(q, p, tocopy);
- p += bpr;
- q += w * (*bytesPerPixel);
- }
- }
- }
- [bitmap release];
- return data;
-}
-
-
static void nsbitmapProviderReleaseData (void *info, const void *data, size_t size)
{
[(NSBitmapImageRep*)info release];