Re: Leopard broke NSView's cacheDisplayInRect:toBitmapImageRep:

  • Just in case somebody else runs into this and finds this in the
    archives: A workaround is to set the NSBitmapImageRep size before
    calling
    cacheDisplayInRect:toBitmapImageRep:, eg in the code below this line
    had to be added to make it work on Leopard:

    [bir setSize:imgSize];

    Gerd

    On Nov 7, 2007, at 4:57 PM, Gerd Knops wrote:

    > I use the code below to produce a drag image. The view in question
    > is scaled. The code works fine under Tiger, but under Leopard the
    > view representation only fills a tiny area in the bottom left corner
    > of the drag image.
    >
    > Any ideas?
    >
    > Thanks
    >
    > Gerd
    >
    >
    > NSSize    mySize=[self bounds].size;
    > NSSize
    > imgSize
    > =
    > NSMakeSize
    > (mySize.width*dragScaleFactor,mySize.height*dragScaleFactor);
    >
    > NSBitmapImageRep *bir=[self bitmapImageRepForCachingDisplayInRect:
    > [self bounds]];
    > [self cacheDisplayInRect:[self bounds] toBitmapImageRep:bir];
    >
    > DLog(@"mySize        : %@",NSStringFromSize(mySize));
    > DLog(@"imgSize      : %@",NSStringFromSize(imgSize));
    > DLog(@"bir size      : %@",NSStringFromSize([bir size]));
    >
    > NSImage    *dragImage=[[NSImage alloc]initWithSize:imgSize];
    > [dragImage addRepresentation:bir];
    >
    > DLog(@"dragImage size: %@",NSStringFromSize([dragImage size]));
    >
    > Output under Tiger:
    >
    > PageView.m:398: mySize        : {3728, 5856}
    > PageView.m:399: imgSize      : {96, 150.798}
    > PageView.m:400: bir size      : {96, 151}
    > PageView.m:405: dragImage size: {96, 150.798}
    >
    > Leopard (different scale, but note the different size for bir):
    >
    > PageView.m:398: mySize        : {3728, 5856}
    > PageView.m:399: imgSize      : {288, 452.395}
    > PageView.m:400: bir size      : {3728, 5856}
    > PageView.m:405: dragImage size: {288, 452.395}
    >
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today