Hi!
I try to add an image to a Page but when I load the image to an Image object the height and width of the object is all wrong.
The image I load is in 72 dpi and with 560x670 pixels. When I load the image into the object the image.width is 160.8. The image won't fit into the area I have for the picture and no matter how I scale it will come out al wrong because of this.
What am I doing wrong. Here's some of my code:
Dim img As New ceTe.DynamicPDF.PageElements.Image(filePath, x, y))
Dim scale As Single = 1
Dim hScale As Single = 1
Dim wScale As Single = 1
If (img.Height > constMaxImageHeight) Then
hScale = constMaxImageHeight / img.Height
End If
If (img.Width > constMaxImageWidth) Then
wScale = constMaxImageWidth / img.Width
End If
If (hScale > wScale) Then
scale = wScale
Else
scale = hScale
End If
img.ScaleX = scale
img.ScaleY = scale
objPage.Elements.Add(img)
Thanks!
Johan
Image problem
Re: Image problem
Support · Oct 7, 2008Hello Johan,
Many image formats contain a target resolution within the file. If this information is present it is read from the file and used as the default resolution when a scale is not specified. If this information is not present, the default scale is 0.24 or 300 dpi.
You are creating the image object without specifying the scale so it is taking the default from the image if it is present in it or it is .24 (300dpi). The height returned in the "If" condition depends on this scale factor of the image.
You can also set the desired height and width to the image by using the Height and Width properties of the image object. You can refer to the Image Resolution
topic on our help documentation for further information on resolution.
Thanks,
ceTe Software Support Team.