static bool SetImageRef(SkBitmap* bitmap, SkStream* stream,
                        SkBitmap::Config pref, const char name[] = NULL)
{
    if (SkImageDecoder::DecodeStream(stream, bitmap, pref,
                                 SkImageDecoder::kDecodeBounds_Mode, NULL)) {
        SkASSERT(bitmap->config() != SkBitmap::kNo_Config);
    
        SkImageRef* ref = new SkImageRef_GlobalPool(stream, bitmap->config());
        ref->setURI(name);
        bitmap->setPixelRef(ref)->unref();
        return true;
    } else {
        return false;
    }
}
示例#2
0
static bool SetImageRef(SkBitmap* bitmap, SkStream* stream,
                        SkBitmap::Config pref, const char name[] = NULL) {
#if 0
    // test buffer streams
    SkStream* str = new SkBufferStream(stream, 717);
    stream->unref();
    stream = str;
#endif

    SkImageRef* ref = new SkImageRef_GlobalPool(stream, pref, 1);
    ref->setURI(name);
    if (!ref->getInfo(bitmap)) {
        delete ref;
        return false;
    }
    bitmap->setPixelRef(ref)->unref();
    return true;
}