Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

Rendering problem with transparency (alpha) value 9 years 10 months ago #9153

  • hieutrtran
  • hieutrtran's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Last edit: by hieutrtran.

Rendering problem with transparency (alpha) value 9 years 10 months ago #9155

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65

Please Log in or Create an account to join the conversation.

Rendering problem with transparency (alpha) value 9 years 10 months ago #9156

  • hieutrtran
  • hieutrtran's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
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

Please Log in or Create an account to join the conversation.

Rendering problem with transparency (alpha) value 9 years 10 months ago #9159

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
we will check your project and get back to you as soon as possible..

Please Log in or Create an account to join the conversation.

Rendering problem with transparency (alpha) value 9 years 10 months ago #9189

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
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
BMP mBMP = new BMP();
mBMP.Create(bitmap);
// MulAlpha is needed to renormalize RGB values in presence of alpha channel !0xFF
mBMP.MulAlpha();

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum