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

add support for jpx decode/encode with JP2ForAndroid #387

Merged
merged 4 commits into from
Mar 31, 2022

Conversation

anyongjin
Copy link
Contributor

slim_first.pdf
This is a pdf with many jpx images, which can not be print while converting pdf to image.
JP2ForAndroid is a java wrapper for OpenJPEG.
I imported JP2ForAndroid as a depence to encode/decode jpx for pdfbox

Althought android.graphics.ColorSpace is used in this commit, it appears only in PDJPXColorSpace, which would only be used in JPXFilter when Build.VERSION.SDK_INT > Build.VERSION_CODES.O and COLORSPACE not exists in cos parameters.
In fact, most jpx objects has COLORSPACE in its cos parameters.
On the other hand, in api < 26, PDImageXObject.colorSpace would be null and it can be created from COLORSPACE when needed.

So, the jpx support would also works fine in api < 26

@TomRoush TomRoush added the type: enhancement Request to add/improve a feature label Mar 28, 2022
@anyongjin
Copy link
Contributor Author

anyongjin commented Mar 28, 2022

in the first verions , there is two stages in jpx decoding:

  1. decode bitmap from inputstream
  2. write bitmap bytes to output stream.

in the performance test, stage two is 10x times slower than stage one.
so I edit to use a buffer to write bytes to output stream, which makes it 10x faster

@TomRoush TomRoush added this to the v2.0.18.0 milestone Mar 29, 2022
@TomRoush TomRoush merged commit 73c00ab into TomRoush:master Mar 31, 2022
@TomRoush
Copy link
Owner

@anyongjin thanks for your work on this. Just so you're aware, in #391, I made the JP2Android library an optional dependency to keep the application size low since most users probably won't need to handle JPX images. Since I'm sure that you would like to handle JPX images, you will need to add implementation 'com.gemalto.jp2:jp2-android:1.0.3' to your application's Gradle build file

@anyongjin
Copy link
Contributor Author

I also think it's a good idea to make the JP2Android library an optional dependency. thanks for your work. @TomRoush

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Request to add/improve a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants