PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Images with 1bpp and 4bpp allocate too many memory
https://forum.pdfsharp.net/viewtopic.php?f=3&t=964
Page 1 of 1

Author:  jni [ Mon Nov 30, 2009 3:39 pm ]
Post subject:  Images with 1bpp and 4bpp allocate too many memory

For Images stored in an PDF with the function ReadIndexedMemoryBitmap() in PdfImage.cs were always 1 Byte per Pixel allocated independent from the bitdepth. This can potentially cause Problems (but must not). I have replaceded the sourceline
Code:
 byte[] imageData = new byte[1 * width * height];

with
Code:
byte[] imageData = new byte[(width*bits+7)/8 * height];

This should allocate the correct size and works for me.

Author:  Thomas Hoevel [ Mon Nov 30, 2009 4:48 pm ]
Post subject:  Re: Images with 1bpp and 4bpp allocate too many memory

Yep, the new code is correct - I made that change a few weeks ago and it'll be corrected with version 1.31 coming out very soon now.
Anyway: thank you very much for the feedback!

It's only an allocation of temporary memory while processing the image.
It has no effect on the filesize of the PDF that is created.

I also made some changes that can lead to smaller PDF files.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/