If asked for a thumbnail image with small width and height, the image generated seems quite distorted with single lines appearing choppy though the original PDF page is very clear.
We have tried to get thumbnail with width 100 and height 80.
If asked for a thumbnail with higher width and height, the image generated is quite clear.
We are using the below code to get thumbnail previews for PDF pages
PDF_DIB m_dib = NULL;
PDF_DIB bmp = Global_dibGet(m_dib, imageWidth, imageHeight);
float ratiox = imageWidth/w;
float ratioy = imageHeight/h;
if (ratiox>ratioy) {
ratiox = ratioy;
}
ratiox = ratiox * 1.0;
PDF_MATRIX mat = Matrix_createScale(ratiox, -ratiox, 0, h * ratioy);
Page_renderPrepare(page.handle, bmp);
Page_render(page.handle, bmp, mat, false, 1);
Matrix_destroy(mat);
page = nil;
void *data = Global_dibGetData(bmp);
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, data, imageWidth * imageHeight * 4, NULL);
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGImageRef imgRef = CGImageCreate(imageWidth, imageHeight, 8, 32, imageWidth<<2, cs, kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, provider, NULL, FALSE, kCGRenderingIntentDefault);
CGColorSpaceRelease(cs);
CGDataProviderRelease(provider);
UIImage *imgDef = [UIImage imageWithCGImage:imgRef];