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

Extract small part of vector PDF as bitmap

More
9 years 9 months ago #10763 by dsommer
Hi,
we are trying to create a Bitmap from a very small part of a vector PDF in a high resolution like this:
Code:
@NonNull private Bitmap getBitmapForRect(Page page, int widthpa, float heightpa) { int x = 500; int y = 700; Rect rect = new Rect(x, x, y, y); int width = rect.right - rect.left; int height = rect.bottom - rect.top; Document m_doc = document; int pageWidth = Math.round(document.GetPageWidth(0)); int pageHeight = Math.round(document.GetPageHeight(0)); float scaleX = (float)pageWidth / (float)m_doc.GetPageWidth(0); float scaleY = -scaleX; float originX = -rect.left; float originY = pageHeight - rect.top; Matrix matrix = new Matrix(scaleX, scaleY, originX, originY); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.eraseColor(Color.WHITE); page.RenderToBmp(bitmap, matrix); matrix.Destroy();
This works and allows to generate a PDF from a specified area.

However, the size of the resulting Bitmap seems to be determined by the original size of the PDF and the quality is not very good.
Is there any way to extract parts of a Vector PDF in high quality?
More
9 years 9 months ago #10768 by radaee
sorry, what your mean quality?
is there pixels offset or others?
More
9 years 9 months ago #10772 by dsommer
Hey,
I mean that the size of the bitmap is very small, so if I scale it up it becomes very blurry.
I wonder how to properly set the size of the resulting bitmap.
Thanks,
David
More
9 years 9 months ago #10775 by Davide
Hi,
to make the bitmap bigger you have to increase Bitmap width and height, something like that:
Code:
Bitmap bitmap = Bitmap.createBitmap(width + 100, height + 100, Bitmap.Config.ARGB_8888);

Let me know if it's what you are looking for..
Time to create page: 0.402 seconds
Powered by Kunena Forum