Skip to content

Commit

Permalink
wip code review
Browse files Browse the repository at this point in the history
  • Loading branch information
j-jorge committed Nov 14, 2024
1 parent a994e52 commit 5a192ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/renderer/backend/PixelFormatUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void convertRG8ToRGBA8(const unsigned char* data, size_t dataLen, unsigne
for (ssize_t i = 0, l = dataLen - 1; i < l; i += 2)
{
*outData++ = data[i]; // R
*outData++ = data[i]; // G
*outData++ = data[i + 1]; // G
*outData++ = data[i]; // B
*outData++ = data[i + 1]; // A
}
Expand Down
9 changes: 7 additions & 2 deletions tests/cpp-tests/Source/Texture2dTest/Texture2dTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ void TexturePNG::onEnter()
ai88->setPosition(s.width / 4.0f, s.height * 3.0f / 4.0f);
addChild(ai88);

// grayscale with alpha, gray+alpha shader.
auto ai88s = Sprite::create("Images/test_image_ai88.png", PixelFormat::RG8);
ai88s->setPosition(s.width / 4.0f, s.height / 2.0f);
addChild(ai88s);

// rgb without alpha
auto rgb888 = Sprite::create("Images/test_image_rgb888.png");
rgb888->setPosition(s.width * 3.0f / 4.0f, s.height / 4.0f);
Expand All @@ -455,7 +460,7 @@ std::string TexturePNG::title() const

std::string TexturePNG::subtitle() const
{
return "LB:I8, LT:AI8\nRB:RGB888, RT: RGBA8888";
return "LB:I8, LM: AI8/RG8 pixel format, LT:AI8\nRB:RGB888, RT: RGBA8888";
}

//------------------------------------------------------------------
Expand Down Expand Up @@ -1634,7 +1639,7 @@ void TexturePixelFormat::onEnter()
Director::getInstance()->getTextureCache()->removeTexture(sprite5->getTexture());

// A8 image (8-bit)
auto sprite6 = Sprite::create("Images/test-rgba1.png", PixelFormat::R8); //
auto sprite6 = Sprite::create("Images/test-rgba1.png", PixelFormat::R8); //
sprite6->setPosition(Vec2(6 * s.width / 7, s.height / 2 - 32));
addChild(sprite6, 0);

Expand Down

0 comments on commit 5a192ef

Please sign in to comment.