Rank: Newbie
Groups: Registered
Joined: 1/20/2016(UTC) Posts: 7
|
Previously I created png using ghostscript (pnggray argument), a 1679x2609 greyscale png - size is about 88 KB. Using pdfium, how would I get something comparable in size?
right now it is coming out rgb and about 700-800 KB.
|
|
|
|
|
|
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 render page with grayscale flag into 8bpp indexed bitmap. Somthig like this: Code:
using (var doc = PdfDocument.Load(@"document.pdf"))
{
var page = doc.Pages[0];
int width = (int)page.Width;
int height = (int)page.Height;
int stride = width + (4 - width % 4);
IntPtr buffer = Marshal.AllocHGlobal(stride * height * 1);
using (var bmp = new PdfBitmap(width, height, BitmapFormats.FXDIB_8bppRgb, buffer, stride))
{
bmp.FillRect(0, 0, (int)width, (int)height, Color.White);
page.Render(bmp, 0, 0, width, height, PageRotate.Normal, RenderFlags.FPDF_GRAYSCALE);
bmp.Image.Save(@"document.png", ImageFormat.Png);
}
}
Edited by user Wednesday, July 20, 2016 3:27:58 PM(UTC)
| Reason: Not specified
|
|
|
|
|
|
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