- Posts: 1
- Thank you received: 0
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Tell us about your applications and your projects.
Android - Page image dimmed in small resolution
IP: 192.168.0.71
8 years 10 months ago #12352
by JackyHo
Android - Page image dimmed in small resolution was created by JackyHo
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
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
IP: 192.168.0.71
8 years 10 months ago #12363
by nermeen
Replied by nermeen on topic Android - Page image dimmed in small resolution
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:
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:
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();
}
Attachment test.png not found
Time to create page: 0.397 seconds