Android - Page image dimmed in small resolution - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Tell us about your applications and your projects.
  • Page:
  • 1

TOPIC: Android - Page image dimmed in small resolution

Android - Page image dimmed in small resolution 1 year 6 months ago #12352

  • JackyHo
  • JackyHo's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 0
Hi,

We are now using Android Radaee SDK version 3.10c.
We are trying to generate thumbnail for the pdf file in an android application.,So, we try to use DIB.DrawToBmp() to create small image of a PDF page.

However, we found that the image is getting darker than the original document when generating thumbnails of document. Some page even get a all black image when generating a small resolution thumbnail image.

Attached images as an example.
The images are generated with page 4 of file in www.info.gov.hk/tpb/tc/plan_application/..._YL-LFS_8_5_gist.pdf
backup_thumb_large_90364377 is an image generated in full page resolution
backup_thumb_90364255 is thumbnails generated with a smaller resolution.
It is observed that backup_thumb_90364255 is a lot darker than the larger image.

We are using Radaee version 1.1 at the past with the same set of code, and it works perfectly for the thumbnail.

Please advice what we can do for fixing this issue.

Thank you
Attachments:

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

Android - Page image dimmed in small resolution 1 year 6 months ago #12363

  • nermeen
  • nermeen's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 865
  • Karma: 23
  • Thank you received: 70
It's a precision issue, when the thumbnail is smaller the pixel calculation loses precision specially if the original page size is big.
So, we recommend to use a size bigger than 200*200.
and also to use the latest version 3.13.
One more workaround, is to use the thumbnail included in the pdf (if exists), for a code sample, please check PDFGridItem.render
attached is a thumbnail produced with the below code:
try {
	int iw = 384;
	int ih = 384;
	int pageno = 3;
	Page page = m_doc.GetPage(pageno);
	Bitmap bmp = Bitmap.createBitmap( iw, ih, Bitmap.Config.ARGB_8888 );
	bmp.eraseColor(Color.WHITE);
	float w = m_doc.GetPageWidth(pageno);
	float h = m_doc.GetPageHeight(pageno);
	float ratiox = iw/w;
	float ratioy = ih/h;
	if( ratiox > ratioy ) ratiox = ratioy;
		Matrix mat = new Matrix( ratiox, -ratiox, (iw - w * ratiox)/2, (ih + h * ratiox)/2 );
		page.RenderPrepare((Bitmap) null);
		page.RenderToBmp(bmp, mat);
		mat.Destroy();
		FileOutputStream fos = new FileOutputStream("/mnt/sdcard/test.png");
		bmp.compress(Bitmap.CompressFormat.PNG, 90, fos);
		fos.close();
		page.Close();
		bmp.recycle();
} catch (IOException e) {
	e.printStackTrace();
}
Attachments:

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

  • Page:
  • 1
Powered by Kunena Forum