Hi,
I would like to render part of a page into an Android Bitmap. I am using RenderToBmp(Bitmap bitmap, Matrix mat) from com.radaee.pdf.Page.
This method takes in argument a com.radaee.pdf.Matrix which has the following constructor documentation:
Matrix(float sx, float sy, float x0, float y0)
constructor for scaled values.
xx = sx;
yx = 0;
xy = 0;
yx = sy;
Matrix(float xx, float yx, float xy, float yy, float x0, float y0)
constructor for full values.
From:
Matrix
Is there some better documentation somewhere? I have no idea what the parameters are supposed to mean. I have seen some example with something like (scalex, -scalex, 0, h) but I am still not sure what this represents. I have tried with (1, -1, 0, m_doc.GetPageHeight(m_pageno) - height) and I get a Bitmap which seems to have the right size and scale but it is not the section of the page that I am expecting. It is a bit too high and too much on the left.
Does someone know what the Matrix parameters mean and maybe have some idea what is missing or wrong in the way I am trying this?
Here is a code sample.
- rect is the part of the page that I would like to get in the Bitmap.
- m_view is a com.radaee.view.PDFView.
- m_doc is a com.radaee.pdf.Document.
- m_pageno is the number of the displayed page.
public Bitmap getBitmapForRect(Rect rect) {
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
// XXX matrix parameters for no transformation?
Matrix defaultMatrix = new Matrix(0, 0, 0, 0);
Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
m_view.vGetPage(m_pageno).GetPage().RenderToBmp(bitmap, defaultMatrix);
defaultMatrix.Destroy();
return bitmap;
}