DBImage, calculating size so it can be centered on page
Hi,
I have a DBImage component. I need to center this image in the heading.
For example, if the image is 100 pixels wide then the image needs to display
(PageWidth - MarginLeft -MarginRight / 2) - (ImageWidth / 2).
Now I have made a large DBImage area to encompass the image. I can't use
Stretch as this resizes the image to the height and width of the DBImage
component. I really need the DBImage to resize itself to the actual size of
the stored image.
Can this be done from RAP? Alternatively, how can I calculate the width in
pixels of a bmp image from the database field and convert this to the actual
measurements used by ReportBuilder, so that I could adjust the size of the
DBImage and position from within the Report BeforePrint method?
Regards
Alex
I have a DBImage component. I need to center this image in the heading.
For example, if the image is 100 pixels wide then the image needs to display
(PageWidth - MarginLeft -MarginRight / 2) - (ImageWidth / 2).
Now I have made a large DBImage area to encompass the image. I can't use
Stretch as this resizes the image to the height and width of the DBImage
component. I really need the DBImage to resize itself to the actual size of
the stored image.
Can this be done from RAP? Alternatively, how can I calculate the width in
pixels of a bmp image from the database field and convert this to the actual
measurements used by ReportBuilder, so that I could adjust the size of the
DBImage and position from within the Report BeforePrint method?
Regards
Alex
This discussion has been closed.
Comments
This should work fine in RAP, but initially I would suggest getting it
working in Delphi first, then it will be easier to port over to RAP. You
should be able to load the image into either a DBImage or a regular TppImage
component and set the AutoSize property to True so the images will
automatically resize to their original sizes. Also, check out the
ppUtils.pas file for functions to convert pixel values to microns and vice
versa.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
As there is no Autosize option within the end-user capability, I have set
the Autosize in code on the BeforePrint of the report. The ppDBImage,
however does not resize. I put some calculated fields in the report to tell
me the values, and it reports back that the component IS set to Autosize,
but the values reported of the DBImage size and width is the same as at
design time, no matter what size graphic is in the control. Is it possible
that Autosize does not work in RB 6.03?
Maybe then I need to calculate the pixel size myself, and convert to microns
(ReportBuilder measurement?) and set the size that way?
Regards
Alex
Sorry about that, you're best approach would be to load the image directly
from the datapipeline into a regular TppImage. Then from here you can
access the TppImage.Picture.Bitmap property and find out the image
dimentions. Then you could use the ppUtils functions to convert to microns
and place the image where you need it.
--
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com