Skip to content

FlutterJNI.getBitmap generate wrong result when the screenshot has alpha channel #73036

@imReker

Description

@imReker

Steps to Reproduce

  1. Create a smallest MaterialApp with transparent background and a Container with 50% alpha white(#80FFFFFF) in it.
  2. Use RenderRepaintBoundary in Flutter to take a screenshot.
  3. Use FlutterImageView in Android Java side to take a screenshot.
  4. Use FlutterEngine.getRenderer().getBitmap(); in Java side to take a screenshot of this flutter app.

Expected results:
Step 2/3/4: A rectangular filled with #80FFFFFF centered in transparent background and the screenshot saved to a Bitmap.

Actual results:
In step 2 and 3, I get expected result.
I saved result as PNG and it looks like this in PhotoShop:
1

In step 4, a rectangular filled with #80808080 centered in transparent background.
I saved it to PNG:
wrong

Codes
MaterialApp(
      debugShowCheckedModeBanner: false,
      builder: (context, child) {
        return Material(
          type: MaterialType.transparency,
          child: Container(
            alignment: Alignment.center,
            color: Colors.transparent,
            child: Container(
              width: 50,
              height: 50,
              color: Color.fromARGB(128, 255, 255, 255),
            ),
          ),
        );
      },
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listengineflutter/engine related. See also e: labels.found in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions