当前位置: 首页>>代码示例>>C++>>正文


C++ BitmapImage::sizeRespectingOrientation方法代码示例

本文整理汇总了C++中BitmapImage::sizeRespectingOrientation方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapImage::sizeRespectingOrientation方法的具体用法?C++ BitmapImage::sizeRespectingOrientation怎么用?C++ BitmapImage::sizeRespectingOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitmapImage的用法示例。


在下文中一共展示了BitmapImage::sizeRespectingOrientation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: destRect

PassOwnPtr<DragImage> DragImage::create(Image* image, RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScaleFactor)
{
    if (!image)
        return nullptr;

    RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
    if (!bitmap)
        return nullptr;

    if (image->isBitmapImage()) {
        ImageOrientation orientation = DefaultImageOrientation;
        BitmapImage* bitmapImage = toBitmapImage(image);
        IntSize sizeRespectingOrientation = bitmapImage->sizeRespectingOrientation();

        if (shouldRespectImageOrientation == RespectImageOrientation)
            orientation = bitmapImage->currentFrameOrientation();

        if (orientation != DefaultImageOrientation) {
            FloatRect destRect(FloatPoint(), sizeRespectingOrientation);
            if (orientation.usesWidthAsHeight())
                destRect = destRect.transposedRect();

            SkBitmap skBitmap;
            skBitmap.setConfig(
                SkBitmap::kARGB_8888_Config, sizeRespectingOrientation.width(), sizeRespectingOrientation.height());
            if (!skBitmap.allocPixels())
                return nullptr;

            SkCanvas canvas(skBitmap);
            canvas.concat(affineTransformToSkMatrix(orientation.transformFromDefault(sizeRespectingOrientation)));
            canvas.drawBitmapRect(bitmap->bitmap(), 0, destRect);

            return adoptPtr(new DragImage(skBitmap, deviceScaleFactor));
        }
    }

    SkBitmap skBitmap;
#if defined(SBROWSER_GPU_RASTERIZATION_ENABLE)
    if (!bitmap->bitmap().copyTo(&skBitmap, kPMColor_SkColorType))
#else
    if (!bitmap->bitmap().copyTo(&skBitmap, SkBitmap::kARGB_8888_Config))
#endif
        return nullptr;
    return adoptPtr(new DragImage(skBitmap, deviceScaleFactor));
}
开发者ID:Tkkg1994,项目名称:Platfrom-kccat6,代码行数:45,代码来源:DragImage.cpp

示例2: createDragImageFromImage

DragImageRef createDragImageFromImage(Image* image, RespectImageOrientationEnum shouldRespectImageOrientation)
{
    if (!image)
        return 0;

    NativeImageSkia* bitmap = image->nativeImageForCurrentFrame();
    if (!bitmap)
        return 0;

    DragImageChromium* dragImageChromium = new DragImageChromium;
    dragImageChromium->bitmap = new SkBitmap();
    dragImageChromium->resolutionScale = bitmap->resolutionScale();

    if (image->isBitmapImage()) {
        ImageOrientation orientation = DefaultImageOrientation;
        BitmapImage* bitmapImage = static_cast<BitmapImage*>(image);
        IntSize sizeRespectingOrientation = bitmapImage->sizeRespectingOrientation();

        if (shouldRespectImageOrientation == RespectImageOrientation)
            orientation = bitmapImage->currentFrameOrientation();

        if (orientation != DefaultImageOrientation) {
            // Construct a correctly-rotated copy of the image to use as the drag image.
            dragImageChromium->bitmap->setConfig(
                SkBitmap::kARGB_8888_Config, sizeRespectingOrientation.width(), sizeRespectingOrientation.height());
            dragImageChromium->bitmap->allocPixels();

            FloatRect destRect(FloatPoint(), sizeRespectingOrientation);
            SkCanvas canvas(*dragImageChromium->bitmap);

            canvas.concat(orientation.transformFromDefault(sizeRespectingOrientation));

            if (orientation.usesWidthAsHeight())
                destRect = FloatRect(destRect.x(), destRect.y(), destRect.height(), destRect.width());

            canvas.drawBitmapRect(bitmap->bitmap(), 0, destRect);
            return dragImageChromium;
        }
    }

    bitmap->bitmap().copyTo(dragImageChromium->bitmap, SkBitmap::kARGB_8888_Config);
    return dragImageChromium;
}
开发者ID:dog-god,项目名称:iptv,代码行数:43,代码来源:DragImageChromiumSkia.cpp

示例3: destRect

PassOwnPtr<DragImage> DragImage::create(Image* image, RespectImageOrientationEnum shouldRespectImageOrientation, float deviceScaleFactor)
{
    if (!image)
        return nullptr;

    RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
    if (!bitmap)
        return nullptr;

    if (image->isBitmapImage()) {
        ImageOrientation orientation = DefaultImageOrientation;
        BitmapImage* bitmapImage = toBitmapImage(image);
        IntSize sizeRespectingOrientation = bitmapImage->sizeRespectingOrientation();

        if (shouldRespectImageOrientation == RespectImageOrientation)
            orientation = bitmapImage->currentFrameOrientation();

        if (orientation != DefaultImageOrientation) {
            FloatRect destRect(FloatPoint(), sizeRespectingOrientation);
            if (orientation.usesWidthAsHeight())
                destRect = destRect.transposedRect();

            SkBitmap skBitmap;
            if (!skBitmap.tryAllocN32Pixels(sizeRespectingOrientation.width(), sizeRespectingOrientation.height()))
                return nullptr;

            SkCanvas canvas(skBitmap);
            canvas.concat(affineTransformToSkMatrix(orientation.transformFromDefault(sizeRespectingOrientation)));
            canvas.drawBitmapRect(bitmap->bitmap(), 0, destRect);

            return adoptPtr(new DragImage(skBitmap, deviceScaleFactor));
        }
    }

    SkBitmap skBitmap;
    if (!bitmap->bitmap().copyTo(&skBitmap, kN32_SkColorType))
        return nullptr;
    return adoptPtr(new DragImage(skBitmap, deviceScaleFactor));
}
开发者ID:kjthegod,项目名称:WebKit,代码行数:39,代码来源:DragImage.cpp


注:本文中的BitmapImage::sizeRespectingOrientation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。