I’m using the below code to save an image using RenderTexture:
auto sprite = Sprite::create("original.png"); auto renderTexture = RenderTexture::create(64, 64, Texture2D::PixelFormat::RGBA8888); renderTexture->begin(); sprite->setAnchorPoint(Vec2(0, 0)); sprite->setPosition(Vec2(0,0)); sprite->visit(); renderTexture->end(); renderTexture->saveToFile("rendertexture.png", Image::Format::PNG);
My issue is that I get strange artifacts in the saved file. For example look at the below images:
The first image is the original while the second is the renderTexture->saveToFile() image. Notice how for the second one the edges at the top have a dark border which the original does not have. Is it maybe something to do with the alpha values at the edges not being saved properly? Any ideas on how to fix?