Leopard broke NSView's cacheDisplayInRect:toBitmapImageRep:

  • 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