Rank: Newbie
Groups: Registered
Joined: 12/4/2017(UTC) Posts: 9  Location: Bratislava
|
Hello, how can I specify filter for image: DCTDecode, JBIG2Decode, JPXDecode, FlateDecode... I need to optimize size of pdf which contains only one image per page and trying to use jpeg format, but I do not know how. I'm using following code to create PdfBitmap: Code:PdfBitmap result = null;
BitmapFormats pdfFormat;
int[] palette;
GetPdfFormat(bitmap, out pdfFormat, out palette);
var lockInfo = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
result = new PdfBitmap(bitmap.Width, bitmap.Height, pdfFormat, lockInfo.Scan0, lockInfo.Stride);
bitmap.UnlockBits(lockInfo);
if (palette != null)
{
result.Palette = palette;
}
Thank you.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
PdfBitmap is by definition an uncompressed image. Compression mode should be applied to the PdfImageObject, that is placed in the content stream on a page.
When the PdfBitmap inserted into PdfImageObject the FlateDecode is used to compress this image. This is by default behavior.
You may try PdfImageObject.LoadJpegFile(). In this case JPXDecode will be applied.
Also you may try to create monochrome bitmap instead of argb format.
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 12/4/2017(UTC) Posts: 9  Location: Bratislava
|
Thanks, loading jpeg works.
It decodes Jpeg image by DCTDecode. Jpeg has sense only for images in color. 8bpp (grayscale) and 1bpp (black white) can't be used in jpeg. Is there any other way to optimize the size of PDF?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
You can try encode such images yourself and write raw bytes into the image object stream.
Also you may try to create PdfBitmap with appropriate pixel format.
|
|
|
|
|
|
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close