Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
DrawImage function problem |
Post Reply ![]() |
Author | |
alinux ![]() Team Player ![]() Joined: 09 Dec 08 Location: France Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() Posted: 07 Jun 12 at 9:08AM |
Hello,
Using DrawImage/DrawScaledImage alter image resolution (any image format) in PDF (even using ImageHorizontalResolution & ImageVerticalResolution). Do anyone have an idea to how avoid this? Thanks, alinux |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Can you post a code sample.
PostScript and PDF scale the image to the required size so the resolution will change. This is how it is designed to work. What exactly are you trying to acheive ? smaller filesize ? Andrew.
|
|
![]() |
|
alinux ![]() Team Player ![]() Joined: 09 Dec 08 Location: France Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() |
Hi Andrew,
I'd like only to draw an image (a logo for example) into a PDF. As result I have a "pixelated" image into the pdf. I only load image from resources file (c# .Net) and use drawimage function. Same result with drawscaledimage function (scale level = 1): MemoryStream ms = new MemoryStream(); Image img = ProjectName.ResourceFile.bpo_logo; img.Save(ms, ImageFormat.Jpeg); qp.AddImageFromVariant(ms.ToArray(), 0); qp.SelectImage(qp.GetImageID(1)); qp.DrawImage(30, 30, qp.ImageWidth(), qp.ImageHeight()); I have the same result with all image formats (BMP, TIF, GIF, JPG, PNG). alinux |
|
alinux
|
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
ImageWidth and ImageHeight return a value in pixels so you cannot use this pixel value directly in DrawImage as it require a location in points (72 points = 1 inch)
Here is some code that will do what you need. QP.SetMeasurementUnits(0); int dpix = QP.ImageHorizontalResolution(); int dpiy = QP.ImageVerticalResolution(); if (dpix == 0) dpix = 72; if (dpiy == 0) dpiy = 72; int xx = QP.ImageWidth(); int yy = QP.ImageHeight(); double ImageWidthInPoints = (double)QP.ImageWidth() / dpix * 72.0; // assumming dpi units double ImageHeightInPoints = (double)QP.ImageHeight() / dpiy * 72.0; QP.DrawImage(0, 0, ImageWidthInPoints, ImageHeightInPoints); Andrew. |
|
![]() |
|
alinux ![]() Team Player ![]() Joined: 09 Dec 08 Location: France Status: Offline Points: 20 |
![]() ![]() ![]() ![]() ![]() |
Mea culpa.
Thank you Andrew for your explanation and your time. alinux |
|
alinux
|
|
![]() |
|
Autodidact ![]() Team Player ![]() ![]() Joined: 03 Feb 06 Status: Offline Points: 21 |
![]() ![]() ![]() ![]() ![]() |
How about using vector-logos? If the logo don't have to be in bitmap, which it rarely should/do, you could have a crisp logo scaled to any size — with a very low disk footprint.
|
|
Haakon 8o)
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store