Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ALPHA_8 format support for bitmap in Cue. #2058

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

peerless2012
Copy link

@peerless2012 peerless2012 commented Jan 20, 2025

Bitmap.compress not support ALPHA_8 format, so we just copy the pixel buffer.

This should fix #2054

Copy link

google-cla bot commented Jan 20, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@peerless2012 peerless2012 changed the title Add ALPHA_8 format support for bitmap in Cue. Fix ALPHA_8 format support for bitmap in Cue. Jan 20, 2025
@@ -835,6 +837,9 @@ public Cue build() {
private static final String FIELD_MULTI_ROW_ALIGNMENT = Util.intToStringMaxRadix(2);
private static final String FIELD_BITMAP_PARCELABLE = Util.intToStringMaxRadix(3);
private static final String FIELD_BITMAP_BYTES = Util.intToStringMaxRadix(18);
private static final String FIELD_BITMAP_ORIGIN_WIDTH = Util.intToStringMaxRadix(19);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the meaning of the word 'origin' here?


/** Tests for {@link Cue}. */
@RunWith(AndroidJUnit4.class)
public class CueTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just move the whole of CueTest to androidTest instead of splitting it like this.

bitmap = Bitmap.createBitmap(bitmapWidth,bitmapHeight, Bitmap.Config.ALPHA_8);
Buffer buffer = ByteBuffer.wrap(bitmapBytes);
bitmap.copyPixelsFromBuffer(buffer);
builder.setBitmap(bitmap);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: de-duplicate the 3 builder.setBitmap lines, so the code is instead:

@Nullable Bitmap bitmap = bundle.getParcelable(FIELD_BITMAP_PARCELABLE);
if (bitmap == null) {
  // handle bytes case (both compressed and uncompressed) with 
  // existing code, but assigning `bitmap` each time instead of setting
  // it on the builder.
}
builder.setBitmap(bitmap); // Passing null is fine here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cue encode error when use bitmap and config is ALPHA_8.
2 participants