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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - DrawImage function problem
  FAQ FAQ  Forum Search   Register Register  Login Login

DrawImage function problem

 Post Reply Post Reply
Author
Message
alinux View Drop Down
Team Player
Team Player


Joined: 09 Dec 08
Location: France
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote alinux Quote  Post ReplyReply Direct Link To This Post Topic: DrawImage function problem
    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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 07 Jun 12 at 2:00PM
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.
Back to Top
alinux View Drop Down
Team Player
Team Player


Joined: 09 Dec 08
Location: France
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote alinux Quote  Post ReplyReply Direct Link To This Post Posted: 07 Jun 12 at 5:17PM
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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 08 Jun 12 at 11:53AM
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.
Back to Top
alinux View Drop Down
Team Player
Team Player


Joined: 09 Dec 08
Location: France
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote alinux Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jun 12 at 7:50PM
Mea culpa.

Thank you Andrew for your explanation and your time.

alinux

alinux
Back to Top
Autodidact View Drop Down
Team Player
Team Player
Avatar

Joined: 03 Feb 06
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote Autodidact Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jun 12 at 10:22PM
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)
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store