- Posts: 4
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Rendering problem with transparency (alpha) value
- hieutrtran
- Topic Author
- Offline
- New Member
-
Less
More
10 years 8 months ago - 10 years 8 months ago #9153
by hieutrtran
Rendering problem with transparency (alpha) value was created by hieutrtran
We're using v3.4 in one of our application.
It seems that results of the PDF renderer depend on how we erase the bitmap before rendering PDF pages to it in an odd way.
If we erase the bitmap with 0x00000000 (in our app, PDF images usually have alpha, so we need to erase the
bitmap with this value to preserve the transparency), the rendered bitmap itself often looks fine, but when we draw it on top of another
layer, the blending is weird. More interestingly, if we save the rendered bitmap to a PNG file and then decode it back, the
new bitmap looks very different from the original one. See the attached sample project, when we try to render the file file1.pdf.
If we try to erase the bitmap with another color, e.g. 0x7f050000 in the sample project, the weird blending and PNG image
disappear, but it increases the opacity of the bitmap. It also doesn't work in all cases, for example, with the PDF file
file2.pdf in our sample, the bitmap must be erased with 0x00000000 for the renderer to works correctly.
Steps to reproduce:
- Copy 2 files file1.pdf and file2.pdf to /sdcard/
- Run the sample project: result is the bitmap rendered from file1.pdf being drawn on top of a blue layer
- Change the erase color value in PDFSimple#render_page() from 0x00000000 to 0x7f050000 to see the difference in blending
and PNG image.
- Change the fileName in PDFSimpleAct#init() to FILE_2 and do the 2 steps above.
******* The sample project can be downloaded herer:
www.notabasement.com/files/PDFReader.zip
It seems that results of the PDF renderer depend on how we erase the bitmap before rendering PDF pages to it in an odd way.
If we erase the bitmap with 0x00000000 (in our app, PDF images usually have alpha, so we need to erase the
bitmap with this value to preserve the transparency), the rendered bitmap itself often looks fine, but when we draw it on top of another
layer, the blending is weird. More interestingly, if we save the rendered bitmap to a PNG file and then decode it back, the
new bitmap looks very different from the original one. See the attached sample project, when we try to render the file file1.pdf.
If we try to erase the bitmap with another color, e.g. 0x7f050000 in the sample project, the weird blending and PNG image
disappear, but it increases the opacity of the bitmap. It also doesn't work in all cases, for example, with the PDF file
file2.pdf in our sample, the bitmap must be erased with 0x00000000 for the renderer to works correctly.
Steps to reproduce:
- Copy 2 files file1.pdf and file2.pdf to /sdcard/
- Run the sample project: result is the bitmap rendered from file1.pdf being drawn on top of a blue layer
- Change the erase color value in PDFSimple#render_page() from 0x00000000 to 0x7f050000 to see the difference in blending
and PNG image.
- Change the fileName in PDFSimpleAct#init() to FILE_2 and do the 2 steps above.
******* The sample project can be downloaded herer:
www.notabasement.com/files/PDFReader.zip
Last edit: 10 years 8 months ago by hieutrtran.
10 years 8 months ago #9155
by Davide
Replied by Davide on topic Rendering problem with transparency (alpha) value
Hi,
this will help you: www.radaeepdf.com/support/knowledge-base...component&kbartid=24
this will help you: www.radaeepdf.com/support/knowledge-base...component&kbartid=24
- hieutrtran
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 4
- Thank you received: 0
10 years 8 months ago #9156
by hieutrtran
Replied by hieutrtran on topic Rendering problem with transparency (alpha) value
Hello
No, I dont have problem with rendering pdf contains transparency. The problem is the rendered image looks fine but its gone bad when put on top of another layer. Could you pls forward my sample code to the dev team, description and instructions are provided above. Thank you very much
No, I dont have problem with rendering pdf contains transparency. The problem is the rendered image looks fine but its gone bad when put on top of another layer. Could you pls forward my sample code to the dev team, description and instructions are provided above. Thank you very much
10 years 8 months ago #9159
by Davide
Replied by Davide on topic Rendering problem with transparency (alpha) value
Hi,
we will check your project and get back to you as soon as possible..
we will check your project and get back to you as soon as possible..
10 years 8 months ago #9189
by Davide
Replied by Davide on topic Rendering problem with transparency (alpha) value
Hi,
sorry for the delay.
We have checked you project and I suggest you to look at the Knowledgebase I linked you some days ago.
I think you need New BMP.MulAlpha() method and it is available starting from SDK 3.5beta6
sorry for the delay.
We have checked you project and I suggest you to look at the Knowledgebase I linked you some days ago.
I think you need New BMP.MulAlpha() method and it is available starting from SDK 3.5beta6
Code:
BMP mBMP = new BMP();
mBMP.Create(bitmap);
// MulAlpha is needed to renormalize RGB values in presence of alpha channel !0xFF
mBMP.MulAlpha();
Time to create page: 0.406 seconds