-1

Actually i am using the mupdf library to fetch the images by using

drawPage(bitmap, pdfwidth, pdfHeight,x,y, imageWidth, imageHeight);

but the quality of image is not upto the mark , So I increased the imageHeight and imageWidth then i am getting the high quality image but the image is taking too much memory so that i am getting out of memory exception.

Can any one suggest which is the best way to resolve this problem. do i need to tiling after getting quality image? or can i do something to get high quality image taking less memory ?

or any other best way to do this?

Thanks in Advance.

srikanth
  • 1
  • 1

1 Answers1

0

You are dealing in uncompressed images, so the memory usage is directly related to the width multiplied by the height. There's not anything you can do to reduce that memory usage whilst keeping a high resolution without reducing the colour depth, which I suspect you don't want to do.

So the solution is tiles (or, depending on what you are trying to accomplish, bands - bands would be the more normal solution for printing or exporting to png).

You could deal with the bands at the java level. Or if you are trying to export to png or a similar format, you could write code at the C level based on source/tools/mudraw.c in the mupdf codebase, which uses bands to keep the memory usage down (and can also use multiple threads to increase the speed on devices that have multiple CPU cores).

It's hard to say which solution would be best without knowing what you are trying to achieve. If you are not familiar with C and JNI you are probably best going with a java solution.

JosephH
  • 37,173
  • 19
  • 130
  • 154