Cannot include video when rendering a WebView to CGImageRef

Discussion in 'Mac Programming' started by tannyhot, Apr 27, 2011.

  1. tannyhot macrumors newbie

    Apr 27, 2011

    Please guys, I need your help on this. I'm using this code to render the contents of any NSView:

    + (CGImageRef)allocCGImageRefFromView:(NSView*)theView
    NSBitmapImageRep * bm = [NSBitmapImageRep alloc];
        NSBitmapImageRep * newBM = nil;
    [theView lockFocus];
        [bm retain];
    newBM = [bm initWithFocusedViewRect:[theView bounds]];
        [newBM autorelease];
    [theView unlockFocus];
    //[bm retain];// data provider will release this
    NSInteger     rowBytes, width, height;
    rowBytes = [bm bytesPerRow];
    width = [bm pixelsWide];
    height = [bm pixelsHigh];
    CGDataProviderRef provider = CGDataProviderCreateWithData([bm autorelease], [bm bitmapData], rowBytes * height, BitmapReleaseCallback );
    CGColorSpaceRef colorspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
    CGBitmapInfo    bitsInfo = kCGImageAlphaPremultipliedLast;
    CGImageRef img = CGImageCreate( width, height, 8, 32, rowBytes, colorspace, bitsInfo, provider, NULL, NO, kCGRenderingIntentDefault );
    CGDataProviderRelease( provider );
    CGColorSpaceRelease( colorspace );
    return img;
    However, when I tried this with WebView, it seems that it can only render simple content (i.e. buttons, images, text) and it cannot render any video that's embedded in a website. Did I miss something here? Or this kind of behavior functions as designed by Apple?


Share This Page