Skip to content

Null Image Data In RenderTexture::newImage Callback #20776

@Diam2023

Description

@Diam2023
  • cocos2d-x version: 4.0
  • devices test on: Windows 11 Pro
  • developing environments
    • IDE: Clion 2023.1.3
    • Toolchain: Visual Studio
    • Generator: Visual Studio 17 2022
    • CMake: 3.26.3

When Run Code:

        RenderTexture* pRender = RenderTexture::create(
            static_cast<int>(tmpSprite->getContentSize().width),
            static_cast<int>(tmpSprite->getContentSize().height),
            backend::PixelFormat::RGBA8888);

//        pRender->setSprite(tmpSprite);
        pRender->begin();
        tmpSprite->visit();
        pRender->end();

        pRender->newImage([role](Image* image) {
            auto polygon = ImageAutoPolygon::generatePolygon(image);
            role->initWithPolygon(polygon);
            // role->updatePoly();
            role->setVisible(true);
        });

In line
auto polygon = ImageAutoPolygon::generatePolygon(image);
You Will get a incomplete Image Instance
Because Image::_data is null data
Like This:
image

When Use

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions